【问题标题】:How To Parse Image Byte[] Array如何解析图像字节 [] 数组
【发布时间】:2012-08-15 18:38:12
【问题描述】:

我的 Android 相机正在将整个图像传递到 onPreviewFrame 中,但我只想要对应于像素范围的字节。 例如,通过一个像素为 480x640 的图像。我想要一个新的 byte[] 数组,其像素在 Rect(100,100,200,200) 范围内

public void onPreviewFrame(byte[] arg0, Camera arg1) {
    // arg0 = 460,800 BYTES
    // the camera's resolution is at 640 x 480
    // arg0 format is NV21
}

【问题讨论】:

标签: android bitmap camera byte


【解决方案1】:

尝试使用http://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html

和BitmapRegionDecoder类的方法newInstance(InputStream stream, boolean isShareable)。接下来就可以使用了

BitmapRegionDecoder decoder = newInstance(stream,false)
Bitmap region = decoder.decodeRegion(new Rect(x, y, x1, y1), null);

【讨论】:

  • 我试过用这个方法,但它只支持JPEG和PNG图片格式,我的安卓相机也不支持。不过还是谢谢!
猜你喜欢
  • 1970-01-01
  • 2020-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-17
相关资源
最近更新 更多