Skip to content

Instantly share code, notes, and snippets.

@kimkidong
Created August 14, 2012 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimkidong/3346014 to your computer and use it in GitHub Desktop.
Save kimkidong/3346014 to your computer and use it in GitHub Desktop.
Convert YUV420 to RGB8888
// in Camera callback preview
int w = params.getPreviewSize().width;
int h = params.getPreviewSize().height;
int format = params.getPreviewFormat();
YuvImage image = new YuvImage(data, format, w, h, null);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Rect area = new Rect(0, 0, w, h);
image.compressToJpeg(area, 50, out);
Bitmap bm = BitmapFactory.decodeByteArray(out.toByteArray(), 0, out.size());
ivCam.setImageBitmap(bm);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment