I built my own camera app with the camera2 API. I started with the sample \"camera2Raw\" and I added YUV_420_888 support instead of JPEG. But now I am wondering how I save t
If you have the YuvImage object then you can convert it to Jpeg using the compressToJpeg function like so.
ByteArrayOutputStream out = new ByteArrayOutputStream();
YuvImage yuvImage = new YuvImage(data, ImageFormat.NV21, width, height, null);
yuvImage.compressToJpeg(new Rect(0, 0, width, height), 50, out);
byte[] imageBytes = out.toByteArray();
Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
iv.setImageBitmap(image);
You have to set the width and height of the image explicitly though.