Skip to content

Instantly share code, notes, and snippets.

@acontal
Created January 19, 2014 15:35
Show Gist options
  • Save acontal/8506445 to your computer and use it in GitHub Desktop.
Save acontal/8506445 to your computer and use it in GitHub Desktop.
[android] Save the raw preview image provided by the Camera's preview as a JPEG file.
// Input: byte[] data, int width, int height, File jpegFile
YuvImage yuvImage = new YuvImage(data, ImageFormat.NV21, width, height, null);
FileOutputStream jepgFileOS = new FileOutputStream(jpegFile);
yuvimage.compressToJpeg(new Rect(0, 0, width, height), 95, jpegFileOS);
jpegFileOS.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment