1、YUV转bitmap
// YUV转RGB
final YuvImage image = new YuvImage(verifyResult.getImageBuf(), ImageFormat.NV21, 640, 480,
null);
ByteArrayOutputStream os = new ByteArrayOutputStream(verifyResult.getImageBuf().length);
if (!image.compressToJpeg(new Rect(0, 0, 640, 480), 100, os)) {
return;
}
byte[] tmp = os.toByteArray();
Bitmap bmp = BitmapFactory.decodeByteArray(tmp, 0, tmp.length);
2、byte[] 生成bitmap
bmp = Bitmap.createBitmap(640, 480, Bitmap.Config.ARGB_8888);
ByteBuffer tmpBuf= ByteBuffer.wrap(verifyResult.getImageBuf());
bmp.copyPixelsFromBuffer(tmpBuf);