转自文章《Android--将NV21图像保存成JPEG》http://blog.csdn.net/tanmengwen/article/details/41412425
将NV21数据压缩成JPEG,并得到JPEG byte数据,解压JPEG byte数据成一张Bitmap
- @Override
- public void onPreviewFrame(byte[] bytes, Camera camera) {
-
- YuvImage image = new YuvImage(bytes, ImageFormat.NV21, width, height, null);
- ByteArrayOutputStream outputSteam = new ByteArrayOutputStream();
- image.compressToJpeg(new Rect(0, 0, image.getWidth(), image.getHeight()), 70, outputSteam);
- byte[] jpegData = outputSteam.toByteArray();
-
- Options options = new BitmapFactory.Options();
- options.inSampleSize = 1;
- Bitmap bmp = BitmapFactory.decodeStream(jpegData, null, options);
- }