I have attempted to crop image from a Bitmap using YuvImage like this:
Bitmap bitmap=params[0];
ByteArrayOutputStream bos=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
byte[] data=bos.toByteArray();
//bos=null;
YuvImage yuvImage=new YuvImage(data, ImageFormat.NV21, bitmap.getWidth(), bitmap.getHeight(),null);
bos=new ByteArrayOutputStream();
boolean isCropped=yuvImage.compressToJpeg(rect, 100, bos);
if(isCropped)
data=bos.toByteArray();
bitmap=BitmapFactory.decodeByteArray(data, 0, data.length);
return bitmap;
This causes the resulting image
Is there an alternate approach in order to crop and save the image without using the Intent
.
You consider Bitmap.CompressFormat.JPEG as ImageFormat.NV21 which shouldn't be true.