Android 显示YUV编码格式

                ByteArrayOutputStream out = new ByteArrayOutputStream();
String path = "res/drawable/sample.yuv";
byte buffer[];
buffer = new byte[1024*1024]; InputStream is = getClassLoader().getResourceAsStream(path);
try{
is.read(buffer);
}catch (Exception e)
{
e.printStackTrace();
} YuvImage yuvImage;
yuvImage = new YuvImage(buffer, ImageFormat.NV21, 640, 480, null);
yuvImage.compressToJpeg(new Rect(0, 0, 640, 480), 50, out);
byte[] imageBytes = out.toByteArray();
Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); ImageView iv = (ImageView) findViewById(R.id.iv);
iv.setImageBitmap(image);
上一篇:jackson学习之十(终篇):springboot整合(配置类)


下一篇:双向广搜+hash+康托展开 codevs 1225 八数码难题