// 测试OK
public static Bitmap yuv2Bmp(byte[] data, int width, int height) {
ByteArrayOutputStream baos;
byte[] rawImage;
Bitmap bitmap;
BitmapFactory.Options newOpts = new BitmapFactory.Options();
newOpts.inJustDecodeBounds = true;
YuvImage yuvimage = new YuvImage(
data,
ImageFormat.YUY2,
width,
height,
null);
baos = new ByteArrayOutputStream();
yuvimage.compressToJpeg(new Rect(0, 0, width, height), 100, baos);
rawImage = baos.toByteArray();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
bitmap = BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length, options);
return bitmap;
}
其实代码就是上面这些了,但是需要注意的是我们平时说的yuy2数据格式其实就是yuyv或者yuv422数据格式
day day up!

1944

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



