private Bitmap byte2bitmap(byte[] bytes, Camera camera) {
Camera.Size size = camera.getParameters().getPreviewSize(); // 获取预览大小
final int w = size.width; // 宽度
final int h = size.height;
final YuvImage image = new YuvImage(bytes, ImageFormat.NV21, w, h,
null);
ByteArrayOutputStream os = new ByteArrayOutputStream(bytes.length);
if (!image.compressToJpeg(new Rect(0, 0, w, h), 100, os)) {
return null;
}
byte[] tmp = os.toByteArray();
// CameraRelease();
BitmapFactory.Options localOptions = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeByteArray(tmp, 0, tmp.length,localOptions);
//
return bitmap;
}
Camera byte[] - > jpeg android
最新推荐文章于 2021-04-13 16:27:54 发布