OpModeCamera.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:OpModeCamera 作者:
static public Bitmap convertYuvImageToRgb(YuvImage yuvImage, int width, int height, int downSample) {
  Bitmap rgbImage;
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  yuvImage.compressToJpeg(new Rect(0, 0, width, height), 0, out);
  byte[] imageBytes = out.toByteArray();

  BitmapFactory.Options opt;
  opt = new BitmapFactory.Options();
  opt.inSampleSize = downSample;

  // get image and rotate it so (0,0) is in the bottom left
  Bitmap tmpImage;
  Matrix matrix = new Matrix();
  matrix.postRotate(90); // to rotate the camera images so (0,0) is in the bottom left
  tmpImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length, opt);
  rgbImage=Bitmap.createBitmap(tmpImage , 0, 0, tmpImage.getWidth(), tmpImage.getHeight(), matrix, true);

  return rgbImage;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号