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
.
您将Bitmap.CompressFormat.JPEG视为ImageFormat.NV21,这不应该是真的。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.