/**
* 把一帧yuv数据保存为bitmap
* @param yuv 数据流
* @param mWidth 图片的宽
* @param mHeight 图片的高
* @return bitmap 对象
*
*/
public Bitmap saveYUV2Bitmap(byte[] yuv, int mWidth, int mHeight) {
YuvImage image = new YuvImage(yuv, ImageFormat.NV21, mWidth, mHeight, null);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compressToJpeg(new Rect(0, 0, mWidth, mHeight), 100, stream);
Bitmap bmp = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size());
try {
stream.flush();
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
return bmp;
}
把YUV数据保存成图片
最新推荐文章于 2025-09-03 14:23:37 发布
3万+

被折叠的 条评论
为什么被折叠?



