这里为已经打包好的yuv.so
通过ImageReader获得数据来源借助libyuv做转换
Image image = mImageReader.acquireLatestImage()
图片格式决定了image里面planes有几个数组
如下:
/**
* Only a subset of the formats defined in
* {@link android.graphics.ImageFormat ImageFormat} and
* {@link android.graphics.PixelFormat PixelFormat} are supported by
* ImageReader. When reading RGB data from a surface, the formats defined in
* {@link android.graphics.PixelFormat PixelFormat} can be used; when
* reading YUV, JPEG, HEIC or raw sensor data (for example, from the camera
* or video decoder), formats from {@link android.graphics.ImageFormat ImageFormat}
* are used.
*/
public static int getNumPlanesForFormat(int format) {
switch (format) {
case ImageFormat.YV12:
case ImageFormat.YUV_420_888:
case ImageFormat.NV21:
return 3;
case ImageFormat.NV16:
return 2;
case PixelFormat.RGB_565:
case PixelFormat.RGBA_8888:
case PixelFormat.RGBX_8888:
case PixelFormat.RGB_888:
case ImageFormat.JPEG:
case ImageFormat.YUY2:
case ImageFormat.Y8:
case ImageFormat.Y16:
case ImageFormat.RAW_SENSOR:
case ImageFormat.RAW_PRIVATE:
case ImageFormat.RAW10:
case ImageFormat.RAW12:
case ImageFormat.DEPTH16:
case ImageFormat.DEPTH_POINT_CLOUD:
case ImageFormat.RAW_DEPTH:
case ImageFormat.DEPTH_JPEG:
case ImageFormat.HEIC:
return 1;
case ImageFormat.PRIVATE:
return 0;
default:
throw new UnsupportedOperationException(
String.format("Invalid format specified %d", format));
}
}
以上为ImageUtility里面给出的线索,故从此之后再也不愁应该在image的planes里面取几组数据了。