目录

pixelmap_native.h

Overview

The file declares the APIs for accessing a PixelMap. The APIs provide capabilities for accessing PixelMaps, supporting the creation of PixelMaps through pixel data, surface, NativeBuffer, and other methods, as well as cloning PixelMaps, reading and writing PixelMaps, and performing image transformations such as scaling, rotation, flipping, translation, and cropping. They also support HDR metadata management, color space configuration, alpha type conversion, interoperability between Native and Napi objects, and direct memory access. These APIs are suitable for scenarios where pixel-level processing and transformation of decoded image bitmaps are required in the native layer.

File to include: <multimedia/image_framework/image/pixelmap_native.h>

Library: libpixelmap.so

System capability: SystemCapability.Multimedia.Image.Core

Since: 12

Related module: Image_NativeModule

Summary

[h2]Structs

Name typedef Keyword Description
OH_Pixelmap_HdrStaticMetadata OH_Pixelmap_HdrStaticMetadata Describes the metadata value type corresponding to the HDR_STATIC_METADATA key in OH_Pixelmap_HdrMetadataKey, used to store HDR static metadata.
OH_Pixelmap_HdrDynamicMetadata OH_Pixelmap_HdrDynamicMetadata Describes the metadata value type corresponding to the HDR_DYNAMIC_METADATA key in OH_Pixelmap_HdrMetadataKey, used to store HDR dynamic metadata. The format conforms to relevant HDR dynamic metadata standards.
OH_Pixelmap_HdrGainmapMetadata OH_Pixelmap_HdrGainmapMetadata Describes the metadata value type corresponding to the HDR_GAINMAP_METADATA key in OH_Pixelmap_HdrMetadataKey, used to store HDR gain map metadata as defined in ISO 21496-1.
OH_Pixelmap_HdrMetadataValue OH_Pixelmap_HdrMetadataValue Describes the HDR metadata value used by the PixelMap, corresponding to a OH_Pixelmap_HdrMetadataKey. When the corresponding OH_Pixelmap_HdrMetadataKey is passed as an input parameter, this struct can be used to set or retrieve the metadata value of the corresponding type via OH_PixelmapNative_SetMetadata or OH_PixelmapNative_GetMetadata.
OH_PixelmapNative -

Uncompressed pixel map format struct encapsulated at the native layer after image decoding.

To create an OH_PixelmapNative object, call OH_PixelmapNative_CreatePixelmap. The default pixel format is BGRA_8888.

To release an OH_PixelmapNative object, call OH_PixelmapNative_Release.

OH_NativeBuffer - Describes the native buffer, which is used to perform operations related to the native buffer.
OH_NativeColorSpaceManager OH_NativeColorSpaceManager Describes the native color space manager, which is used to perform operations related to the native color space manager.
OH_Pixelmap_InitializationOptions -

Initialization parameter struct encapsulated at the native layer, used to set PixelMap initialization parameters.

To create an OH_Pixelmap_InitializationOptions object, call OH_PixelmapInitializationOptions_Create.

To release an OH_Pixelmap_InitializationOptions object, call OH_PixelmapInitializationOptions_Release.

OH_Pixelmap_ImageInfo - Describes the image information.

[h2]Enums

Name typedef Keyword Description
PIXELMAP_ALPHA_TYPE PIXELMAP_ALPHA_TYPE Enumerates the alpha types of a PixelMap.
PIXEL_FORMAT PIXEL_FORMAT Enumerates the image pixel formats.
OH_PixelmapNative_AntiAliasingLevel OH_PixelmapNative_AntiAliasingLevel Enumerates the anti-aliasing levels used for scaling PixelMaps.
OH_Pixelmap_HdrMetadataKey OH_Pixelmap_HdrMetadataKey Enumerates the keys of the HDR metadata information used by the PixelMap. It is used in OH_PixelmapNative_SetMetadata and OH_PixelmapNative_GetMetadata.
OH_Pixelmap_HdrMetadataType OH_Pixelmap_HdrMetadataType Enumerates the HDR metadata types, which are the values of HDR_METADATA_TYPE.

[h2]Functions

Name Description
Image_ErrorCode OH_PixelmapInitializationOptions_Create(OH_Pixelmap_InitializationOptions **options) Creates the pointer to an OH_Pixelmap_InitializationOptions struct.
Image_ErrorCode OH_PixelmapInitializationOptions_GetWidth(OH_Pixelmap_InitializationOptions *options, uint32_t *width) Obtains the image width.
Image_ErrorCode OH_PixelmapInitializationOptions_SetWidth(OH_Pixelmap_InitializationOptions *options, uint32_t width) Sets the image width.
Image_ErrorCode OH_PixelmapInitializationOptions_GetHeight(OH_Pixelmap_InitializationOptions *options, uint32_t *height) Obtains the image height.
Image_ErrorCode OH_PixelmapInitializationOptions_SetHeight(OH_Pixelmap_InitializationOptions *options, uint32_t height) Sets the image height.
Image_ErrorCode OH_PixelmapInitializationOptions_GetPixelFormat(OH_Pixelmap_InitializationOptions *options, int32_t *pixelFormat) Obtains the pixel format.
Image_ErrorCode OH_PixelmapInitializationOptions_SetPixelFormat(OH_Pixelmap_InitializationOptions *options, int32_t pixelFormat) Sets the pixel format.
Image_ErrorCode OH_PixelmapInitializationOptions_GetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options, int32_t *srcpixelFormat) Obtains the source pixel format (the pixel format of the input data used when creating an PixelMap).
Image_ErrorCode OH_PixelmapInitializationOptions_SetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options, int32_t srcpixelFormat) Sets the source pixel format (the pixel format of the input data used when creating an PixelMap).
Image_ErrorCode OH_PixelmapInitializationOptions_GetRowStride(OH_Pixelmap_InitializationOptions *options, int32_t *rowStride)

Obtains the row stride.

The stride is the actual memory size occupied by each row of pixels in the image. The unit is bytes. The stride is calculated as: stride = image width × bytes per pixel + padding, where the padding is the blank area added at the end of each row for memory alignment.

Image_ErrorCode OH_PixelmapInitializationOptions_SetRowStride(OH_Pixelmap_InitializationOptions *options, int32_t rowStride)

Sets the row stride.

The stride is the actual memory size occupied by each row of pixels in the image. The unit is bytes. The stride is calculated as: stride = image width × bytes per pixel + padding, where the padding is the blank area added at the end of each row for memory alignment.

Image_ErrorCode OH_PixelmapInitializationOptions_GetAlphaType(OH_Pixelmap_InitializationOptions *options, int32_t *alphaType) Obtains the alpha type.
Image_ErrorCode OH_PixelmapInitializationOptions_SetAlphaType(OH_Pixelmap_InitializationOptions *options, int32_t alphaType) Sets the alpha type.
Image_ErrorCode OH_PixelmapInitializationOptions_GetEditable(OH_Pixelmap_InitializationOptions *options, bool *editable) Obtains the editable flag.
Image_ErrorCode OH_PixelmapInitializationOptions_SetEditable(OH_Pixelmap_InitializationOptions *options, bool editable) Sets the editable flag.
Image_ErrorCode OH_PixelmapInitializationOptions_Release(OH_Pixelmap_InitializationOptions *options) Releases the pointer to an OH_Pixelmap_InitializationOptions struct.
Image_ErrorCode OH_PixelmapImageInfo_Create(OH_Pixelmap_ImageInfo **info) Creates the pointer to an OH_Pixelmap_ImageInfo struct.
Image_ErrorCode OH_PixelmapImageInfo_GetWidth(OH_Pixelmap_ImageInfo *info, uint32_t *width) Obtains the image width.
Image_ErrorCode OH_PixelmapImageInfo_GetHeight(OH_Pixelmap_ImageInfo *info, uint32_t *height) Obtains the image height.
Image_ErrorCode OH_PixelmapImageInfo_GetAlphaMode(OH_Pixelmap_ImageInfo *info, int32_t *alphaMode) Obtains the alpha type of an image.
Image_ErrorCode OH_PixelmapImageInfo_GetRowStride(OH_Pixelmap_ImageInfo *info, uint32_t *rowStride) Obtains the row stride.
Image_ErrorCode OH_PixelmapImageInfo_GetPixelFormat(OH_Pixelmap_ImageInfo *info, int32_t *pixelFormat) Obtains the pixel format.
Image_ErrorCode OH_PixelmapImageInfo_GetAlphaType(OH_Pixelmap_ImageInfo *info, int32_t *alphaType) Obtains the default alpha type of OH_PixelmapImageInfo. To obtain the current alpha type of the image, call OH_PixelmapImageInfo_GetAlphaMode.
Image_ErrorCode OH_PixelmapImageInfo_GetDynamicRange(OH_Pixelmap_ImageInfo *info, bool *isHdr) Obtains the dynamic range of a PixelMap.
Image_ErrorCode OH_PixelmapImageInfo_Release(OH_Pixelmap_ImageInfo *info) Releases the pointer to an OH_Pixelmap_ImageInfo struct.
Image_ErrorCode OH_PixelmapNative_CreatePixelmap(uint8_t *data, size_t dataLength, OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap)

Creates a PixelMap based on the pixel data and image properties.

This API cannot create PixelMaps in the PIXEL_FORMAT_RGBA_1010102, PIXEL_FORMAT_YCBCR_P010, or PIXEL_FORMAT_YCRCB_P010 format.

Image_ErrorCode OH_PixelmapNative_CreatePixelmapUsingAllocator(uint8_t *data, size_t dataLength, OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap)

Creates a PixelMap based on the pixel data and image properties. You can specify the memory type via the allocator.

By default, the system selects an appropriate memory type based on the image type, image size, and platform capability.

When processing the PixelMap returned by this API, consider the impact of the row stride. The row stride is the actual memory size occupied by each row of the image. It may be larger than the image width multiplied by the bytes per pixel due to memory alignment. For details, see OH_PixelmapInitializationOptions_GetRowStride.

Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeToNapi(napi_env env, OH_PixelmapNative *pixelmapNative, napi_value *pixelmapNapi) Converts an OH_PixelmapNative object to a PixelmapNapi object.
Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeFromNapi(napi_env env, napi_value pixelmapNapi, OH_PixelmapNative **pixelmapNative) Converts a PixelmapNapi object to an OH_PixelmapNative object.
Image_ErrorCode OH_PixelmapNative_ReadPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize) Reads the pixel data of a PixelMap and writes it to the buffer based on the pixel format of the PixelMap.
Image_ErrorCode OH_PixelmapNative_WritePixels(OH_PixelmapNative *pixelmap, uint8_t *source, size_t bufferSize) Writes the pixel data in the buffer to a PixelMap based on the pixel format of the PixelMap.
Image_ErrorCode OH_PixelmapNative_ReadPixelsFromArea(OH_PixelmapNative *pixelmap, Image_PositionArea *area) Reads pixel data from the specified area in a PixelMap and stores the data to the buffer. If the pixel format of the PixelMap is YUV, the data is written to the buffer in the original YUV format; otherwise, it is written in the BGRA_8888 format.
Image_ErrorCode OH_PixelmapNative_WritePixelsToArea(OH_PixelmapNative *pixelmap, Image_PositionArea *area) Writes pixel data in the buffer to the specified area in a PixelMap. If the pixel format of the PixelMap is YUV, the data source format must be the same as that of the PixelMap; otherwise, the data source must be in the BGRA_8888 format.
Image_ErrorCode OH_PixelmapNative_GetArgbPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize) Reads data in ARGB format from a PixelMap.
Image_ErrorCode OH_PixelmapNative_ToSdr(OH_PixelmapNative *pixelmap) Converts a PixelMap from the HDR format to the SDR format.
Image_ErrorCode OH_PixelmapNative_GetImageInfo(OH_PixelmapNative *pixelmap, OH_Pixelmap_ImageInfo *imageInfo) Obtains the image information of a PixelMap.
Image_ErrorCode OH_PixelmapNative_SetOpacity(OH_PixelmapNative *pixelmap, float value) Sets the opacity of a PixelMap. The specified opacity value is applied to all pixels.
Image_ErrorCode OH_PixelmapNative_Opacity(OH_PixelmapNative *pixelmap, float rate)

Sets the opacity of a PixelMap. The specified opacity value is applied to all pixels.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_SetOpacity instead, which provides more comprehensive error information.

Image_ErrorCode OH_PixelmapNative_ApplyScale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY) Scales a PixelMap horizontally or vertically by the specified width and height scaling factors.
Image_ErrorCode OH_PixelmapNative_Scale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY)

Scales a PixelMap based on the input scale ratio.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyScale instead, which provides more comprehensive error information.

Image_ErrorCode OH_PixelmapNative_ApplyScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level) Scales a PixelMap horizontally or vertically by the specified scaling factors for width and height, using the specified anti-aliasing level.
Image_ErrorCode OH_PixelmapNative_ScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level)

Scales an image based on the specified anti-aliasing level and scale ratio.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyScaleWithAntiAliasing instead, which provides more comprehensive error information.

Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMap(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap, float scaleX, float scaleY) Creates an image that has been resized based on the scale factors of the width and height. The generated PixelMap is not editable. This API does not copy the HDR metadata or EXIF information from the original image.
Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMapWithAntiAliasing(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level) Creates an image that has been resized based on the specified anti-aliasing level and the scale factors of the width and height. The generated PixelMap is not editable. This API does not copy the HDR metadata or EXIF information from the original image.
Image_ErrorCode OH_PixelmapNative_CreateAlphaPixelmap(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap)

Creates a new non-editable ALPHA_8 PixelMap that contains only the Alpha channel from the source PixelMap.

If the format of the source PixelMap is ALPHA_F16, the newly created PixelMap will retain the ALPHA_F16 format.

Image_ErrorCode OH_PixelmapNative_Clone(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap) Copies the source PixelMap to create a new PixelMap. This API does not copy the EXIF information from the original image.
Image_ErrorCode OH_PixelmapNative_CreateCroppedAndScaledPixelMap(OH_PixelmapNative *srcPixelmap, Image_Region *region, Image_Scale *scale, OH_PixelmapNative_AntiAliasingLevel level, OH_PixelmapNative **dstPixelmap) Creates a PixelMap that is cropped and scaled based on the source PixelMap. This API does not copy the EXIF information from the original image.
Image_ErrorCode OH_PixelmapNative_ApplyTranslate(OH_PixelmapNative *pixelmap, float x, float y)

Translates the PixelMap horizontally or vertically by the specified horizontal and vertical distances.

After translation, the image size becomes: width = original width + x, height = original height + y.

Image_ErrorCode OH_PixelmapNative_Translate(OH_PixelmapNative *pixelmap, float x, float y)

Translates an image by the specified translation distances.

After translation, the image size becomes: width = original width + x, height = original height + y.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyTranslate instead, which provides more comprehensive error information.

Image_ErrorCode OH_PixelmapNative_ApplyRotate(OH_PixelmapNative *pixelmap, float angle) Rotates a PixelMap by the specified angle. YUV formats support only rotation angles that are multiples of 90°.
Image_ErrorCode OH_PixelmapNative_Rotate(OH_PixelmapNative *pixelmap, float angle)

Rotates an image by the specified angle. YUV formats support only rotation angles that are multiples of 90°.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyRotate instead, which provides more comprehensive error information.

Image_ErrorCode OH_PixelmapNative_ApplyFlip(OH_PixelmapNative *pixelmap, bool shouldFlipHorizontally, bool shouldFlipVertically) Flips an image based on the specified horizontal or vertical flip conditions.
Image_ErrorCode OH_PixelmapNative_Flip(OH_PixelmapNative *pixelmap, bool shouldFlipHorizontally, bool shouldFlipVertically)

Flips a PixelMap based on a given angle.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyFlip instead, which provides more comprehensive error information.

Image_ErrorCode OH_PixelmapNative_ApplyCrop(OH_PixelmapNative *pixelmap, Image_Region *region) Crops a PixelMap based on the specified region information.
Image_ErrorCode OH_PixelmapNative_Crop(OH_PixelmapNative *pixelmap, Image_Region *region)

Crops a PixelMap based on the input region information.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyCrop instead, which provides more comprehensive error information.

Image_ErrorCode OH_PixelmapNative_Release(OH_PixelmapNative *pixelmap)

Releases the pointer to an OH_PixelmapNative object. (The pointer cannot be released when the memory is locked by OH_PixelmapNative_AccessPixels.)

You are advised to use OH_PixelmapNative_Destroy.

Image_ErrorCode OH_PixelmapNative_Destroy(OH_PixelmapNative **pixelmap) Releases the pointer to an OH_PixelmapNative object, regardless of whether the memory is locked by OH_PixelmapNative_AccessPixels.
Image_ErrorCode OH_PixelmapNative_ConvertAlphaType(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative *dstPixelmap, const bool toPremul)

Converts the alpha type of the PixelMap pixel data between premultiplied mode (PIXELMAP_ALPHA_TYPE_PREMULTIPLIED) and non-premultiplied mode (PIXELMAP_ALPHA_TYPE_UNPREMULTIPLIED). This conversion is supported only for pixel formats that contain an alpha channel, except RGBA_F16 and ASTC_4x4.

For details about the pixel formats, see PIXEL_FORMAT.

Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixelmap, OH_PixelmapNative* dstpixelmap, const bool isPremul)

Converts the alpha type of the PixelMap pixel data between premultiplied mode and non-premultiplied mode. This conversion is supported only for pixel formats that contain an alpha channel, except RGBA_F16 and ASTC_4x4.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ConvertAlphaType instead, which provides more comprehensive error information.

Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap(OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap) Creates an empty PixelMap object based on OH_Pixelmap_InitializationOptions. The memory data is 0.
Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmapUsingAllocator(OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap) Creates an empty PixelMap object based on options. The memory type used by the PixelMap can be specified by allocator. By default, the system selects an appropriate memory type based on the image type, image size, and platform capability. When processing the PixelMap returned by this API, consider the impact of the row stride. The row stride is the actual memory size occupied by each row of the image. It may be larger than the image width multiplied by the bytes per pixel due to memory alignment. For details, see OH_PixelmapInitializationOptions_GetRowStride.
Image_ErrorCode OH_PixelmapNative_CreatePixelmapFromSurface(const char *surfaceId, size_t length, OH_PixelmapNative **pixelmap) Creates a PixelMap based on the surface ID. If the surface carries rotation or flipping information and processing is required, use OH_PixelmapNative_CreatePixelmapFromSurfaceWithTransformation.
Image_ErrorCode OH_PixelmapNative_CreatePixelmapFromSurfaceWithTransformation(const char *surfaceId, size_t length, bool transformEnabled, OH_PixelmapNative **pixelmap) Creates a PixelMap object for a preview stream image based on a surface ID. The surface may carry rotation or flipping information.
Image_ErrorCode OH_PixelmapNative_CreatePixelmapFromNativeBuffer(OH_NativeBuffer *nativeBuffer, OH_PixelmapNative **pixelmap)

Creates a PixelMap based on a NativeBuffer. If the NativeBuffer usage does not have CPU access permission configured (for details, see OH_NativeBuffer_Usage), creation is not supported.

The supported pixel formats are RGBA_8888, NV21, NV12, YCBCR_P010, and YCRCB_P010.

Image_ErrorCode OH_PixelmapNative_GetNativeBuffer(OH_PixelmapNative *pixelmap, OH_NativeBuffer **nativeBuffer) Obtains the NativeBuffer object from a PixelMap in the DMA memory.
Image_ErrorCode OH_PixelmapNative_GetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, OH_Pixelmap_HdrMetadataValue **value) Obtains HDR metadata of a PixelMap.
Image_ErrorCode OH_PixelmapNative_SetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, OH_Pixelmap_HdrMetadataValue *value) Sets the HDR metadata for a PixelMap.
Image_ErrorCode OH_PixelmapNative_SetColorSpaceNative(OH_PixelmapNative *pixelmap, OH_NativeColorSpaceManager *colorSpaceNative) Sets the NativeColorSpaceManager object for a PixelMap to manage the color space information of the PixelMap.
Image_ErrorCode OH_PixelmapNative_GetColorSpaceNative(OH_PixelmapNative *pixelmap, OH_NativeColorSpaceManager **colorSpaceNative) Obtains the NativeColorSpaceManager object of a PixelMap to query the color space information currently configured for the PixelMap.
Image_ErrorCode OH_PixelmapNative_SetMemoryName(OH_PixelmapNative *pixelmap, char *name, size_t *size) Sets the memory name of a PixelMap to facilitate memory identification during debugging or issue troubleshooting.
Image_ErrorCode OH_PixelmapNative_GetByteCount(OH_PixelmapNative *pixelmap, uint32_t *byteCount) Obtains the total number of bytes occupied by all pixels in a PixelMap, excluding memory-alignment padding bytes.
Image_ErrorCode OH_PixelmapNative_GetAllocationByteCount(OH_PixelmapNative *pixelmap, uint32_t *allocationByteCount) Obtains the actual number of memory bytes allocated for storing pixel data, including memory-alignment padding bytes. Unlike OH_PixelmapNative_GetByteCount (which does not include padding), this API returns the actual memory size allocated by the system for the PixelMap.
Image_ErrorCode OH_PixelmapNative_AccessPixels(OH_PixelmapNative *pixelmap, void **addr)

Obtains the memory address where the pixels of a PixelMap are stored and locks the memory.

When the memory is locked, any attempts to alter or free the pixel data of the PixelMap will fail or be ineffective.

After use, you must call OH_PixelmapNative_UnaccessPixels to release the memory lock. The two APIs must be used in pairs.

Image_ErrorCode OH_PixelmapNative_UnaccessPixels(OH_PixelmapNative *pixelmap)

Unlocks the memory allocated to store the pixels of a PixelMap.

This function must be used together with OH_PixelmapNative_AccessPixels.

Image_ErrorCode OH_PixelmapNative_GetUniqueId(OH_PixelmapNative *pixelmap, uint32_t *uniqueId) Obtains the unique ID of a PixelMap.
Image_ErrorCode OH_PixelmapNative_IsReleased(OH_PixelmapNative *pixelmap, bool *released) Checks whether a PixelMap is released. If released, any attempt to access the internal data of this object will fail.

Enum Description

[h2]PIXELMAP_ALPHA_TYPE

enum PIXELMAP_ALPHA_TYPE

Description

Enumerates the alpha types of a PixelMap.

Since: 12

Enum Item Description
PIXELMAP_ALPHA_TYPE_UNKNOWN = 0 Unknown format.
PIXELMAP_ALPHA_TYPE_OPAQUE = 1 Opaque format.
PIXELMAP_ALPHA_TYPE_PREMULTIPLIED = 2 Premultiplied format.
PIXELMAP_ALPHA_TYPE_UNPREMULTIPLIED = 3 Non-premultiplied format.

[h2]PIXEL_FORMAT

enum PIXEL_FORMAT

Description

Enumerates the image pixel formats.

Since: 12

Enum Item Description
PIXEL_FORMAT_UNKNOWN = 0 Unknown format.
PIXEL_FORMAT_RGB_565 = 2 RGB_565 format.
PIXEL_FORMAT_RGBA_8888 = 3 RGBA_8888 format.
PIXEL_FORMAT_BGRA_8888 = 4 BGRA_8888 format.
PIXEL_FORMAT_RGB_888 = 5 RGB_888 format.
PIXEL_FORMAT_ALPHA_8 = 6 ALPHA_8 format.
PIXEL_FORMAT_RGBA_F16 = 7 RGBA_F16 format.
PIXEL_FORMAT_NV21 = 8 NV21 format.
PIXEL_FORMAT_NV12 = 9 NV12 format.
PIXEL_FORMAT_RGBA_1010102 = 10 RGBA_1010102 format.
PIXEL_FORMAT_YCBCR_P010 = 11 YCBCR_P010 format.
PIXEL_FORMAT_YCRCB_P010 = 12 YCRCB_P010 format.
PIXEL_FORMAT_ALPHA_U8 = 15

ALPHA_U8 format.

Since: 26.0.0

PIXEL_FORMAT_ALPHA_F16 = 16

ALPHA_F16 format.

Since: 26.0.0

[h2]OH_PixelmapNative_AntiAliasingLevel

enum OH_PixelmapNative_AntiAliasingLevel

Description

Enumerates the anti-aliasing levels used for scaling PixelMaps.

Since: 12

Enum Item Description
OH_PixelmapNative_AntiAliasing_NONE = 0 Nearest neighbor interpolation.
OH_PixelmapNative_AntiAliasing_LOW = 1 Bilinear interpolation.
OH_PixelmapNative_AntiAliasing_MEDIUM = 2 Bilinear interpolation with mipmap enabled. You are advised to use this value when zooming out an image.
OH_PixelmapNative_AntiAliasing_HIGH = 3 Cubic interpolation.

[h2]OH_Pixelmap_HdrMetadataKey

enum OH_Pixelmap_HdrMetadataKey

Description

Enumerates the keys of the HDR metadata information used by the PixelMap. It is used in OH_PixelmapNative_SetMetadata and OH_PixelmapNative_GetMetadata.

Since: 12

Enum Item Description
HDR_METADATA_TYPE = 0 Metadata type used by the PixelMap.
HDR_STATIC_METADATA = 1 Static metadata.
HDR_DYNAMIC_METADATA = 2 Dynamic metadata.
HDR_GAINMAP_METADATA = 3 Metadata used by the gain map.

[h2]OH_Pixelmap_HdrMetadataType

enum OH_Pixelmap_HdrMetadataType

Description

Enumerates the HDR metadata types, which are the values of HDR_METADATA_TYPE.

Since: 12

Enum Item Description
HDR_METADATA_TYPE_NONE = 0 No metadata.
HDR_METADATA_TYPE_BASE = 1 Metadata used for base graphics.
HDR_METADATA_TYPE_GAINMAP = 2 Metadata used for gain maps.
HDR_METADATA_TYPE_ALTERNATE = 3 Metadata used for synthesized HDR graphics.

Function Description

[h2]OH_PixelmapInitializationOptions_Create()

Image_ErrorCode OH_PixelmapInitializationOptions_Create(OH_Pixelmap_InitializationOptions **options)

Description

Creates the pointer to an OH_Pixelmap_InitializationOptions struct.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions **options Double pointer to the OH_Pixelmap_InitializationOptions struct created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_GetWidth()

Image_ErrorCode OH_PixelmapInitializationOptions_GetWidth(OH_Pixelmap_InitializationOptions *options, uint32_t *width)

Description

Obtains the image width.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
uint32_t *width Pointer to the image width, in px.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_SetWidth()

Image_ErrorCode OH_PixelmapInitializationOptions_SetWidth(OH_Pixelmap_InitializationOptions *options, uint32_t width)

Description

Sets the image width.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
uint32_t width Pointer to the image width, in px.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_GetHeight()

Image_ErrorCode OH_PixelmapInitializationOptions_GetHeight(OH_Pixelmap_InitializationOptions *options, uint32_t *height)

Description

Obtains the image height.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
uint32_t *height Pointer to the image height, in px.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_SetHeight()

Image_ErrorCode OH_PixelmapInitializationOptions_SetHeight(OH_Pixelmap_InitializationOptions *options, uint32_t height)

Description

Sets the image height.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
uint32_t height Pointer to the image height, in px.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_GetPixelFormat()

Image_ErrorCode OH_PixelmapInitializationOptions_GetPixelFormat(OH_Pixelmap_InitializationOptions *options, int32_t *pixelFormat)

Description

Obtains the pixel format.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
int32_t *pixelFormat Pointer to the pixel format. For details about the available options, see PIXEL_FORMAT.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_SetPixelFormat()

Image_ErrorCode OH_PixelmapInitializationOptions_SetPixelFormat(OH_Pixelmap_InitializationOptions *options, int32_t pixelFormat)

Description

Sets the pixel format.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
int32_t pixelFormat Pixel format. For details about the available options, see PIXEL_FORMAT.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_GetSrcPixelFormat()

Image_ErrorCode OH_PixelmapInitializationOptions_GetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options, int32_t *srcpixelFormat)

Description

Obtains the source pixel format (the pixel format of the input data used when creating an PixelMap).

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
int32_t *srcpixelFormat Pointer to the pixel format.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_SetSrcPixelFormat()

Image_ErrorCode OH_PixelmapInitializationOptions_SetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options, int32_t srcpixelFormat)

Description

Sets the source pixel format (the pixel format of the input data used when creating an PixelMap).

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
int32_t srcpixelFormat Source pixel format. For details about the available options, see PIXEL_FORMAT.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_GetRowStride()

Image_ErrorCode OH_PixelmapInitializationOptions_GetRowStride(OH_Pixelmap_InitializationOptions *options, int32_t *rowStride)

Description

Obtains the row stride.

The stride is the actual memory size occupied by each row of pixels in the image. The unit is bytes. The stride is calculated as: stride = image width × bytes per pixel + padding, where the padding is the blank area added at the end of each row for memory alignment.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
int32_t *rowStride Pointer to the stride, in bytes.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_UNKNOWN_ERROR: The struct that options points to is released.

[h2]OH_PixelmapInitializationOptions_SetRowStride()

Image_ErrorCode OH_PixelmapInitializationOptions_SetRowStride(OH_Pixelmap_InitializationOptions *options, int32_t rowStride)

Description

Sets the row stride.

The stride is the actual memory size occupied by each row of pixels in the image. The unit is bytes. The stride is calculated as: stride = image width × bytes per pixel + padding, where the padding is the blank area added at the end of each row for memory alignment.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
int32_t rowStride Pointer to the stride. The unit is bytes.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_UNKNOWN_ERROR: The struct that options points to is released.

[h2]OH_PixelmapInitializationOptions_GetAlphaType()

Image_ErrorCode OH_PixelmapInitializationOptions_GetAlphaType(OH_Pixelmap_InitializationOptions *options, int32_t *alphaType)

Description

Obtains the alpha type.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
int32_t *alphaType Pointer to the alpha type. For details about the alpha types, see PIXELMAP_ALPHA_TYPE.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_SetAlphaType()

Image_ErrorCode OH_PixelmapInitializationOptions_SetAlphaType(OH_Pixelmap_InitializationOptions *options, int32_t alphaType)

Description

Sets the alpha type.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
int32_t alphaType Pointer to the alpha type. For details about the alpha types, see PIXELMAP_ALPHA_TYPE.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_GetEditable()

Image_ErrorCode OH_PixelmapInitializationOptions_GetEditable(OH_Pixelmap_InitializationOptions *options, bool *editable)

Description

Obtains the editable flag.

Since: 18

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
bool *editable Pointer to the editable flag. true if editable, false otherwise.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_SetEditable()

Image_ErrorCode OH_PixelmapInitializationOptions_SetEditable(OH_Pixelmap_InitializationOptions *options, bool editable)

Description

Sets the editable flag.

Since: 18

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.
bool editable Editable flag. true if editable, false otherwise.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapInitializationOptions_Release()

Image_ErrorCode OH_PixelmapInitializationOptions_Release(OH_Pixelmap_InitializationOptions *options)

Description

Releases the pointer to an OH_Pixelmap_InitializationOptions struct.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Pointer to an OH_Pixelmap_InitializationOptions struct.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapImageInfo_Create()

Image_ErrorCode OH_PixelmapImageInfo_Create(OH_Pixelmap_ImageInfo **info)

Description

Creates the pointer to an OH_Pixelmap_ImageInfo struct.

Since: 12

Parameters

Name Description
OH_Pixelmap_ImageInfo **info Double pointer to the OH_Pixelmap_ImageInfo struct created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapImageInfo_GetWidth()

Image_ErrorCode OH_PixelmapImageInfo_GetWidth(OH_Pixelmap_ImageInfo *info, uint32_t *width)

Description

Obtains the image width.

Since: 12

Parameters

Name Description
OH_Pixelmap_ImageInfo *info Pointer to an OH_Pixelmap_ImageInfo struct.
uint32_t *width Pointer to the image width. The unit is px.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapImageInfo_GetHeight()

Image_ErrorCode OH_PixelmapImageInfo_GetHeight(OH_Pixelmap_ImageInfo *info, uint32_t *height)

Description

Obtains the image height.

Since: 12

Parameters

Name Description
OH_Pixelmap_ImageInfo *info Pointer to an OH_Pixelmap_ImageInfo struct.
uint32_t *height Pointer to the image height. The unit is px.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapImageInfo_GetAlphaMode()

Image_ErrorCode OH_PixelmapImageInfo_GetAlphaMode(OH_Pixelmap_ImageInfo *info, int32_t *alphaMode)

Description

Obtains the alpha type of an image.

Since: 20

Parameters

Name Description
OH_Pixelmap_ImageInfo *info Pointer to an OH_Pixelmap_ImageInfo struct.
int32_t *alphaMode Obtained alpha type.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapImageInfo_GetRowStride()

Image_ErrorCode OH_PixelmapImageInfo_GetRowStride(OH_Pixelmap_ImageInfo *info, uint32_t *rowStride)

Description

Obtains the row stride.

Since: 12

Parameters

Name Description
OH_Pixelmap_ImageInfo *info Pointer to an OH_Pixelmap_ImageInfo struct.
uint32_t *rowStride Pointer to the row stride, which is the number of bytes from one row of pixels in memory to the next row of pixels in memory. The unit is bytes.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapImageInfo_GetPixelFormat()

Image_ErrorCode OH_PixelmapImageInfo_GetPixelFormat(OH_Pixelmap_ImageInfo *info, int32_t *pixelFormat)

Description

Obtains the pixel format.

Since: 12

Parameters

Name Description
OH_Pixelmap_ImageInfo *info Pointer to an OH_Pixelmap_ImageInfo struct.
int32_t *pixelFormat Pointer to the pixel format. For details about the available options, see PIXEL_FORMAT.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapImageInfo_GetAlphaType()

Image_ErrorCode OH_PixelmapImageInfo_GetAlphaType(OH_Pixelmap_ImageInfo *info, int32_t *alphaType)

Description

Obtains the default alpha type of OH_PixelmapImageInfo. To obtain the current alpha type of the image, call OH_PixelmapImageInfo_GetAlphaMode.

Since: 12

Parameters

Name Description
OH_Pixelmap_ImageInfo *info Pointer to an OH_Pixelmap_ImageInfo struct.
int32_t *alphaType Pointer to the alpha type. For details about the alpha types, see PIXELMAP_ALPHA_TYPE.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapImageInfo_GetDynamicRange()

Image_ErrorCode OH_PixelmapImageInfo_GetDynamicRange(OH_Pixelmap_ImageInfo *info, bool *isHdr)

Description

Obtains the dynamic range of a PixelMap.

Since: 12

Parameters

Name Description
OH_Pixelmap_ImageInfo *info Pointer to an OH_Pixelmap_ImageInfo struct.
bool *isHdr Whether the image is an HDR image. The value true means that the image is an HDR image, and the value false means the opposite.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapImageInfo_Release()

Image_ErrorCode OH_PixelmapImageInfo_Release(OH_Pixelmap_ImageInfo *info)

Description

Releases the pointer to an OH_Pixelmap_ImageInfo struct.

Since: 12

Parameters

Name Description
OH_Pixelmap_ImageInfo *info Pointer to an OH_Pixelmap_ImageInfo struct.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_CreatePixelmap()

Image_ErrorCode OH_PixelmapNative_CreatePixelmap(uint8_t *data, size_t dataLength, OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap)

Description

Creates a PixelMap based on the pixel data and image properties.

This API cannot create PixelMaps in the PIXEL_FORMAT_RGBA_1010102, PIXEL_FORMAT_YCBCR_P010, or PIXEL_FORMAT_YCRCB_P010 format.

Since: 12

Parameters

Name Description
uint8_t *data

Pixel data array.

The input pixel data is parsed in BGRA_8888 format by default. To use another format, see OH_PixelmapInitializationOptions_SetSrcPixelFormat.

If the pixel data contains padding bytes at the end of each row for memory alignment, you must use OH_PixelmapInitializationOptions_SetRowStride to set the row stride.

size_t dataLength Length of the pixel data array. The unit is bytes.
OH_Pixelmap_InitializationOptions *options Initialization properties for image creation.
OH_PixelmapNative **pixelmap Double pointer to the OH_PixelmapNative object created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_UNSUPPORTED_OPERATION: The operation is not supported.

[h2]OH_PixelmapNative_CreatePixelmapUsingAllocator()

Image_ErrorCode OH_PixelmapNative_CreatePixelmapUsingAllocator(uint8_t *data, size_t dataLength, OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap)

Description

Creates a PixelMap based on the pixel data and image properties. You can specify the memory type via the allocator.

By default, the system selects an appropriate memory type based on the image type, image size, and platform capability.

When processing the PixelMap returned by this API, consider the impact of the row stride. The row stride is the actual memory size occupied by each row of the image. It may be larger than the image width multiplied by the bytes per pixel due to memory alignment. For details, see OH_PixelmapInitializationOptions_GetRowStride.

Since: 20

Parameters

Name Description
uint8_t *data

Pixel data array.

The input pixel data is parsed in BGRA_8888 format by default. To use another format, see OH_PixelmapInitializationOptions_SetSrcPixelFormat.

If the pixel data contains padding bytes at the end of each row for memory alignment, you must use OH_PixelmapInitializationOptions_SetRowStride to set the row stride.

size_t dataLength Length of the pixel data array. The unit is bytes.
OH_Pixelmap_InitializationOptions *options Initialization properties for image creation.
IMAGE_ALLOCATOR_MODE allocator PixelMap memory allocation type.
OH_PixelmapNative **pixelmap Double pointer to the OH_PixelmapNative object created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_UNSUPPORTED_OPERATION: The operation is not supported.

IMAGE_TOO_LARGE: The image is too large to allocate memory.

IMAGE_DMA_OPERATION_FAILED: The DMA memory operation fails.

IMAGE_ALLOCATOR_MODE_UNSUPPORTED: The current memory allocation type is not supported, for example, creating an HDR image using shared memory.

[h2]OH_PixelmapNative_ConvertPixelmapNativeToNapi()

Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeToNapi(napi_env env, OH_PixelmapNative *pixelmapNative, napi_value *pixelmapNapi)

Description

Converts an OH_PixelmapNative object to a PixelmapNapi object.

Since: 12

Parameters

Name Description
napi_env env Napi environment pointer.
OH_PixelmapNative *pixelmapNative Pointer to an OH_PixelmapNative object.
napi_value *pixelmapNapi Pointer to the converted PixelmapNapi object.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: The pixelmapNative parameter is nullptr.

[h2]OH_PixelmapNative_ConvertPixelmapNativeFromNapi()

Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeFromNapi(napi_env env, napi_value pixelmapNapi, OH_PixelmapNative **pixelmapNative)

Description

Converts a PixelmapNapi object to an OH_PixelmapNative object.

Since: 12

Parameters

Name Description
napi_env env Napi environment pointer.
napi_value pixelmapNapi PixelMapNapi object to convert.
OH_PixelmapNative **pixelmapNative Double pointer to the OH_PixelmapNative object.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: pixelmapNative is nullptr or pixelmapNapi is not an PixelmapNapi object.

[h2]OH_PixelmapNative_ReadPixels()

Image_ErrorCode OH_PixelmapNative_ReadPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize)

Description

Reads the pixel data of a PixelMap and writes it to the buffer based on the pixel format of the PixelMap.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
uint8_t *destination Target buffer to which the obtained pixel data will be copied. The pixel format in the buffer is the same as that of the PixelMap and does not contain memory-alignment padding bytes.
size_t *bufferSize Pointer to the buffer size. The unit is bytes. It can be obtained via the OH_PixelmapNative_GetByteCount API. The buffer size of the RGBA format is equal to width * height * 4, and the buffer size of the NV21 and NV12 formats is equal to width * height + ((width + 1)/2) * ((height+1)/2) * 2.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_UNKNOWN_ERROR: An unknown error occurs.

[h2]OH_PixelmapNative_WritePixels()

Image_ErrorCode OH_PixelmapNative_WritePixels(OH_PixelmapNative *pixelmap, uint8_t *source, size_t bufferSize)

Description

Writes the pixel data in the buffer to a PixelMap based on the pixel format of the PixelMap.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
uint8_t *source Source data buffer. The image pixel data in this buffer is written to the PixelMap. The pixel data in the buffer must cover the entire PixelMap and must be in the same pixel format as the PixelMap, without memory-alignment padding bytes.
size_t bufferSize Pointer to the buffer size. The unit is bytes. It can be obtained via the OH_PixelmapNative_GetByteCount API. The buffer size of the RGBA format is equal to width * height * 4, and the buffer size of the NV21 and NV12 formats is equal to width * height + ((width + 1)/2) * ((height+1)/2) * 2.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_UNSUPPORTED_OPERATION: The operation is not supported.

IMAGE_UNKNOWN_ERROR: An unknown error occurs.

[h2]OH_PixelmapNative_ReadPixelsFromArea()

Image_ErrorCode OH_PixelmapNative_ReadPixelsFromArea(OH_PixelmapNative *pixelmap, Image_PositionArea *area)

Description

Reads pixel data from the specified area in a PixelMap and stores the data to the buffer. If the pixel format of the PixelMap is YUV, the data is written to the buffer in the original YUV format; otherwise, it is written in the BGRA_8888 format.

Since: 22

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to the PixelMap from which pixels are read.
Image_PositionArea *area Pointer to the specified PixelMap area from which pixels are read. The pixel data in this area is read and copied to area->pixels. If the pixel format of the PixelMap is YUV, the retrieved pixel data remains in the same format as the PixelMap; otherwise, it is converted to the BGRA_8888 format.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: Invalid parameters. For example, pixelmap or area is incorrect.

IMAGE_UNKNOWN_ERROR: Unknown internal error. For example, the pixel format is not supported.

[h2]OH_PixelmapNative_WritePixelsToArea()

Image_ErrorCode OH_PixelmapNative_WritePixelsToArea(OH_PixelmapNative *pixelmap, Image_PositionArea *area)

Description

Writes pixel data in the buffer to the specified area in a PixelMap. If the pixel format of the PixelMap is YUV, the data source format must be the same as that of the PixelMap; otherwise, the data source must be in the BGRA_8888 format.

Since: 22

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to the PixelMap to which pixels are written.
Image_PositionArea *area Pointer to the specified area in the PixelMap to which data is written. The pixel data in area->pixels is written to this area. If the pixel format of the PixelMap is YUV, the pixel data in area->pixels must be in the same format as the PixelMap; otherwise, it must be in the BGRA_8888 format.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: Invalid parameters. For example, pixelmap or area is incorrect.

IMAGE_UNSUPPORTED_OPERATION: The PixelMap is not editable.

IMAGE_UNKNOWN_ERROR: Unknown internal error. For example, the pixel format is not supported.

[h2]OH_PixelmapNative_GetArgbPixels()

Image_ErrorCode OH_PixelmapNative_GetArgbPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize)

Description

Reads data in ARGB format from a PixelMap.

Since: 13

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
uint8_t *destination Pointer to the buffer to which the pixels will be written. The buffer size must not be less than width × height × 4 bytes.
size_t *bufferSize Pointer to the buffer size. The unit is bytes.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_UNSUPPORTED_CONVERSION: The PixelMap format does not support reading ARGB data.

IMAGE_ALLOC_FAILED: Memory allocation fails.

IMAGE_COPY_FAILED: Memory data copy, read, or operation fails.

[h2]OH_PixelmapNative_ToSdr()

Image_ErrorCode OH_PixelmapNative_ToSdr(OH_PixelmapNative *pixelmap)

Description

Converts a PixelMap from the HDR format to the SDR format.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_UNSUPPORTED_OPERATION: The operation is not supported.

[h2]OH_PixelmapNative_GetImageInfo()

Image_ErrorCode OH_PixelmapNative_GetImageInfo(OH_PixelmapNative *pixelmap, OH_Pixelmap_ImageInfo *imageInfo)

Description

Obtains the image information of a PixelMap.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
OH_Pixelmap_ImageInfo *imageInfo Pointer to the image information.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_SetOpacity()

Image_ErrorCode OH_PixelmapNative_SetOpacity(OH_PixelmapNative *pixelmap, float value)

Description

Sets the opacity of a PixelMap. The specified opacity value is applied to all pixels.

Since: 26.0.0

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float value Opacity value. The value range is (0.0, 1.0], where 1.0 indicates that the image is completely opaque. A value closer to 0.0 indicates higher transparency.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_GET_IMAGE_DATA_FAILED: The image data fails to be obtained. Possible cause: The internal data is damaged. Check the log for details.

IMAGE_PIXELMAP_RELEASED: The PixelMap has been released.

IMAGE_UNSUPPORTED_OPERATION: The PixelMap is locked and the operation is not supported.

IMAGE_INVALID_PARAMETER: Invalid parameter. Possible causes: 1. The opacity value is out of range.2. The input parameter is null.

IMAGE_UNSUPPORTED_DATA_FORMAT: Unsupported data format. Possible cause: The alpha type is not supported.

[h2]OH_PixelmapNative_Opacity()

Image_ErrorCode OH_PixelmapNative_Opacity(OH_PixelmapNative *pixelmap, float rate)

Description

Sets the opacity of a PixelMap. The specified opacity value is applied to all pixels.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_SetOpacity instead, which provides more comprehensive error information.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float rate Opacity value. The value range is (0.0, 1.0], where 1.0 indicates that the image is completely opaque. A value closer to 0.0 indicates higher transparency.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_ApplyScale()

Image_ErrorCode OH_PixelmapNative_ApplyScale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY)

Description

Scales a PixelMap horizontally or vertically by the specified width and height scaling factors.

Since: 26.0.0

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float scaleX Scale factor of the width. The value cannot be 0.
float scaleY Scale factor of the height. The value cannot be 0.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_GET_IMAGE_DATA_FAILED: The image data fails to be obtained. Possible cause: The internal data is damaged. Check the log for details.

IMAGE_PIXELMAP_RELEASED: The PixelMap has been released.

IMAGE_UNSUPPORTED_OPERATION: The PixelMap is locked and the operation is not supported.

IMAGE_INVALID_PARAMETER: Invalid parameter. Possible cause: The input parameter is null.

IMAGE_ALLOC_FAILED: Memory allocation fails. Possible causes: 1. The size of the generated PixelMap is too large.2. Insufficient memory.

[h2]OH_PixelmapNative_Scale()

Image_ErrorCode OH_PixelmapNative_Scale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY)

Description

Scales a PixelMap based on the input scale ratio.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyScale instead, which provides more comprehensive error information.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float scaleX Scale ratio of the width. The value cannot be 0.
float scaleY Scale ratio of the height. The value cannot be 0.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_ApplyScaleWithAntiAliasing()

Image_ErrorCode OH_PixelmapNative_ApplyScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level)

Description

Scales a PixelMap horizontally or vertically by the specified scaling factors for width and height, using the specified anti-aliasing level.

Since: 26.0.0

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float scaleX Scale factor of the width. The value cannot be 0.
float scaleY Scale factor of the height. The value cannot be 0.
OH_PixelmapNative_AntiAliasingLevel level Anti-aliasing level. This parameter does not take effect for PixelMaps in ASTC format.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_GET_IMAGE_DATA_FAILED: The image data fails to be obtained. Possible cause: The internal data is damaged. Check the log for details.

IMAGE_PIXELMAP_RELEASED: The PixelMap has been released.

IMAGE_UNSUPPORTED_OPERATION: The PixelMap is locked and the operation is not supported.

IMAGE_INVALID_PARAMETER: Invalid parameter. Possible cause: The input parameter is null.

IMAGE_ALLOC_FAILED: Memory allocation fails. Possible causes: 1. The size of the generated PixelMap is too large.2. Insufficient memory.

[h2]OH_PixelmapNative_ScaleWithAntiAliasing()

Image_ErrorCode OH_PixelmapNative_ScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level)

Description

Scales an image based on the specified anti-aliasing level and scale ratio.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyScaleWithAntiAliasing instead, which provides more comprehensive error information.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float scaleX Scale ratio of the width. The value cannot be 0.
float scaleY Scale ratio of the height. The value cannot be 0.
OH_PixelmapNative_AntiAliasingLevel level Anti-aliasing level. This parameter does not take effect for PixelMaps in ASTC format.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_TOO_LARGE: The image is too large.

IMAGE_ALLOC_FAILED: Memory allocation fails.

IMAGE_UNKNOWN_ERROR: The struct that pixelmap points to is released.

[h2]OH_PixelmapNative_CreateScaledPixelMap()

Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMap(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap, float scaleX, float scaleY)

Description

Creates an image that has been resized based on the scale factors of the width and height. The generated PixelMap is not editable. This API does not copy the HDR metadata or EXIF information from the original image.

Since: 18

Parameters

Name Description
OH_PixelmapNative *srcPixelmap Pointer to the source PixelMap, which is an OH_PixelmapNative object.
OH_PixelmapNative **dstPixelmap Pointer to the target PixelMap, which is an OH_PixelmapNative object.
float scaleX Scale ratio of the width. The value cannot be 0.
float scaleY Scale ratio of the height. The value cannot be 0.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_CreateScaledPixelMapWithAntiAliasing()

Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMapWithAntiAliasing(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level)

Description

Creates an image that has been resized based on the specified anti-aliasing level and the scale factors of the width and height. The generated PixelMap is not editable. This API does not copy the HDR metadata or EXIF information from the original image.

Since: 18

Parameters

Name Description
OH_PixelmapNative *srcPixelmap Pointer to the source PixelMap, which is an OH_PixelmapNative object.
OH_PixelmapNative **dstPixelmap Pointer to the target PixelMap, which is an OH_PixelmapNative object.
float scaleX Scale ratio of the width. The value cannot be 0.
float scaleY Scale ratio of the height. The value cannot be 0.
OH_PixelmapNative_AntiAliasingLevel level Anti-aliasing level. This parameter does not take effect for PixelMaps in ASTC format.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_TOO_LARGE: The image is too large.

IMAGE_ALLOC_FAILED: Memory allocation fails.

[h2]OH_PixelmapNative_CreateAlphaPixelmap()

Image_ErrorCode OH_PixelmapNative_CreateAlphaPixelmap(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap)

Description

Creates a new non-editable ALPHA_8 PixelMap that contains only the Alpha channel from the source PixelMap.

If the format of the source PixelMap is ALPHA_F16, the newly created PixelMap will retain the ALPHA_F16 format.

Since: 22

Parameters

Name Description
OH_PixelmapNative *srcPixelmap Pointer to the source PixelMap that provides the alpha channel data.
OH_PixelmapNative **dstPixelmap Double pointer to the target PixelMap created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: Invalid parameters. For example, srcPixelmap or dstPixelmap is incorrect.

[h2]OH_PixelmapNative_Clone()

Image_ErrorCode OH_PixelmapNative_Clone(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap)

Description

Copies the source PixelMap to create a new PixelMap. This API does not copy the EXIF information from the original image.

Since: 22

Parameters

Name Description
OH_PixelmapNative *srcPixelmap Source PixelMap to be copied.
OH_PixelmapNative **dstPixelmap Created target PixelMap.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: Invalid parameters. For example, srcPixelmap or dstPixelmap is incorrect.

IMAGE_UNSUPPORTED_DATA_FORMAT: The pixel format is not supported.

IMAGE_TOO_LARGE: The source PixelMap is too large.

IMAGE_INIT_FAILED: The target PixelMap fails to be initialized.

IMAGE_ALLOC_FAILED: Memory allocation or data copy fails.

[h2]OH_PixelmapNative_CreateCroppedAndScaledPixelMap()

Image_ErrorCode OH_PixelmapNative_CreateCroppedAndScaledPixelMap(OH_PixelmapNative *srcPixelmap, Image_Region *region, Image_Scale *scale, OH_PixelmapNative_AntiAliasingLevel level, OH_PixelmapNative **dstPixelmap)

Description

Creates a PixelMap that is cropped and scaled based on the source PixelMap. This API does not copy the EXIF information from the original image.

Since: 22

Parameters

Name Description
OH_PixelmapNative *srcPixelmap Pointer to the source PixelMap.
Image_Region *region Pointer to the region to crop.
Image_Scale *scale Pointer to the scale factor of the width and height. It must not be 0.
OH_PixelmapNative_AntiAliasingLevel level Scale interpolation algorithm. This parameter does not take effect for PixelMaps in ASTC format.
OH_PixelmapNative **dstPixelmap Double pointer to the target PixelMap created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: Invalid parameters. For example, srcPixelmap, region, scale, or dstPixelmap is incorrect.

IMAGE_UNSUPPORTED_DATA_FORMAT: The pixel format is not supported.

IMAGE_TOO_LARGE: The source PixelMap is too large.

IMAGE_INIT_FAILED: The target PixelMap fails to be initialized.

IMAGE_ALLOC_FAILED: Memory allocation or data copy fails.

[h2]OH_PixelmapNative_ApplyTranslate()

Image_ErrorCode OH_PixelmapNative_ApplyTranslate(OH_PixelmapNative *pixelmap, float x, float y)

Description

Translates the PixelMap horizontally or vertically by the specified horizontal and vertical distances.

After translation, the image size becomes: width = original width + x, height = original height + y.

Since: 26.0.0

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float x

Horizontal translation distance. Positive values move the image to the right; negative values move it to the left. The value range is (-image width, +∞). The unit is px.

When the value is negative, the translation is equivalent to cropping x columns of pixels from the left side of the image.

float y

Vertical translation distance. Positive values move the image downward; negative values move it upward. The value range is (-image height, +∞). The unit is px.

When the value is negative, the translation is equivalent to cropping y rows of pixels from the top of the image.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_GET_IMAGE_DATA_FAILED: The image data fails to be obtained. Possible cause: The internal data is damaged. Check the log for details.

IMAGE_PIXELMAP_RELEASED: The PixelMap has been released.

IMAGE_UNSUPPORTED_OPERATION: The PixelMap is locked and the operation is not supported.

IMAGE_INVALID_PARAMETER: Invalid parameter. Possible cause: The input parameter is null.

IMAGE_ALLOC_FAILED: Memory allocation fails. Possible causes: 1. The size of the generated PixelMap is too large.2. Insufficient memory.

[h2]OH_PixelmapNative_Translate()

Image_ErrorCode OH_PixelmapNative_Translate(OH_PixelmapNative *pixelmap, float x, float y)

Description

Translates an image by the specified translation distances.

After translation, the image size becomes: width = original width + x, height = original height + y.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyTranslate instead, which provides more comprehensive error information.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float x

Horizontal translation distance. Positive values move the image to the right; negative values move it to the left. The value range is (-image width, +∞). The unit is px.

When the value is negative, the translation is equivalent to cropping x columns of pixels from the left side of the image.

float y

Vertical translation distance. Positive values move the image downward; negative values move it upward. The value range is (-image height, +∞). The unit is px.

When the value is negative, the translation is equivalent to cropping y rows of pixels from the top of the image.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_ApplyRotate()

Image_ErrorCode OH_PixelmapNative_ApplyRotate(OH_PixelmapNative *pixelmap, float angle)

Description

Rotates a PixelMap by the specified angle. YUV formats support only rotation angles that are multiples of 90°.

Since: 26.0.0

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float angle Rotation angle. The unit is degrees (°).

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_GET_IMAGE_DATA_FAILED: The image data fails to be obtained. Possible cause: The internal data is damaged. Check the log for details.

IMAGE_PIXELMAP_RELEASED: The PixelMap has been released.

IMAGE_UNSUPPORTED_OPERATION: The PixelMap is locked and the operation is not supported.

IMAGE_INVALID_PARAMETER: Invalid parameter. Possible cause: The input parameter is null.

IMAGE_ALLOC_FAILED: Memory allocation fails. Possible causes: 1. The size of the generated PixelMap is too large.2. Insufficient memory.

[h2]OH_PixelmapNative_Rotate()

Image_ErrorCode OH_PixelmapNative_Rotate(OH_PixelmapNative *pixelmap, float angle)

Description

Rotates an image by the specified angle. YUV formats support only rotation angles that are multiples of 90°.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyRotate instead, which provides more comprehensive error information.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
float angle Angle to rotate. The unit is degrees (°).

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_ApplyFlip()

Image_ErrorCode OH_PixelmapNative_ApplyFlip(OH_PixelmapNative *pixelmap, bool shouldFlipHorizontally, bool shouldFlipVertically)

Description

Flips an image based on the specified horizontal or vertical flip conditions.

Since: 26.0.0

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
bool shouldFlipHorizontally Whether to flip horizontally. true to flip the image horizontally, false otherwise.
bool shouldFlipVertically Whether to flip vertically. true to flip the image vertically, false otherwise.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_GET_IMAGE_DATA_FAILED: The image data fails to be obtained. Possible cause: The internal data is damaged. Check the log for details.

IMAGE_PIXELMAP_RELEASED: The PixelMap has been released.

IMAGE_UNSUPPORTED_OPERATION: The PixelMap is locked and the operation is not supported.

IMAGE_INVALID_PARAMETER: Invalid parameter. Possible cause: The input parameter is null.

IMAGE_ALLOC_FAILED: Memory allocation fails. Possible cause: The system memory is insufficient.

[h2]OH_PixelmapNative_Flip()

Image_ErrorCode OH_PixelmapNative_Flip(OH_PixelmapNative *pixelmap, bool shouldFlipHorizontally, bool shouldFlipVertically)

Description

Flips a PixelMap based on a given angle.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyFlip instead, which provides more comprehensive error information.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
bool shouldFlipHorizontally Whether to flip the image horizontally. true to flip the image horizontally, false otherwise.
bool shouldFlipVertically Whether to flip the image vertically. true to flip the image vertically, false otherwise.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_ApplyCrop()

Image_ErrorCode OH_PixelmapNative_ApplyCrop(OH_PixelmapNative *pixelmap, Image_Region *region)

Description

Crops a PixelMap based on the specified region information.

Since: 26.0.0

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
Image_Region *region Pointer to the cropping region.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_GET_IMAGE_DATA_FAILED: The image data fails to be obtained. Possible cause: The internal data is damaged. Check the log for details.

IMAGE_PIXELMAP_RELEASED: The PixelMap has been released.

IMAGE_UNSUPPORTED_OPERATION: The PixelMap is locked and the operation is not supported.

IMAGE_INVALID_REGION: The specified region is invalid or out of range.

IMAGE_INVALID_PARAMETER: Invalid parameter. Possible cause: An input parameter is null.

IMAGE_ALLOC_FAILED: Memory allocation fails. Possible causes: 1. Failed to process the pixel data.2. Insufficient memory.

[h2]OH_PixelmapNative_Crop()

Image_ErrorCode OH_PixelmapNative_Crop(OH_PixelmapNative *pixelmap, Image_Region *region)

Description

Crops a PixelMap based on the input region information.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ApplyCrop instead, which provides more comprehensive error information.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
Image_Region *region Cropping region, including the start coordinates, width, and height.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_Release()

Image_ErrorCode OH_PixelmapNative_Release(OH_PixelmapNative *pixelmap)

Description

Releases the pointer to an OH_PixelmapNative object. (The pointer cannot be released when the memory is locked by OH_PixelmapNative_AccessPixels.)

You are advised to use OH_PixelmapNative_Destroy.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_Destroy()

Image_ErrorCode OH_PixelmapNative_Destroy(OH_PixelmapNative **pixelmap)

Description

Releases the pointer to an OH_PixelmapNative object, regardless of whether the memory is locked by OH_PixelmapNative_AccessPixels.

Since: 18

Parameters

Name Description
OH_PixelmapNative **pixelmap Pointer to an OH_PixelmapNative object.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_ConvertAlphaType()

Image_ErrorCode OH_PixelmapNative_ConvertAlphaType(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative *dstPixelmap, const bool toPremul)

Description

Converts the alpha type of the PixelMap pixel data between premultiplied mode (PIXELMAP_ALPHA_TYPE_PREMULTIPLIED) and non-premultiplied mode (PIXELMAP_ALPHA_TYPE_UNPREMULTIPLIED). This conversion is supported only for pixel formats that contain an alpha channel, except RGBA_F16 and ASTC_4x4.

For details about the pixel formats, see PIXEL_FORMAT.

Since: 26.0.0

Parameters

Name Description
OH_PixelmapNative *srcPixelmap Pointer to the source PixelMap, which contains the pixel data to be converted. Its alpha type must be either premultiplied or non-premultiplied.
OH_PixelmapNative *dstPixelmap Pointer to an empty target PixelMap. Its attributes (width, height, pixel format, and more) must be the same as those of the source PixelMap, but its alpha type must be the opposite of the source PixelMap (for example, if the source PixelMap is premultiplied, the destination PixelMap must be non-premultiplied). The target PixelMap must be editable. The converted pixel data will be written to this PixelMap.
const bool toPremul Conversion direction. The value true indicates conversion from non-premultiplied to premultiplied, and the value false indicates conversion from premultiplied to non-premultiplied.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_GET_IMAGE_DATA_FAILED: The image data fails to be obtained. Possible cause: The internal data is damaged. Check the log for details.

IMAGE_PIXELMAP_RELEASED: Either of the PixelMaps has been released.

IMAGE_UNSUPPORTED_OPERATION: The PixelMap is locked and the operation is not supported.

IMAGE_INVALID_PARAMETER: Invalid parameter. Possible causes: 1. A PixelMap does not meet the requirements.2. An input parameter is null.

IMAGE_UNSUPPORTED_DATA_FORMAT: The pixel format of a PixelMap is not supported.

[h2]OH_PixelmapNative_ConvertAlphaFormat()

Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixelmap, OH_PixelmapNative* dstpixelmap, const bool isPremul)

Description

Converts the alpha type of the PixelMap pixel data between premultiplied mode and non-premultiplied mode. This conversion is supported only for pixel formats that contain an alpha channel, except RGBA_F16 and ASTC_4x4.

Since API version 26.0.0, you are advised to use OH_PixelmapNative_ConvertAlphaType instead, which provides more comprehensive error information.

Since: 12

Parameters

Name Description
OH_PixelmapNative* srcpixelmap Pointer to the source PixelMap, which contains the pixel data to be converted. Its alpha type must be either premultiplied or non-premultiplied.
OH_PixelmapNative* dstpixelmap Pointer to an empty target PixelMap. Its attributes (width, height, pixel format, and more) must be the same as those of the source PixelMap, but its alpha type must be the opposite of the source PixelMap (for example, if the source PixelMap is premultiplied, the destination PixelMap must be non-premultiplied). The target PixelMap must be editable. The converted pixel data will be written to this PixelMap.
const bool isPremul Conversion direction. The value true means a conversion from premultiplied alpha to non-premultiplied alpha, and false means a conversion from non-premultiplied alpha to premultiplied alpha.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_CreateEmptyPixelmap()

Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap(OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap)

Description

Creates an empty PixelMap object based on OH_Pixelmap_InitializationOptions. The memory data is 0.

Since: 12

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Initialization properties for image creation.
OH_PixelmapNative **pixelmap Double pointer to the OH_PixelmapNative object created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_CreateEmptyPixelmapUsingAllocator()

Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmapUsingAllocator(OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap)

Description

Creates an empty PixelMap object based on options. The memory type used by the PixelMap can be specified by allocator. By default, the system selects an appropriate memory type based on the image type, image size, and platform capability. When processing the PixelMap returned by this API, consider the impact of the row stride. The row stride is the actual memory size occupied by each row of the image. It may be larger than the image width multiplied by the bytes per pixel due to memory alignment. For details, see OH_PixelmapInitializationOptions_GetRowStride.

Since: 20

Parameters

Name Description
OH_Pixelmap_InitializationOptions *options Initialization properties for image creation.
IMAGE_ALLOCATOR_MODE allocator Type of memory allocation for the PixelMap.
OH_PixelmapNative **pixelmap Double pointer to the OH_PixelmapNative object created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_UNSUPPORTED_OPERATION: The operation is not supported.

IMAGE_TOO_LARGE: The image is too large to allocate memory.

IMAGE_DMA_OPERATION_FAILED: The DMA memory operation fails.

IMAGE_ALLOCATOR_MODE_UNSUPPORTED: The current memory allocation type is not supported, for example, creating an HDR image using shared memory.

[h2]OH_PixelmapNative_CreatePixelmapFromSurface()

Image_ErrorCode OH_PixelmapNative_CreatePixelmapFromSurface(const char *surfaceId, size_t length, OH_PixelmapNative **pixelmap)

Description

Creates a PixelMap based on the surface ID. If the surface carries rotation or flipping information and processing is required, use OH_PixelmapNative_CreatePixelmapFromSurfaceWithTransformation.

Since: 22

Parameters

Name Description
const char *surfaceId Pointer to the string of the surface ID.
size_t length Length of the surface ID string. The unit is bytes.
OH_PixelmapNative **pixelmap Double pointer to the PixelMap created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: Invalid parameters. For example, surfaceId or pixelmap is incorrect.

IMAGE_CREATE_PIXELMAP_FAILED: PixelMap creation fails.

[h2]OH_PixelmapNative_CreatePixelmapFromSurfaceWithTransformation()

Image_ErrorCode OH_PixelmapNative_CreatePixelmapFromSurfaceWithTransformation(const char *surfaceId, size_t length, bool transformEnabled, OH_PixelmapNative **pixelmap)

Description

Creates a PixelMap object for a preview stream image based on a surface ID. The surface may carry rotation or flipping information.

Since: 23

Parameters

Name Description
const char *surfaceId Surface ID.
size_t length Length of the surface ID. The unit is bytes.
bool transformEnabled

Whether to perform inverse transformation on the surface that carries transformation information to eliminate the rotation or flipping effect of the PixelMap. If the surface does not carry transformation information, this parameter does not take effect.

If this parameter is set to true, the inverse transformation is performed. The transform angle matches the angle carried by the surface but in the opposite direction, and the output PixelMap has no rotation or flipping effect.

If this parameter is set to false, no inverse transformation is performed. The output PixelMap has the rotation or flipping effect based on the transformation information in the surface.

OH_PixelmapNative **pixelmap Double pointer to the PixelMap created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_INVALID_PARAMETER: Invalid parameters. For example, surfaceId or pixelmap is incorrect.

IMAGE_UNSUPPORTED_OPERATION: The operation is not supported. For example, the operation is called across platforms.

IMAGE_GET_IMAGE_DATA_FAILED: Failed to obtain the surface data.

IMAGE_CREATE_PIXELMAP_FAILED: PixelMap creation fails.

Reference

OH_PixelmapNative

[h2]OH_PixelmapNative_CreatePixelmapFromNativeBuffer()

Image_ErrorCode OH_PixelmapNative_CreatePixelmapFromNativeBuffer(OH_NativeBuffer *nativeBuffer, OH_PixelmapNative **pixelmap)

Description

Creates a PixelMap based on a NativeBuffer. If the NativeBuffer usage does not have CPU access permission configured (for details, see OH_NativeBuffer_Usage), creation is not supported.

The supported pixel formats are RGBA_8888, NV21, NV12, YCBCR_P010, and YCRCB_P010.

Since: 22

Parameters

Name Description
OH_NativeBuffer *nativeBuffer Pointer to the NativeBuffer object that contains PixelMap data. The NativeBuffer usage must have CPU access permission configured (for details, see OH_NativeBuffer_Usage), and the pixel format must be RGBA_8888, NV21, NV12, YCBCR_P010, or YCRCB_P010.
OH_PixelmapNative **pixelmap Double pointer to the PixelMap created.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: Invalid parameters. For example, nativeBuffer or pixelmap is incorrect, the pixel format is not supported, or the CPU access permission is not configured.

IMAGE_CREATE_PIXELMAP_FAILED: PixelMap creation fails.

[h2]OH_PixelmapNative_GetNativeBuffer()

Image_ErrorCode OH_PixelmapNative_GetNativeBuffer(OH_PixelmapNative *pixelmap, OH_NativeBuffer **nativeBuffer)

Description

Obtains the NativeBuffer object from a PixelMap in the DMA memory.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Source PixelMap from which to obtain the NativeBuffer. The memory type must be DMA.
OH_NativeBuffer **nativeBuffer Double pointer to the NativeBuffer object obtained.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_DMA_NOT_EXIST: DMA memory does not exist.

IMAGE_DMA_OPERATION_FAILED: The DMA memory operation fails.

[h2]OH_PixelmapNative_GetMetadata()

Image_ErrorCode OH_PixelmapNative_GetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, OH_Pixelmap_HdrMetadataValue **value)

Description

Obtains HDR metadata of a PixelMap. The type of metadata to be obtained is specified by passing an OH_Pixelmap_HdrMetadataKey key, and the corresponding metadata value is returned via OH_Pixelmap_HdrMetadataValue.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to the OH_PixelmapNative to be operated. The memory type of the PixelMap must be DMA.
OH_Pixelmap_HdrMetadataKey key HDR metadata key.
OH_Pixelmap_HdrMetadataValue **value

Double pointer to the value of the metadata key.

If the obtained metadata is dynamic metadata (HDR_DYNAMIC_METADATA) and the API is successfully called, you must call free(value->dynamicMetadata.data) to free the memory after using the metadata.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_DMA_NOT_EXIST: DMA memory does not exist.

IMAGE_COPY_FAILED: Memory copy fails.

[h2]OH_PixelmapNative_SetMetadata()

Image_ErrorCode OH_PixelmapNative_SetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, OH_Pixelmap_HdrMetadataValue *value)

Description

Sets the HDR metadata for a PixelMap. The type of metadata to be set is specified by passing an OH_Pixelmap_HdrMetadataKey key, and the corresponding metadata value is passed via OH_Pixelmap_HdrMetadataValue.

Since: 12

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to the OH_PixelmapNative to be operated. The memory type of the PixelMap must be DMA.
OH_Pixelmap_HdrMetadataKey key HDR metadata key.
OH_Pixelmap_HdrMetadataValue *value Pointer to the value of the metadata key.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

IMAGE_DMA_NOT_EXIST: DMA memory does not exist.

IMAGE_COPY_FAILED: Memory copy fails.

[h2]OH_PixelmapNative_SetColorSpaceNative()

Image_ErrorCode OH_PixelmapNative_SetColorSpaceNative(OH_PixelmapNative *pixelmap, OH_NativeColorSpaceManager *colorSpaceNative)

Description

Sets the NativeColorSpaceManager object for a PixelMap to manage the color space information of the PixelMap.

Since: 13

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to the target PixelMap of the NativeColorSpaceManager object to set.
OH_NativeColorSpaceManager *colorSpaceNative Pointer to a NativeColorSpaceManager object.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_GetColorSpaceNative()

Image_ErrorCode OH_PixelmapNative_GetColorSpaceNative(OH_PixelmapNative *pixelmap, OH_NativeColorSpaceManager **colorSpaceNative)

Description

Obtains the NativeColorSpaceManager object of a PixelMap to query the color space information currently configured for the PixelMap.

Since: 13

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to the source PixelMap of the NativeColorSpaceManager to be obtained.
OH_NativeColorSpaceManager **colorSpaceNative Double pointer to the NativeColorSpaceManager object obtained.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: A parameter is incorrect.

[h2]OH_PixelmapNative_SetMemoryName()

Image_ErrorCode OH_PixelmapNative_SetMemoryName(OH_PixelmapNative *pixelmap, char *name, size_t *size)

Description

Sets the memory name of a PixelMap to facilitate memory identification during debugging or issue troubleshooting.

Since: 13

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to an OH_PixelmapNative object.
char *name Pointer to the PixelMap memory name. For the DMA memory type, the value range is [1, 255]. For the SHARE_MEMORY memory type, the value range is [1, 244]. The unit is bytes.
size_t *size Byte size of the memory name to be set for the PixelMap. For the DMA memory type, the value range is [1, 255]. For the SHARE_MEMORY memory type, the value range is [1, 244]. The unit is bytes.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: The name length exceeds the value range. For the DMA memory type, the value range is [1, 255]. For the SHARE_MEMORY memory type, the value range is [1, 244]. The unit is bytes.

IMAGE_UNSUPPORTED_MEMORY_FORMAT: The memory is neither DMA memory nor SHARE_MEMORY memory.

[h2]OH_PixelmapNative_GetByteCount()

Image_ErrorCode OH_PixelmapNative_GetByteCount(OH_PixelmapNative *pixelmap, uint32_t *byteCount)

Description

Obtains the total number of bytes occupied by all pixels in a PixelMap, excluding memory-alignment padding bytes.

Since: 18

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to a PixelMap.
uint32_t *byteCount Pointer to the number of bytes obtained.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

Image_BAD_PARAMETER: The pixelmap or byteCount parameter is invalid.

[h2]OH_PixelmapNative_GetAllocationByteCount()

Image_ErrorCode OH_PixelmapNative_GetAllocationByteCount(OH_PixelmapNative *pixelmap, uint32_t *allocationByteCount)

Description

Obtains the actual number of memory bytes allocated for storing pixel data, including memory-alignment padding bytes. Unlike OH_PixelmapNative_GetByteCount (which does not include padding), this API returns the actual memory size allocated by the system for the PixelMap.

Since: 18

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to a PixelMap.
uint32_t *allocationByteCount Pointer to the number of bytes obtained.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

Image_BAD_PARAMETER: The pixelmap or allocationByteCount parameter is invalid.

[h2]OH_PixelmapNative_AccessPixels()

Image_ErrorCode OH_PixelmapNative_AccessPixels(OH_PixelmapNative *pixelmap, void **addr)

Description

Obtains the memory address where the pixels of a PixelMap are stored and locks the memory.

When the memory is locked, any attempts to alter or free the pixel data of the PixelMap will fail or be ineffective.

After use, you must call OH_PixelmapNative_UnaccessPixels to release the memory lock. The two APIs must be used in pairs.

Since: 15

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to a PixelMap.
void **addr Double pointer to the memory address.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

Image_BAD_PARAMETER: The pixelmap or addr parameter is invalid.

Image_LOCK_UNLOCK_FAILED: Memory locking fails.

[h2]OH_PixelmapNative_UnaccessPixels()

Image_ErrorCode OH_PixelmapNative_UnaccessPixels(OH_PixelmapNative *pixelmap)

Description

Unlocks the memory allocated to store the pixels of a PixelMap.

This function must be used together with OH_PixelmapNative_AccessPixels.

Since: 15

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to a PixelMap.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

Image_BAD_PARAMETER: The pixelmap parameter is invalid.

IMAGE_LOCK_UNLOCK_FAILED: Memory unlocking fails.

[h2]OH_PixelmapNative_GetUniqueId()

Image_ErrorCode OH_PixelmapNative_GetUniqueId(OH_PixelmapNative *pixelmap, uint32_t *uniqueId)

Description

Obtains the unique ID of a PixelMap.

Since: 22

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to the unique ID of the PixelMap.
uint32_t *uniqueId Pointer to the unique ID obtained.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: Invalid parameters. For example, pixelmap or uniqueId is incorrect.

[h2]OH_PixelmapNative_IsReleased()

Image_ErrorCode OH_PixelmapNative_IsReleased(OH_PixelmapNative *pixelmap, bool *released)

Description

Checks whether a PixelMap is released. If released, any attempt to access the internal data of this object will fail.

Since: 22

Parameters

Name Description
OH_PixelmapNative *pixelmap Pointer to the PixelMap to be checked.
bool *released Release status of the PixelMap. The value true indicates that the PixelMap is released, and false indicates the opposite.

Returns

Type Description
Image_ErrorCode

IMAGE_SUCCESS: The operation is successful.

IMAGE_BAD_PARAMETER: Invalid parameters. For example, pixelmap or released is incorrect.