ByteBufferExtractor

public class ByteBufferExtractor

Utility for extracting ByteBuffer from MPImage.

Currently it only supports MPImage with MPImage.STORAGE_TYPE_BYTEBUFFER, otherwise IllegalArgumentException will be thrown.

Public Methods

static ByteBuffer
extract(MPImage image)
Extracts a ByteBuffer from a MPImage.
static ByteBuffer
extract(MPImage image, int targetFormat)
Extracts a readonly ByteBuffer in given targetFormat from a MPImage.

Inherited Methods

Public Methods

public static ByteBuffer extract (MPImage image)

Extracts a ByteBuffer from a MPImage.

The returned ByteBuffer is a read-only view, with the first available MPImageProperties whose storage type is MPImage.STORAGE_TYPE_BYTEBUFFER.

Parameters
image
Returns
Throws
IllegalArgumentException when the image doesn't contain a ByteBuffer storage.

public static ByteBuffer extract (MPImage image, int targetFormat)

Extracts a readonly ByteBuffer in given targetFormat from a MPImage.

Format conversion spec:

  • When extracting RGB images to RGBA format, A channel will always set to 255.
  • When extracting RGBA images to RGB format, A channel will be dropped.

Parameters
image the image to extract buffer from.
targetFormat the image format of the result bytebuffer.
Returns
Throws
IllegalArgumentException when the extraction requires unsupported format or data type conversions.