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);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-12-20
  • 2021-09-23
  • 2022-12-23
猜你喜欢
  • 2022-02-07
  • 2022-12-23
  • 2022-01-21
  • 2022-01-01
  • 2021-10-19
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案