In my application user can select image from camera or gallery in android. After selecting image, user can also crop circular image from that original image. But after circle cropping, I am getting black rectangle image from that in HTC devices(explorer and other HTC devices). In samsung devices it works fine. I am using below code to crop image:
intent.setDataAndType(selectedImage, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("outputX", 96);
intent.putExtra("outputY", 96);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", true);
intent.putExtra("circleCrop", "true");
startActivityForResult(intent, CROP_FROM_CAMERA);
Here is my onactivityresult method where i will get cropped image:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
Bundle extras = data.getExtras();
Bitmap photo = null;
if (extras != null) {
photo = extras.getParcelable("data");
}
if (photo != null) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.PNG, 100, bytes);
byte[] b = bytes.toByteArray();
FileOutputStream out;// = new FileOutputStream(filename);
out = openFileOutput("cropImage.png", Context.MODE_PRIVATE);
out.write(b);
out.close();
pref.edit().putString(PrefernceData.PREF_IMAGE_CROP_URL,"cropImage.png").commit();
Log.i("capute", "success after crop......");
}catch (Exception e) {
Toast.makeText(this, "Can not find image crop app",
Toast.LENGTH_SHORT).show();
}
}
In above code, when I just remove this line :intent.putExtra("circleCrop", "true"); It works fine for rectangle crop image on all HTC as well as samsung devices. But i want circle crop image only. How to resolve this problem?