MPImage

public class MPImage implements Closeable


The wrapper class for image objects.

MPImage is designed to be an immutable image container, which could be shared cross-platforms.

To construct a MPImage, use the provided builders:

MPImage uses reference counting to maintain internal storage. When it is created the reference count is 1. Developer can call close to reduce reference count to release internal storage earlier, otherwise Java garbage collection will release the storage eventually.

To extract concrete image, first check StorageType and then use the provided extractors:

Summary

Nested types

@IntDef(value = )
@Retention(value = RetentionPolicy.SOURCE)
public annotation MPImage.MPImageFormat

Specifies the image format of an image.

@IntDef(value = )
@Retention(value = RetentionPolicy.SOURCE)
public annotation MPImage.StorageType

Specifies the image container type.

Constants

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

Public fields

final int
final int

Public methods

synchronized void

Removes a reference that was previously acquired or init.

List<MPImageProperties>

Returns a list of supported image properties for this MPImage.

int

Returns the height of the image.

int

Returns the width of the image.

Constants

IMAGE_FORMAT_ALPHA

public static final int IMAGE_FORMAT_ALPHA = 8

IMAGE_FORMAT_JPEG

public static final int IMAGE_FORMAT_JPEG = 9

IMAGE_FORMAT_NV12

public static final int IMAGE_FORMAT_NV12 = 3

IMAGE_FORMAT_NV21

public static final int IMAGE_FORMAT_NV21 = 4

IMAGE_FORMAT_RGB

public static final int IMAGE_FORMAT_RGB = 2

IMAGE_FORMAT_RGBA

public static final int IMAGE_FORMAT_RGBA = 1

IMAGE_FORMAT_UNKNOWN

public static final int IMAGE_FORMAT_UNKNOWN = 0

IMAGE_FORMAT_VEC32F1

public static final int IMAGE_FORMAT_VEC32F1 = 10

IMAGE_FORMAT_VEC32F2

public static final int IMAGE_FORMAT_VEC32F2 = 11

IMAGE_FORMAT_YUV_420_888

public static final int IMAGE_FORMAT_YUV_420_888 = 7

IMAGE_FORMAT_YV12

public static final int IMAGE_FORMAT_YV12 = 5

IMAGE_FORMAT_YV21

public static final int IMAGE_FORMAT_YV21 = 6

STORAGE_TYPE_BITMAP

public static final int STORAGE_TYPE_BITMAP = 1

STORAGE_TYPE_BYTEBUFFER

public static final int STORAGE_TYPE_BYTEBUFFER = 2

STORAGE_TYPE_IMAGE_PROXY

public static final int STORAGE_TYPE_IMAGE_PROXY = 4

STORAGE_TYPE_MEDIA_IMAGE

public static final int STORAGE_TYPE_MEDIA_IMAGE = 3

Public fields

height

public final int height

width

public final int width

Public methods

close

synchronized public void close()

Removes a reference that was previously acquired or init.

When MPImage is created, it has 1 reference count.

When the reference count becomes 0, it will release the resource under the hood.

getContainedImageProperties

public List<MPImageProperties> getContainedImageProperties()

Returns a list of supported image properties for this MPImage.

Currently MPImage only support single storage type so the size of return list will always be 1.

getHeight

public int getHeight()

Returns the height of the image.

getWidth

public int getWidth()

Returns the width of the image.