Bitmap

#include <bitmap.h>

Summary

Enumerations

Anonymous Enum 19{
  ANDROID_BITMAP_RESULT_SUCCESS = 0,
  ANDROID_BITMAP_RESULT_BAD_PARAMETER = -1,
  ANDROID_BITMAP_RESULT_JNI_EXCEPTION = -2,
  ANDROID_BITMAP_RESULT_ALLOCATION_FAILED = -3
}
enum
AndroidBitmap functions result code.
Anonymous Enum 20{
  ANDROID_BITMAP_FLAGS_ALPHA_PREMUL = 0,
  ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE = 1,
  ANDROID_BITMAP_FLAGS_ALPHA_UNPREMUL = 2,
  ANDROID_BITMAP_FLAGS_ALPHA_MASK = 0x3,
  ANDROID_BITMAP_FLAGS_ALPHA_SHIFT = 0
}
enum
Bitmap alpha format.
Anonymous Enum 21{
  ANDROID_BITMAP_FLAGS_IS_HARDWARE = 1 << 31
}
enum
AndroidBitmapCompressFormat{
  ANDROID_BITMAP_COMPRESS_FORMAT_JPEG = 0,
  ANDROID_BITMAP_COMPRESS_FORMAT_PNG = 1,
  ANDROID_BITMAP_COMPRESS_FORMAT_WEBP_LOSSY = 3,
  ANDROID_BITMAP_COMPRESS_FORMAT_WEBP_LOSSLESS = 4
}
enum
Specifies the formats that can be compressed to with AndroidBitmap_compress.
AndroidBitmapFormat{
  ANDROID_BITMAP_FORMAT_NONE = 0,
  ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
  ANDROID_BITMAP_FORMAT_RGB_565 = 4,
  ANDROID_BITMAP_FORMAT_RGBA_4444 = 7,
  ANDROID_BITMAP_FORMAT_A_8 = 8,
  ANDROID_BITMAP_FORMAT_RGBA_F16 = 9
}
enum
Bitmap pixel format.

Typedefs

AndroidBitmap_compress_write_fn)(void *userContext, const void *data, size_t size) __INTRODUCED_IN(30) typedef
bool(*
User-defined function for writing the output of compression.

Functions

AndroidBitmap_compress(const AndroidBitmapInfo *info, int32_t dataspace, const void *pixels, int32_t format, int32_t quality, void *userContext, AndroidBitmap_compress_write_fn fn)
int
Compress |pixels| as described by |info|.
AndroidBitmap_getDataSpace(JNIEnv *env, jobject jbitmap)
int32_t
Given a java bitmap object, return its ADataSpace.
AndroidBitmap_getHardwareBuffer(JNIEnv *env, jobject bitmap, AHardwareBuffer **outBuffer)
int
Retrieve the native object associated with a HARDWARE Bitmap.
AndroidBitmap_getInfo(JNIEnv *env, jobject jbitmap, AndroidBitmapInfo *info)
int
Given a java bitmap object, fill out the AndroidBitmapInfo struct for it.
AndroidBitmap_lockPixels(JNIEnv *env, jobject jbitmap, void **addrPtr)
int
Given a java bitmap object, attempt to lock the pixel address.
AndroidBitmap_unlockPixels(JNIEnv *env, jobject jbitmap)
int
Call this to balance a successful call to AndroidBitmap_lockPixels.

Structs

AndroidBitmapInfo

Bitmap info, see AndroidBitmap_getInfo().

Enumerations

Anonymous Enum 19

 Anonymous Enum 19

AndroidBitmap functions result code.

Properties
ANDROID_BITMAP_RESULT_ALLOCATION_FAILED

Allocation failed.

ANDROID_BITMAP_RESULT_BAD_PARAMETER

Bad parameter.

ANDROID_BITMAP_RESULT_JNI_EXCEPTION

JNI exception occured.

ANDROID_BITMAP_RESULT_SUCCESS

Operation was successful.

Anonymous Enum 20

 Anonymous Enum 20

Bitmap alpha format.

Properties
ANDROID_BITMAP_FLAGS_ALPHA_MASK

Bit mask for AndroidBitmapFormat.flags to isolate the alpha.

ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE

Pixels are opaque.

ANDROID_BITMAP_FLAGS_ALPHA_PREMUL

Pixel components are premultiplied by alpha.

ANDROID_BITMAP_FLAGS_ALPHA_SHIFT

Shift for AndroidBitmapFormat.flags to isolate the alpha.

ANDROID_BITMAP_FLAGS_ALPHA_UNPREMUL

Pixel components are independent of alpha.

Anonymous Enum 21

 Anonymous Enum 21
Properties
ANDROID_BITMAP_FLAGS_IS_HARDWARE

If this bit is set in AndroidBitmapInfo.flags, the Bitmap uses the HARDWARE Config, and its AHardwareBuffer can be retrieved via AndroidBitmap_getHardwareBuffer.

AndroidBitmapCompressFormat

 AndroidBitmapCompressFormat

Specifies the formats that can be compressed to with AndroidBitmap_compress.

Properties
ANDROID_BITMAP_COMPRESS_FORMAT_JPEG

Compress to the JPEG format.

quality of 0 means compress for the smallest size. 100 means compress for max visual quality.

ANDROID_BITMAP_COMPRESS_FORMAT_PNG

Compress to the PNG format.

PNG is lossless, so quality is ignored.

ANDROID_BITMAP_COMPRESS_FORMAT_WEBP_LOSSLESS

Compress to the WEBP lossless format.

quality refers to how much effort to put into compression. A value of 0 means to compress quickly, resulting in a relatively large file size. 100 means to spend more time compressing, resulting in a smaller file.

ANDROID_BITMAP_COMPRESS_FORMAT_WEBP_LOSSY

Compress to the WEBP lossy format.

quality of 0 means compress for the smallest size. 100 means compress for max visual quality.

AndroidBitmapFormat

 AndroidBitmapFormat

Bitmap pixel format.

Properties
ANDROID_BITMAP_FORMAT_A_8

Alpha: 8 bits.

ANDROID_BITMAP_FORMAT_NONE

No format.

ANDROID_BITMAP_FORMAT_RGBA_4444

Deprecated in API level 13.

Because of the poor quality of this configuration, it is advised to use ARGB_8888 instead.

ANDROID_BITMAP_FORMAT_RGBA_8888

Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits.

ANDROID_BITMAP_FORMAT_RGBA_F16

Each component is stored as a half float.

ANDROID_BITMAP_FORMAT_RGB_565

Red: 5 bits, Green: 6 bits, Blue: 5 bits.

Typedefs

AndroidBitmap_compress_write_fn

bool(* AndroidBitmap_compress_write_fn)(void *userContext, const void *data, size_t size) __INTRODUCED_IN(30)

User-defined function for writing the output of compression.

Details
Parameters
userContext
Pointer to user-defined data passed to AndroidBitmap_compress.
data
Compressed data of |size| bytes to write.
size
Length in bytes of data to write.
Returns
Whether the operation succeeded.

Functions

AndroidBitmap_getDataSpace

int32_t AndroidBitmap_getDataSpace(
  JNIEnv *env,
  jobject jbitmap
)

Given a java bitmap object, return its ADataSpace.

Note that ADataSpace only exposes a few values. This may return ADATASPACE_UNKNOWN, even for Named ColorSpaces, if they have no corresponding ADataSpace.

AndroidBitmap_getHardwareBuffer

int AndroidBitmap_getHardwareBuffer(
  JNIEnv *env,
  jobject bitmap,
  AHardwareBuffer **outBuffer
)

Retrieve the native object associated with a HARDWARE Bitmap.

Client must not modify it while a Bitmap is wrapping it.

Details
Parameters
bitmap
Handle to an android.graphics.Bitmap.
outBuffer
On success, is set to a pointer to the AHardwareBuffer associated with bitmap. This acquires a reference on the buffer, and the client must call AHardwareBuffer_release when finished with it.
Returns
AndroidBitmap functions result code. ANDROID_BITMAP_RESULT_BAD_PARAMETER if bitmap is not a HARDWARE Bitmap.

AndroidBitmap_getInfo

int AndroidBitmap_getInfo(
  JNIEnv *env,
  jobject jbitmap,
  AndroidBitmapInfo *info
)

Given a java bitmap object, fill out the AndroidBitmapInfo struct for it.

If the call fails, the info parameter will be ignored.

AndroidBitmap_lockPixels

int AndroidBitmap_lockPixels(
  JNIEnv *env,
  jobject jbitmap,
  void **addrPtr
)

Given a java bitmap object, attempt to lock the pixel address.

Locking will ensure that the memory for the pixels will not move until the unlockPixels call, and ensure that, if the pixels had been previously purged, they will have been restored.

If this call succeeds, it must be balanced by a call to AndroidBitmap_unlockPixels, after which time the address of the pixels should no longer be used.

If this succeeds, *addrPtr will be set to the pixel address. If the call fails, addrPtr will be ignored.

AndroidBitmap_unlockPixels

int AndroidBitmap_unlockPixels(
  JNIEnv *env,
  jobject jbitmap
)

Call this to balance a successful call to AndroidBitmap_lockPixels.