ByteBufferExtractor

公共类 ByteBufferExtractor

用于从 MPImage 中提取 ByteBuffer 的实用程序。

目前,它仅支持将 MPImageMPImage.STORAGE_TYPE_BYTEBUFFER 搭配使用,否则会抛出 IllegalArgumentException

公共方法

static ByteBuffer
提取MPImage 图片)
MPImage 中提取 ByteBuffer
static ByteBuffer
Extract(MPImage image, int targetFormat)
MPImage 中提取给定 targetFormat 中的只读 ByteBuffer

继承的方法

公共方法

public static ByteBuffer 提取 MPImage 图片)

MPImage 中提取 ByteBuffer

返回的 ByteBuffer 是一个只读视图,其中第一个可用的 MPImageProperties 的存储类型为 MPImage.STORAGE_TYPE_BYTEBUFFER

参数
图片
返回
抛出
IllegalArgumentException 当映像不包含 ByteBuffer 存储空间时。

public static ByteBuffer Extract (MPImage image, int targetFormat)

MPImage 中提取给定 targetFormat 中的只读 ByteBuffer

转换格式规范:

  • 将 RGB 图片提取为 RGBA 格式时,通道将始终设置为 255。
  • 将 RGBA 图片提取为 RGB 格式时,系统会丢弃一个通道。

参数
图片 要从中提取缓冲区的图像。
targetFormat 结果字节缓冲区的图像格式。
返回
抛出
IllegalArgumentException 提取要求进行不支持的格式或数据类型转换时触发。