android bitmap插件,Bitmap  |  Android NDK  |  Android Developers

Bitmap

#include

Summary

Typedefs

typedef

struct AHardwareBuffer

AndroidBitmap_CompressWriteFunc)(void *userContext, const void *data, size_t size)

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_CompressWriteFunc fn)

int

Compress |pixels| as described by |info|.

AndroidBitmap_getDataSpace(JNIEnv *env, jobject jbitmap)

int32_t

Given a java bitmap object, return its ADataSpace.

int

Retrieve the native object associated with a HARDWARE Bitmap.

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.

Enumerations

Anonymous Enum 25

Anonymous Enum 25

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 26

Anonymous Enum 26

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 27

Anonymous Enum 27

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

AHardwareBuffer

struct AHardwareBuffer AHardwareBuffer

AndroidBitmap_CompressWriteFunc

bool(* AndroidBitmap_CompressWriteFunc)(void *userContext, const void *data, size_t size)

User-defined function for writing the output of compression.

Available since API level 30.

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_compress

int AndroidBitmap_compress(

const AndroidBitmapInfo *info,

int32_t dataspace,

const void *pixels,

int32_t format,

int32_t quality,

void *userContext,

AndroidBitmap_CompressWriteFunc fn

)

Compress |pixels| as described by |info|.

Available since API level 30.

Details

Parameters

info

Description of the pixels to compress.

dataspace

ADataSpace describing the color space of the pixels.

pixels

Pointer to pixels to compress.

quality

Hint to the compressor, 0-100. The value is interpreted differently depending on the AndroidBitmapCompressFormat.

userContext

User-defined data which will be passed to the supplied AndroidBitmap_CompressWriteFunc each time it is called. May be null.

fn

Function that writes the compressed data. Will be called each time the compressor has compressed more data that is ready to be written. May be called more than once for each call to this method. May not be null.

Returns

AndroidBitmap functions result code.

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.

Available since API level 30.

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.

Available since API level 30.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值