鸿蒙系统 api,鸿蒙OS《Native API参考》

本文档介绍了ImageOverview库中关于像素数据的访问控制和映射信息获取的方法,包括锁定和解锁内存、获取像素地图尺寸,以及不同返回结果代码和像素格式的枚举。重点讲解了AccessPixels和GetImageInfo函数的用法及注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Image

Overview

Provides access to pixel data and pixel map information.

Since:

3

Version:

1.0

Summary

Files

File Name

Description

image_pixel_map.h

Declares functions for you to lock and access or unlock pixel data, and obtain the width and height of a pixel map.

Data Structures

Data Structure Name

Description

OhosPixelMapInfo

Defines pixel map information.

Enumerations

Enumeration Name

Description

{ OHOS_IMAGE_RESULT_SUCCESS = 0, OHOS_IMAGE_RESULT_BAD_PARAMETER = -1, OHOS_IMAGE_RESULT_JNI_EXCEPTION = -2 }

Enumerates the result codes that may be returned by a function.

{ OHOS_PIXEL_MAP_FORMAT_NONE = 0, OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3, OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2 }

Enumerates pixel formats.

Functions

Function Name

Description

GetImageInfo (JNIEnv *env, jobject pixelMapObject, OhosPixelMapInfo &info)

int32_tObtains information about a given PixelMap and stores the information in a OhosPixelMapInfo structure.

AccessPixels (JNIEnv *env, jobject pixelMapObject, void **addrPtr)

int32_tObtains the memory address of a given PixelMap object and locks the memory.

UnAccessPixels (JNIEnv *env, jobject pixelMapObject)

int32_tUnlocks the memory storing the pixel data of a given PixelMap to balance a successful call to AccessPixels.

Details

Enumeration Type Documentation

anonymous enum

anonymous enum

Description:

Enumerates the result codes that may be returned by a function.

Enumerator

Description

OHOS_IMAGE_RESULT_SUCCESS

Success result

OHOS_IMAGE_RESULT_BAD_PARAMETER

Invalid parameters

OHOS_IMAGE_RESULT_JNI_EXCEPTION

JNI exception

anonymous enum

anonymous enum

Description:

Enumerates pixel formats.

Enumerator

Description

OHOS_PIXEL_MAP_FORMAT_NONE

Unknown format

OHOS_PIXEL_MAP_FORMAT_RGBA_8888

32-bit RGBA. Components R, G, B, and A each occupies 8 bits and are stored from the higher-order to the lower-order bits.

OHOS_PIXEL_MAP_FORMAT_RGB_565

16-bit RGB. Only the R, G, and B components are encoded from the higher-order to the lower-order bits: red is stored with 5 bits of precision, green is stored with 6 bits of precision, and blue is stored with 5 bits of precision.

Function Documentation

AccessPixels()

int32_t AccessPixels (JNIEnv * env, jobject pixelMapObject, void ** addrPtr )

Description:

Obtains the memory address of a given PixelMap object and locks the memory.

If this function call is successful, *addrPtr is set to the memory address. After accessing the pixel data, you must use UnAccessPixels to unlock the memory. Otherwise, resources cannot be released. After the memory is unlocked, it can be invalid and should not be accessed.

Parameters:

Name

Description

env

Indicates the pointer to the JNI environment.

pixelMapObject

Indicates the Java PixelMap object.

addrPtr

Indicates the double pointer to the memory address.

See also:

UnAccessPixels

Returns:

Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns other result codes if the operation fails.

GetImageInfo()

int32_t GetImageInfo (JNIEnv * env, jobject pixelMapObject, OhosPixelMapInfo & info )

Description:

Obtains information about a given PixelMap and stores the information in a OhosPixelMapInfo structure.

Parameters:

Name

Description

env

Indicates the pointer to the JNI environment.

pixelMapObject

Indicates the Java PixelMap object.

info

Indicates the pointer to the pixel map information to obtain. For details, see OhosPixelMapInfo.

Returns:

Returns 0 if the information is obtained and stored in the structure; returns result codes if the operation fails. OhosPixelMapInfo 3 1.0

UnAccessPixels()

int32_t UnAccessPixels (JNIEnv * env, jobject pixelMapObject )

Description:

Unlocks the memory storing the pixel data of a given PixelMap to balance a successful call to AccessPixels.

Parameters:

Name

Description

env

Indicates the pointer to the JNI environment.

pixelMapObject

Indicates the Java PixelMap object.

Returns:

Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns other result codes if the operation fails.

See also:

AccessPixels

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值