0

我尝试使用 YuvImage 从位图中裁剪图像,如下所示:

        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;

这会导致生成的图像奇怪又可怕……就像一台旧的黑白电视

是否有替代方法可以在不使用Intent.

4

1 回答 1

1

您认为 Bitmap.CompressFormat.JPEG 作为 ImageFormat.NV21 这不应该是真的。

于 2013-12-03T07:21:06.363 回答