1# pixelmap_native.h 2 3## Overview 4 5The **pixelmap_native.h** file declares the APIs for accessing a PixelMap. 6 7**File to include**: <multimedia/image_framework/image/pixelmap_native.h> 8 9**Library**: libpixelmap.so 10 11**Since**: 12 12 13**Related module**: [Image_NativeModule](capi-image-nativemodule.md) 14 15## Summary 16 17### Structs 18 19| Name| typedef Keyword| Description| 20| -- | -- | -- | 21| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) | OH_PixelmapNative | Describes an uncompressed PixelMap format, which is encapsulated at the native layer after images are decoded.| 22| [OH_NativeBuffer](capi-image-nativemodule-image-nativemodule-oh-nativebuffer.md) | OH_NativeBuffer | Describes the native buffer, which is used to perform operations related to the native buffer.| 23| [OH_Pixelmap_HdrStaticMetadata](capi-image-nativemodule-oh-pixelmap-hdrstaticmetadata.md) | OH_Pixelmap_HdrStaticMetadata | Describes the static metadata values available for the key **HDR_STATIC_METADATA**.| 24| [OH_NativeColorSpaceManager](capi-image-nativemodule-oh-nativecolorspacemanager.md) | OH_NativeColorSpaceManager | Describes the native color space manager, which is used to perform operations related to the native color space manager.| 25| [OH_Pixelmap_HdrDynamicMetadata](capi-image-nativemodule-oh-pixelmap-hdrdynamicmetadata.md) | OH_Pixelmap_HdrDynamicMetadata | Describes the dynamic metadata values available for the key **DR_DYNAMIC_METADATA**.| 26| [OH_Pixelmap_HdrGainmapMetadata](capi-image-nativemodule-oh-pixelmap-hdrgainmapmetadata.md) | OH_Pixelmap_HdrGainmapMetadata | Describes the gain map metadata values available for the key **HDR_GAINMAP_METADATA**. For details, see ISO 21496-1.| 27| [OH_Pixelmap_HdrMetadataValue](capi-image-nativemodule-oh-pixelmap-hdrmetadatavalue.md) | OH_Pixelmap_HdrMetadataValue | Describes the HDR metadata values used by the PixelMap and available for the key **OH_Pixelmap_HdrMetadataKey**.| 28| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) | OH_Pixelmap_InitializationOptions | Describes the initialization options encapsulated at the native layer. The struct is used to set the initialization parameters for a PixelMap.| 29| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) | OH_Pixelmap_ImageInfo | Describes the image information encapsulated at the native layer. The struct stores the width, height, row stride, pixel format, and HDR of an image.| 30 31### Enums 32 33| Name| typedef Keyword| Description| 34| -- | -- | -- | 35| [PIXELMAP_ALPHA_TYPE](#pixelmap_alpha_type) | PIXELMAP_ALPHA_TYPE | Enumerates the alpha types of a PixelMap.| 36| [PIXEL_FORMAT](#pixel_format) | PIXEL_FORMAT | Enumerates the image pixel formats.| 37| [OH_PixelmapNative_AntiAliasingLevel](#oh_pixelmapnative_antialiasinglevel) | OH_PixelmapNative_AntiAliasingLevel | Enumerates the anti-aliasing levels used for scaling PixelMaps.| 38| [OH_Pixelmap_HdrMetadataKey](#oh_pixelmap_hdrmetadatakey) | OH_Pixelmap_HdrMetadataKey | Enumerates the keys of the HDR related metadata information used by the PixelMap. It is used in [OH_PixelmapNative_SetMetadata](#oh_pixelmapnative_setmetadata) and [OH_PixelmapNative_GetMetadata](#oh_pixelmapnative_getmetadata).| 39| [OH_Pixelmap_HdrMetadataType](#oh_pixelmap_hdrmetadatatype) | OH_Pixelmap_HdrMetadataType | Enumerates the HDR metadata types, which are the values of **HDR_METADATA_TYPE**.| 40 41### Functions 42 43| Name| Description| 44| -- | -- | 45| [Image_ErrorCode OH_PixelmapInitializationOptions_Create(OH_Pixelmap_InitializationOptions **options)](#oh_pixelmapinitializationoptions_create) | Creates the pointer to an OH_Pixelmap_InitializationOptions struct.| 46| [Image_ErrorCode OH_PixelmapInitializationOptions_GetWidth(OH_Pixelmap_InitializationOptions *options,uint32_t *width)](#oh_pixelmapinitializationoptions_getwidth) | Obtains the image width.| 47| [Image_ErrorCode OH_PixelmapInitializationOptions_SetWidth(OH_Pixelmap_InitializationOptions *options,uint32_t width)](#oh_pixelmapinitializationoptions_setwidth) | Sets the image width.| 48| [Image_ErrorCode OH_PixelmapInitializationOptions_GetHeight(OH_Pixelmap_InitializationOptions *options,uint32_t *height)](#oh_pixelmapinitializationoptions_getheight) | Obtains the image height.| 49| [Image_ErrorCode OH_PixelmapInitializationOptions_SetHeight(OH_Pixelmap_InitializationOptions *options,uint32_t height)](#oh_pixelmapinitializationoptions_setheight) | Sets the image height.| 50| [Image_ErrorCode OH_PixelmapInitializationOptions_GetPixelFormat(OH_Pixelmap_InitializationOptions *options,int32_t *pixelFormat)](#oh_pixelmapinitializationoptions_getpixelformat) | Obtains the pixel format.| 51| [Image_ErrorCode OH_PixelmapInitializationOptions_SetPixelFormat(OH_Pixelmap_InitializationOptions *options,int32_t pixelFormat)](#oh_pixelmapinitializationoptions_setpixelformat) | Sets the pixel format.| 52| [Image_ErrorCode OH_PixelmapInitializationOptions_GetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options,int32_t *srcpixelFormat)](#oh_pixelmapinitializationoptions_getsrcpixelformat) | Obtains the source pixel format.| 53| [Image_ErrorCode OH_PixelmapInitializationOptions_SetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options,int32_t srcpixelFormat)](#oh_pixelmapinitializationoptions_setsrcpixelformat) | Sets the source pixel format.| 54| [Image_ErrorCode OH_PixelmapInitializationOptions_GetRowStride(OH_Pixelmap_InitializationOptions *options,int32_t *rowStride)](#oh_pixelmapinitializationoptions_getrowstride) | Obtains the row stride.<br>The stride is the actual memory size occupied by each row of the image, in bytes. Stride = Width \*Number of bytes per pixel + Padding, where padding refers to the extra space added at the end of each row for memory alignment purposes.| 55| [Image_ErrorCode OH_PixelmapInitializationOptions_SetRowStride(OH_Pixelmap_InitializationOptions *options,int32_t rowStride)](#oh_pixelmapinitializationoptions_setrowstride) | Sets the row stride.<br>The stride is the actual memory size occupied by each row of the image, in bytes. Stride = Width \*Number of bytes per pixel + Padding, where padding refers to the extra space added at the end of each row for memory alignment purposes.| 56| [Image_ErrorCode OH_PixelmapInitializationOptions_GetAlphaType(OH_Pixelmap_InitializationOptions *options,int32_t *alphaType)](#oh_pixelmapinitializationoptions_getalphatype) | Obtains the alpha type.| 57| [Image_ErrorCode OH_PixelmapInitializationOptions_SetAlphaType(OH_Pixelmap_InitializationOptions *options,int32_t alphaType)](#oh_pixelmapinitializationoptions_setalphatype) | Sets the alpha type.| 58| [Image_ErrorCode OH_PixelmapInitializationOptions_GetEditable(OH_Pixelmap_InitializationOptions *options,bool *editable)](#oh_pixelmapinitializationoptions_geteditable) | Obtains the editable flag.| 59| [Image_ErrorCode OH_PixelmapInitializationOptions_SetEditable(OH_Pixelmap_InitializationOptions *options,bool editable)](#oh_pixelmapinitializationoptions_seteditable) | Sets the editable flag.| 60| [Image_ErrorCode OH_PixelmapInitializationOptions_Release(OH_Pixelmap_InitializationOptions *options)](#oh_pixelmapinitializationoptions_release) | Releases the pointer to an OH_Pixelmap_InitializationOptions struct.| 61| [Image_ErrorCode OH_PixelmapImageInfo_Create(OH_Pixelmap_ImageInfo **info)](#oh_pixelmapimageinfo_create) | Creates the pointer to an OH_Pixelmap_ImageInfo struct.| 62| [Image_ErrorCode OH_PixelmapImageInfo_GetWidth(OH_Pixelmap_ImageInfo *info, uint32_t *width)](#oh_pixelmapimageinfo_getwidth) | Obtains the image width.| 63| [Image_ErrorCode OH_PixelmapImageInfo_GetHeight(OH_Pixelmap_ImageInfo *info, uint32_t *height)](#oh_pixelmapimageinfo_getheight) | Obtains the image height.| 64| [Image_ErrorCode OH_PixelmapImageInfo_GetAlphaMode(OH_Pixelmap_ImageInfo *info, int32_t *AlphaMode)](#oh_pixelmapimageinfo_getalphamode) | Obtains the alpha format of an image.| 65| [Image_ErrorCode OH_PixelmapImageInfo_GetRowStride(OH_Pixelmap_ImageInfo *info, uint32_t *rowStride)](#oh_pixelmapimageinfo_getrowstride) | Obtains the row stride.| 66| [Image_ErrorCode OH_PixelmapImageInfo_GetPixelFormat(OH_Pixelmap_ImageInfo *info, int32_t *pixelFormat)](#oh_pixelmapimageinfo_getpixelformat) | Obtains the pixel format.| 67| [Image_ErrorCode OH_PixelmapImageInfo_GetAlphaType(OH_Pixelmap_ImageInfo *info, int32_t *alphaType)](#oh_pixelmapimageinfo_getalphatype) | Obtains the alpha type.| 68| [Image_ErrorCode OH_PixelmapImageInfo_GetDynamicRange(OH_Pixelmap_ImageInfo *info, bool *isHdr)](#oh_pixelmapimageinfo_getdynamicrange) | Obtains the dynamic range of a PixelMap.| 69| [Image_ErrorCode OH_PixelmapImageInfo_Release(OH_Pixelmap_ImageInfo *info)](#oh_pixelmapimageinfo_release) | Releases the pointer to an OH_Pixelmap_ImageInfo struct.| 70| [Image_ErrorCode OH_PixelmapNative_CreatePixelmap(uint8_t *data, size_t dataLength,OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap)](#oh_pixelmapnative_createpixelmap) | Creates a PixelMap based on properties. By default, the BGRA_8888 format is used for data processing. For details about other formats, see [OH_PixelmapInitializationOptions_SetSrcPixelFormat](#oh_pixelmapinitializationoptions_setsrcpixelformat).| 71| [Image_ErrorCode OH_PixelmapNative_CreatePixelmapUsingAllocator(uint8_t *data, size_t dataLength,OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap)](#oh_pixelmapnative_createpixelmapusingallocator) | Creates a PixelMap object based on the options and memory type, where **allocator** specifies the memory type of the PixelMap. By default, the system selects an appropriate memory type based on the image type, image size, and platform capability. When processing the returned PixelMap object, consider the impact of stride.| 72| [Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeToNapi(napi_env env, OH_PixelmapNative *pixelmapNative,napi_value *pixelmapNapi)](#oh_pixelmapnative_convertpixelmapnativetonapi) | Converts a nativePixelMap object to a PixelMapnapi object.| 73| [Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeFromNapi(napi_env env, napi_value pixelmapNapi,OH_PixelmapNative **pixelmapNative)](#oh_pixelmapnative_convertpixelmapnativefromnapi) | Converts a PixelMapnapi object to a nativePixelMap object.| 74| [Image_ErrorCode OH_PixelmapNative_ReadPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize)](#oh_pixelmapnative_readpixels) | Reads the pixels of a PixelMap and writes the result to the buffer based on the pixel format of the PixelMap.| 75| [Image_ErrorCode OH_PixelmapNative_WritePixels(OH_PixelmapNative *pixelmap, uint8_t *source, size_t bufferSize)](#oh_pixelmapnative_writepixels) | Reads the pixels in the buffer and writes the result to the PixelMap based on the pixel format of the PixelMap.| 76| [Image_ErrorCode OH_PixelmapNative_GetArgbPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize)](#oh_pixelmapnative_getargbpixels) | Reads data in ARGB format from a PixelMap.| 77| [Image_ErrorCode OH_PixelmapNative_ToSdr(OH_PixelmapNative *pixelmap)](#oh_pixelmapnative_tosdr) | Converts a PixelMap from the HDR format to the SDR format.| 78| [Image_ErrorCode OH_PixelmapNative_GetImageInfo(OH_PixelmapNative *pixelmap, OH_Pixelmap_ImageInfo *imageInfo)](#oh_pixelmapnative_getimageinfo) | Obtains the image information of a PixelMap.| 79| [Image_ErrorCode OH_PixelmapNative_Opacity(OH_PixelmapNative *pixelmap, float rate)](#oh_pixelmapnative_opacity) | Sets the opacity rate to enable the PixelMap to achieve the corresponding opacity effect.| 80| [Image_ErrorCode OH_PixelmapNative_Scale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY)](#oh_pixelmapnative_scale) | Scales a PixelMap based on a given width and height.| 81| [Image_ErrorCode OH_PixelmapNative_ScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY,OH_PixelmapNative_AntiAliasingLevel level)](#oh_pixelmapnative_scalewithantialiasing) | Scales a PixelMap based on the specified anti-aliasing level, width, and height.| 82| [Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMap(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap,float scaleX, float scaleY)](#oh_pixelmapnative_createscaledpixelmap) | Creates a PixelMap that has been resized based on the specified scale factors of the width and height.| 83| [Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMapWithAntiAliasing(OH_PixelmapNative *srcPixelmap,OH_PixelmapNative **dstPixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level)](#oh_pixelmapnative_createscaledpixelmapwithantialiasing) | Creates a PixelMap that has been resized based on the specified anti-aliasing level and the scale factors of the width and height.| 84| [Image_ErrorCode OH_PixelmapNative_Translate(OH_PixelmapNative *pixelmap, float x, float y)](#oh_pixelmapnative_translate) | Translates a PixelMap based on given coordinates.| 85| [Image_ErrorCode OH_PixelmapNative_Rotate(OH_PixelmapNative *pixelmap, float angle)](#oh_pixelmapnative_rotate) | Rotates a PixelMap based on a given angle.| 86| [Image_ErrorCode OH_PixelmapNative_Flip(OH_PixelmapNative *pixelmap, bool shouldFilpHorizontally, bool shouldFilpVertically)](#oh_pixelmapnative_flip) | Flips a PixelMap based on a given angle.| 87| [Image_ErrorCode OH_PixelmapNative_Crop(OH_PixelmapNative *pixelmap, Image_Region *region)](#oh_pixelmapnative_crop) | Crops a PixelMap based on a given size.| 88| [Image_ErrorCode OH_PixelmapNative_Release(OH_PixelmapNative *pixelmap)](#oh_pixelmapnative_release) | Releases the pointer to an OH_PixelmapNative object. [OH_PixelmapNative_Destroy](#oh_pixelmapnative_destroy) is recommended.| 89| [Image_ErrorCode OH_PixelmapNative_Destroy(OH_PixelmapNative **pixelmap)](#oh_pixelmapnative_destroy) | Releases the pointer to an OH_PixelmapNative object.| 90| [Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixelmap,OH_PixelmapNative* dstpixelmap, const bool isPremul)](#oh_pixelmapnative_convertalphaformat) | Converts pixel data of a PixelMap from premultiplied alpha to non-premultiplied alpha, or vice versa.| 91| [Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap(OH_Pixelmap_InitializationOptions *options,OH_PixelmapNative **pixelmap)](#oh_pixelmapnative_createemptypixelmap) | Creates an empty PixelMap object based on **OH_Pixelmap_InitializationOptions**. The memory data is 0.| 92| [Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmapUsingAllocator(OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap)](#oh_pixelmapnative_createemptypixelmapusingallocator) | Creates an empty PixelMap object based on the options and memory type, where **allocator** specifies the memory type of the PixelMap. By default, the system selects an appropriate memory type based on the image type, image size, and platform capability. When processing the returned PixelMap object, consider the impact of stride.| 93| [Image_ErrorCode OH_PixelmapNative_GetNativeBuffer(OH_PixelmapNative *pixelmap, OH_NativeBuffer **nativeBuffer)](#oh_pixelmapnative_getnativebuffer) | Obtains the NativeBuffer object from a PixelMap in the DMA memory.| 94| [Image_ErrorCode OH_PixelmapNative_GetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key,OH_Pixelmap_HdrMetadataValue **value)](#oh_pixelmapnative_getmetadata) | Obtains the metadata.| 95| [Image_ErrorCode OH_PixelmapNative_SetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key,OH_Pixelmap_HdrMetadataValue *value)](#oh_pixelmapnative_setmetadata) | Sets the metadata.| 96| [Image_ErrorCode OH_PixelmapNative_SetColorSpaceNative(OH_PixelmapNative *pixelmap,OH_NativeColorSpaceManager *colorSpaceNative)](#oh_pixelmapnative_setcolorspacenative) | Sets a NativeColorSpaceManager object.| 97| [Image_ErrorCode OH_PixelmapNative_GetColorSpaceNative(OH_PixelmapNative *pixelmap,OH_NativeColorSpaceManager **colorSpaceNative)](#oh_pixelmapnative_getcolorspacenative) | Obtains a NativeColorSpaceManager object.| 98| [Image_ErrorCode OH_PixelmapNative_SetMemoryName(OH_PixelmapNative *pixelmap, char *name, size_t *size)](#oh_pixelmapnative_setmemoryname) | Sets the memory name of a PixelMap.| 99| [Image_ErrorCode OH_PixelmapNative_GetByteCount(OH_PixelmapNative *pixelmap, uint32_t *byteCount)](#oh_pixelmapnative_getbytecount) | Obtains the total number of bytes occupied by all pixels in a PixelMap, excluding any memory padding.| 100| [Image_ErrorCode OH_PixelmapNative_GetAllocationByteCount(OH_PixelmapNative *pixelmap, uint32_t *allocationByteCount)](#oh_pixelmapnative_getallocationbytecount) | Obtains the number of bytes in the memory allocated by a PixelMap to store pixels.| 101| [Image_ErrorCode OH_PixelmapNative_AccessPixels(OH_PixelmapNative *pixelmap, void **addr)](#oh_pixelmapnative_accesspixels) | Obtains the memory address where the pixels of a PixelMap are stored and locks the memory.<br>When the memory is locked, any attempts to alter or free the pixel data of the PixelMap will fail or be ineffective.| 102| [Image_ErrorCode OH_PixelmapNative_UnaccessPixels(OH_PixelmapNative *pixelmap)](#oh_pixelmapnative_unaccesspixels) | Unlocks the memory allocated to store the pixels of a PixelMap.<br>This function must be used together with [OH_PixelmapNative_AccessPixels](#oh_pixelmapnative_accesspixels).| 103 104## Enum Description 105 106### PIXELMAP_ALPHA_TYPE 107 108``` 109enum PIXELMAP_ALPHA_TYPE 110``` 111 112**Description** 113 114Enumerates the alpha types of a PixelMap. 115 116**Since**: 12 117 118| Enum Item| Description| 119| -- | -- | 120| PIXELMAP_ALPHA_TYPE_UNKNOWN = 0 | Unknown format.| 121| PIXELMAP_ALPHA_TYPE_OPAQUE = 1 | Opaque format.| 122| PIXELMAP_ALPHA_TYPE_PREMULTIPLIED = 2 | Premultiplied format.| 123| PIXELMAP_ALPHA_TYPE_UNPREMULTIPLIED = 3 | Non-premultiplied format.| 124 125### PIXEL_FORMAT 126 127``` 128enum PIXEL_FORMAT 129``` 130 131**Description** 132 133Enumerates the image pixel formats. 134 135**Since**: 12 136 137| Enum Item| Description| 138| -- | -- | 139| PIXEL_FORMAT_UNKNOWN = 0 | Unknown format.| 140| PIXEL_FORMAT_RGB_565 = 2 | RGB_565 format.| 141| PIXEL_FORMAT_RGBA_8888 = 3 | RGBA_8888 format.| 142| PIXEL_FORMAT_BGRA_8888 = 4 | BGRA_8888 format.| 143| PIXEL_FORMAT_RGB_888 = 5 | RGB_888 format.| 144| PIXEL_FORMAT_ALPHA_8 = 6 | ALPHA_8 format.| 145| PIXEL_FORMAT_RGBA_F16 = 7 | RGBA_F16 format.| 146| PIXEL_FORMAT_NV21 = 8 | NV21 format.| 147| PIXEL_FORMAT_NV12 = 9 | NV12 format.| 148| PIXEL_FORMAT_RGBA_1010102 = 10 | RGBA_1010102 format.| 149| PIXEL_FORMAT_YCBCR_P010 = 11 | YCBCR_P010 format.| 150| PIXEL_FORMAT_YCRCB_P010 =12 | YCRCB_P010 format.| 151 152### OH_PixelmapNative_AntiAliasingLevel 153 154``` 155enum OH_PixelmapNative_AntiAliasingLevel 156``` 157 158**Description** 159 160Enumerates the anti-aliasing levels used for scaling PixelMaps. 161 162**Since**: 12 163 164| Enum Item| Description| 165| -- | -- | 166| OH_PixelmapNative_AntiAliasing_NONE = 0 | Nearest neighbor interpolation.| 167| OH_PixelmapNative_AntiAliasing_LOW = 1 | Bilinear interpolation.| 168| OH_PixelmapNative_AntiAliasing_MEDIUM = 2 | Bilinear interpolation with mipmap enabled. You are advised to use this value when zooming out an image.| 169| OH_PixelmapNative_AntiAliasing_HIGH = 3 | Cubic interpolation.| 170 171### OH_Pixelmap_HdrMetadataKey 172 173``` 174enum OH_Pixelmap_HdrMetadataKey 175``` 176 177**Description** 178 179Enumerates the keys of the HDR related metadata information used by the PixelMap. It is used in [OH_PixelmapNative_SetMetadata](#oh_pixelmapnative_setmetadata) and [OH_PixelmapNative_GetMetadata](#oh_pixelmapnative_getmetadata). 180 181**Since**: 12 182 183| Enum Item| Description| 184| -- | -- | 185| HDR_METADATA_TYPE = 0 | Metadata type used by the PixelMap.| 186| HDR_STATIC_METADATA = 1 | Static metadata.| 187| HDR_DYNAMIC_METADATA = 2 | Dynamic metadata.| 188| HDR_GAINMAP_METADATA = 3 | Metadata used by gain maps.| 189 190### OH_Pixelmap_HdrMetadataType 191 192``` 193enum OH_Pixelmap_HdrMetadataType 194``` 195 196**Description** 197 198Enumerates the HDR metadata types, which are the values of **HDR_METADATA_TYPE**. 199 200**Since**: 12 201 202| Enum Item| Description| 203| -- | -- | 204| HDR_METADATA_TYPE_NONE = 0 | No metadata.| 205| HDR_METADATA_TYPE_BASE = 1 | Metadata used for base graphics.| 206| HDR_METADATA_TYPE_GAINMAP = 2 | Metadata used for gain maps.| 207| HDR_METADATA_TYPE_ALTERNATE = 3 | Metadata used for synthesized HDR graphics.| 208 209 210## Function Description 211 212### OH_PixelmapInitializationOptions_Create() 213 214``` 215Image_ErrorCode OH_PixelmapInitializationOptions_Create(OH_Pixelmap_InitializationOptions **options) 216``` 217 218**Description** 219 220Creates the pointer to an OH_Pixelmap_InitializationOptions struct. 221 222**Since**: 12 223 224 225**Parameters** 226 227| Name| Description| 228| -- | -- | 229| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) **options | Double pointer to the OH_Pixelmap_InitializationOptions struct created.| 230 231**Returns** 232 233| Type| Description| 234| -- | -- | 235| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 236 237### OH_PixelmapInitializationOptions_GetWidth() 238 239``` 240Image_ErrorCode OH_PixelmapInitializationOptions_GetWidth(OH_Pixelmap_InitializationOptions *options,uint32_t *width) 241``` 242 243**Description** 244 245Obtains the image width. 246 247**Since**: 12 248 249 250**Parameters** 251 252| Name| Description| 253| -- | -- | 254| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 255| uint32_t *width | Pointer to the image width, in px.| 256 257**Returns** 258 259| Type| Description| 260| -- | -- | 261| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 262 263### OH_PixelmapInitializationOptions_SetWidth() 264 265``` 266Image_ErrorCode OH_PixelmapInitializationOptions_SetWidth(OH_Pixelmap_InitializationOptions *options,uint32_t width) 267``` 268 269**Description** 270 271Sets the image width. 272 273**Since**: 12 274 275 276**Parameters** 277 278| Name| Description| 279| -- | -- | 280| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 281| uint32_t width | Image width, in px.| 282 283**Returns** 284 285| Type| Description| 286| -- | -- | 287| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 288 289### OH_PixelmapInitializationOptions_GetHeight() 290 291``` 292Image_ErrorCode OH_PixelmapInitializationOptions_GetHeight(OH_Pixelmap_InitializationOptions *options,uint32_t *height) 293``` 294 295**Description** 296 297Obtains the image height. 298 299**Since**: 12 300 301 302**Parameters** 303 304| Name| Description| 305| -- | -- | 306| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 307| uint32_t *height | Pointer to the image height, in px.| 308 309**Returns** 310 311| Type| Description| 312| -- | -- | 313| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 314 315### OH_PixelmapInitializationOptions_SetHeight() 316 317``` 318Image_ErrorCode OH_PixelmapInitializationOptions_SetHeight(OH_Pixelmap_InitializationOptions *options,uint32_t height) 319``` 320 321**Description** 322 323Sets the image height. 324 325**Since**: 12 326 327 328**Parameters** 329 330| Name| Description| 331| -- | -- | 332| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 333| uint32_t height | Image height, in px.| 334 335**Returns** 336 337| Type| Description| 338| -- | -- | 339| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 340 341### OH_PixelmapInitializationOptions_GetPixelFormat() 342 343``` 344Image_ErrorCode OH_PixelmapInitializationOptions_GetPixelFormat(OH_Pixelmap_InitializationOptions *options,int32_t *pixelFormat) 345``` 346 347**Description** 348 349Obtains the pixel format. 350 351**Since**: 12 352 353 354**Parameters** 355 356| Name| Description| 357| -- | -- | 358| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 359| int32_t *pixelFormat | Pointer to the pixel format. For details about the available options, see [PIXEL_FORMAT](#pixel_format).| 360 361**Returns** 362 363| Type| Description| 364| -- | -- | 365| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 366 367### OH_PixelmapInitializationOptions_SetPixelFormat() 368 369``` 370Image_ErrorCode OH_PixelmapInitializationOptions_SetPixelFormat(OH_Pixelmap_InitializationOptions *options,int32_t pixelFormat) 371``` 372 373**Description** 374 375Sets the pixel format. 376 377**Since**: 12 378 379 380**Parameters** 381 382| Name| Description| 383| -- | -- | 384| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 385| int32_t pixelFormat | Pixel format. For details about the available options, see [PIXEL_FORMAT](#pixel_format).| 386 387**Returns** 388 389| Type| Description| 390| -- | -- | 391| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 392 393### OH_PixelmapInitializationOptions_GetSrcPixelFormat() 394 395``` 396Image_ErrorCode OH_PixelmapInitializationOptions_GetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options,int32_t *srcpixelFormat) 397``` 398 399**Description** 400 401Obtains the source pixel format. 402 403**Since**: 12 404 405 406**Parameters** 407 408| Name| Description| 409| -- | -- | 410| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 411| int32_t *srcpixelFormat | Pointer to the pixel format. For details about the available options, see [PIXEL_FORMAT](#pixel_format).| 412 413**Returns** 414 415| Type| Description| 416| -- | -- | 417| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 418 419### OH_PixelmapInitializationOptions_SetSrcPixelFormat() 420 421``` 422Image_ErrorCode OH_PixelmapInitializationOptions_SetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options,int32_t srcpixelFormat) 423``` 424 425**Description** 426 427Sets the source pixel format. 428 429**Since**: 12 430 431 432**Parameters** 433 434| Name| Description| 435| -- | -- | 436| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 437| int32_t srcpixelFormat | Source pixel format. For details about the available options, see [PIXEL_FORMAT](#pixel_format).| 438 439**Returns** 440 441| Type| Description| 442| -- | -- | 443| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 444 445### OH_PixelmapInitializationOptions_GetRowStride() 446 447``` 448Image_ErrorCode OH_PixelmapInitializationOptions_GetRowStride(OH_Pixelmap_InitializationOptions *options,int32_t *rowStride) 449``` 450 451**Description** 452 453Obtains the row stride.<br> The stride is the actual memory size occupied by each row of the image, in bytes. Stride = Width \*Number of bytes per pixel + Padding, where padding refers to the extra space added at the end of each row for memory alignment purposes. 454 455**Since**: 12 456 457 458**Parameters** 459 460| Name| Description| 461| -- | -- | 462| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 463| int32_t *rowStride | Pointer to the stride, in bytes.| 464 465**Returns** 466 467| Type| Description| 468| -- | -- | 469| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_UNKNOWN_ERROR**: The struct that **options** points to is released.| 470 471### OH_PixelmapInitializationOptions_SetRowStride() 472 473``` 474Image_ErrorCode OH_PixelmapInitializationOptions_SetRowStride(OH_Pixelmap_InitializationOptions *options,int32_t rowStride) 475``` 476 477**Description** 478 479Sets the row stride.<br>The stride is the actual memory size occupied by each row of the image, in bytes. Stride = Width \*Number of bytes per pixel + Padding, where padding refers to the extra space added at the end of each row for memory alignment purposes. 480 481**Since**: 12 482 483 484**Parameters** 485 486| Name| Description| 487| -- | -- | 488| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 489| int32_t rowStride | Stride, in bytes.| 490 491**Returns** 492 493| Type| Description| 494| -- | -- | 495| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_UNKNOWN_ERROR**: The struct that **options** points to is released.| 496 497### OH_PixelmapInitializationOptions_GetAlphaType() 498 499``` 500Image_ErrorCode OH_PixelmapInitializationOptions_GetAlphaType(OH_Pixelmap_InitializationOptions *options,int32_t *alphaType) 501``` 502 503**Description** 504 505Obtains the alpha type. 506 507**Since**: 12 508 509 510**Parameters** 511 512| Name| Description| 513| -- | -- | 514| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 515| int32_t *alphaType | Pointer to the alpha type. For details about the available options, see [PIXELMAP_ALPHA_TYPE](#pixelmap_alpha_type).| 516 517**Returns** 518 519| Type| Description| 520| -- | -- | 521| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 522 523### OH_PixelmapInitializationOptions_SetAlphaType() 524 525``` 526Image_ErrorCode OH_PixelmapInitializationOptions_SetAlphaType(OH_Pixelmap_InitializationOptions *options,int32_t alphaType) 527``` 528 529**Description** 530 531Sets the alpha type. 532 533**Since**: 12 534 535 536**Parameters** 537 538| Name| Description| 539| -- | -- | 540| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 541| int32_t alphaType | Alpha type. For details about the available options, see [PIXELMAP_ALPHA_TYPE](#pixelmap_alpha_type).| 542 543**Returns** 544 545| Type| Description| 546| -- | -- | 547| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 548 549### OH_PixelmapInitializationOptions_GetEditable() 550 551``` 552Image_ErrorCode OH_PixelmapInitializationOptions_GetEditable(OH_Pixelmap_InitializationOptions *options,bool *editable) 553``` 554 555**Description** 556 557Obtains the editable flag. 558 559**Since**: 18 560 561 562**Parameters** 563 564| Name| Description| 565| -- | -- | 566| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 567| bool *editable | Pointer to the editable flag.| 568 569**Returns** 570 571| Type| Description| 572| -- | -- | 573| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 574 575### OH_PixelmapInitializationOptions_SetEditable() 576 577``` 578Image_ErrorCode OH_PixelmapInitializationOptions_SetEditable(OH_Pixelmap_InitializationOptions *options,bool editable) 579``` 580 581**Description** 582 583Sets the editable flag. 584 585**Since**: 18 586 587 588**Parameters** 589 590| Name| Description| 591| -- | -- | 592| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 593| bool editable | Editable flag.| 594 595**Returns** 596 597| Type| Description| 598| -- | -- | 599| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 600 601### OH_PixelmapInitializationOptions_Release() 602 603``` 604Image_ErrorCode OH_PixelmapInitializationOptions_Release(OH_Pixelmap_InitializationOptions *options) 605``` 606 607**Description** 608 609Releases the pointer to an OH_Pixelmap_InitializationOptions struct. 610 611**Since**: 12 612 613 614**Parameters** 615 616| Name| Description| 617| -- | -- | 618| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to an OH_Pixelmap_InitializationOptions struct.| 619 620**Returns** 621 622| Type| Description| 623| -- | -- | 624| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 625 626### OH_PixelmapImageInfo_Create() 627 628``` 629Image_ErrorCode OH_PixelmapImageInfo_Create(OH_Pixelmap_ImageInfo **info) 630``` 631 632**Description** 633 634Creates the pointer to an OH_Pixelmap_ImageInfo struct. 635 636**Since**: 12 637 638 639**Parameters** 640 641| Name| Description| 642| -- | -- | 643| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) **info | Double pointer to the OH_Pixelmap_ImageInfo struct created.| 644 645**Returns** 646 647| Type| Description| 648| -- | -- | 649| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 650 651### OH_PixelmapImageInfo_GetWidth() 652 653``` 654Image_ErrorCode OH_PixelmapImageInfo_GetWidth(OH_Pixelmap_ImageInfo *info, uint32_t *width) 655``` 656 657**Description** 658 659Obtains the image width. 660 661**Since**: 12 662 663 664**Parameters** 665 666| Name| Description| 667| -- | -- | 668| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) *info | Pointer to an OH_Pixelmap_ImageInfo struct.| 669| uint32_t *width | Pointer to the image width, in px.| 670 671**Returns** 672 673| Type| Description| 674| -- | -- | 675| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 676 677### OH_PixelmapImageInfo_GetHeight() 678 679``` 680Image_ErrorCode OH_PixelmapImageInfo_GetHeight(OH_Pixelmap_ImageInfo *info, uint32_t *height) 681``` 682 683**Description** 684 685Obtains the image height. 686 687**Since**: 12 688 689 690**Parameters** 691 692| Name| Description| 693| -- | -- | 694| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) *info | Pointer to an OH_Pixelmap_ImageInfo struct.| 695| uint32_t *height | Pointer to the image height, in px.| 696 697**Returns** 698 699| Type| Description| 700| -- | -- | 701| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 702 703### OH_PixelmapImageInfo_GetAlphaMode() 704 705``` 706Image_ErrorCode OH_PixelmapImageInfo_GetAlphaMode(OH_Pixelmap_ImageInfo *info, int32_t *AlphaMode) 707``` 708 709**Description** 710 711Obtains the alpha format of an image. 712 713**Since**: 20 714 715 716**Parameters** 717 718| Name| Description| 719| -- | -- | 720| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) *info | Pointer to an OH_Pixelmap_ImageInfo struct.| 721| int32_t *AlphaMode | Pointer to the alpha format.| 722 723**Returns** 724 725| Type| Description| 726| -- | -- | 727| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 728 729### OH_PixelmapImageInfo_GetRowStride() 730 731``` 732Image_ErrorCode OH_PixelmapImageInfo_GetRowStride(OH_Pixelmap_ImageInfo *info, uint32_t *rowStride) 733``` 734 735**Description** 736 737Obtains the row stride. 738 739**Since**: 12 740 741 742**Parameters** 743 744| Name| Description| 745| -- | -- | 746| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) *info | Pointer to an OH_Pixelmap_ImageInfo struct.| 747| 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.| 748 749**Returns** 750 751| Type| Description| 752| -- | -- | 753| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 754 755### OH_PixelmapImageInfo_GetPixelFormat() 756 757``` 758Image_ErrorCode OH_PixelmapImageInfo_GetPixelFormat(OH_Pixelmap_ImageInfo *info, int32_t *pixelFormat) 759``` 760 761**Description** 762 763Obtains the pixel format. 764 765**Since**: 12 766 767 768**Parameters** 769 770| Name| Description| 771| -- | -- | 772| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) *info | Pointer to an OH_Pixelmap_ImageInfo struct.| 773| int32_t *pixelFormat | Pointer to the pixel format.| 774 775**Returns** 776 777| Type| Description| 778| -- | -- | 779| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 780 781### OH_PixelmapImageInfo_GetAlphaType() 782 783``` 784Image_ErrorCode OH_PixelmapImageInfo_GetAlphaType(OH_Pixelmap_ImageInfo *info, int32_t *alphaType) 785``` 786 787**Description** 788 789Obtains the alpha type. 790 791**Since**: 12 792 793 794**Parameters** 795 796| Name| Description| 797| -- | -- | 798| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) *info | Pointer to an OH_Pixelmap_ImageInfo struct.| 799| int32_t *alphaType | Pointer to the alpha type. For details about the available options, see [PIXELMAP_ALPHA_TYPE](#pixelmap_alpha_type).| 800 801**Returns** 802 803| Type| Description| 804| -- | -- | 805| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 806 807### OH_PixelmapImageInfo_GetDynamicRange() 808 809``` 810Image_ErrorCode OH_PixelmapImageInfo_GetDynamicRange(OH_Pixelmap_ImageInfo *info, bool *isHdr) 811``` 812 813**Description** 814 815Obtains the dynamic range of a PixelMap. 816 817**Since**: 12 818 819 820**Parameters** 821 822| Name| Description| 823| -- | -- | 824| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) *info | Pointer to an OH_Pixelmap_ImageInfo struct.| 825| bool *isHdr | Pointer to a Boolean that specifies whether the HDR is used.| 826 827**Returns** 828 829| Type| Description| 830| -- | -- | 831| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 832 833### OH_PixelmapImageInfo_Release() 834 835``` 836Image_ErrorCode OH_PixelmapImageInfo_Release(OH_Pixelmap_ImageInfo *info) 837``` 838 839**Description** 840 841Releases the pointer to an OH_Pixelmap_ImageInfo struct. 842 843**Since**: 12 844 845 846**Parameters** 847 848| Name| Description| 849| -- | -- | 850| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) *info | Pointer to an OH_Pixelmap_ImageInfo struct.| 851 852**Returns** 853 854| Type| Description| 855| -- | -- | 856| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 857 858### OH_PixelmapNative_CreatePixelmap() 859 860``` 861Image_ErrorCode OH_PixelmapNative_CreatePixelmap(uint8_t *data, size_t dataLength,OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap) 862``` 863 864**Description** 865 866Creates a PixelMap based on properties. By default, the BGRA_8888 format is used for data processing. For details about other formats, see [OH_PixelmapInitializationOptions_SetSrcPixelFormat](#oh_pixelmapinitializationoptions_setsrcpixelformat). 867 868**Since**: 12 869 870 871**Parameters** 872 873| Name| Description| 874| -- | -- | 875| uint8_t *data | Pointer to the color array in BGRA_8888 format.| 876| size_t dataLength | Size of the array.| 877| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to the properties.| 878| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmap | Double pointer to the OH_PixelmapNative object created.| 879 880**Returns** 881 882| Type| Description| 883| -- | -- | 884| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_UNSUPPORTED_OPERATION**: The operation is not supported.| 885 886### OH_PixelmapNative_CreatePixelmapUsingAllocator() 887 888``` 889Image_ErrorCode OH_PixelmapNative_CreatePixelmapUsingAllocator(uint8_t *data, size_t dataLength,OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap) 890``` 891 892**Description** 893 894Creates a PixelMap object based on the options and memory type, where **allocator** specifies the memory type of the PixelMap. By default, the system selects an appropriate memory type based on the image type, image size, and platform capability. When processing the returned PixelMap object, consider the impact of stride. 895 896**Since**: 20 897 898 899**Parameters** 900 901| Name| Description| 902| -- | -- | 903| uint8_t *data | Pointer to the color array in BGRA_8888 format.| 904| size_t dataLength | Size of the array.| 905| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to the options used for creating the PixelMap.| 906| [IMAGE_ALLOCATOR_MODE](capi-image-common-h.md#image_allocator_mode) allocator | Type of memory allocation for the PixelMap.| 907| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmap | Double pointer to the OH_PixelmapNative object created.| 908 909**Returns** 910 911| Type| Description| 912| -- | -- | 913| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_UNSUPPORTED_OPERATION**: The operation is not supported.<br> **IMAGE_TOO_LARGE**: The image is too large to allocate memory.<br> **IMAGE_DMA_OPERATION_FAILED**: The DMA memory operation fails.<br> **IMAGE_ALLOCATOR_MODE_UNSUPPORTED**: The current memory allocation type is not supported, for example, creating an HDR image using shared memory.| 914 915### OH_PixelmapNative_ConvertPixelmapNativeToNapi() 916 917``` 918Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeToNapi(napi_env env, OH_PixelmapNative *pixelmapNative,napi_value *pixelmapNapi) 919``` 920 921**Description** 922 923Converts a nativePixelMap object to a PixelMapnapi object. 924 925**Since**: 12 926 927 928**Parameters** 929 930| Name| Description| 931| -- | -- | 932| napi_env env | Pointer to the NAPI environment.| 933| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmapNative | Pointer to an OH_PixelmapNative object.| 934| napi_value *pixelmapNapi | Double pointer to the PixelMapnapi object.| 935 936**Returns** 937 938| Type| Description| 939| -- | -- | 940| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: The **pixelmapNative** parameter is a null pointer.| 941 942### OH_PixelmapNative_ConvertPixelmapNativeFromNapi() 943 944``` 945Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeFromNapi(napi_env env, napi_value pixelmapNapi,OH_PixelmapNative **pixelmapNative) 946``` 947 948**Description** 949 950Converts a PixelMapnapi object to a nativePixelMap object. 951 952**Since**: 12 953 954 955**Parameters** 956 957| Name| Description| 958| -- | -- | 959| napi_env env | Pointer to the NAPI environment.| 960| napi_value pixelmapNapi | PixelMapnapi object.| 961| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmapNative | Double pointer to the OH_PixelmapNative object.| 962 963**Returns** 964 965| Type| Description| 966| -- | -- | 967| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: **pixelmapNative** is a null pointer or is not an OH_PixelmapNative object.| 968 969### OH_PixelmapNative_ReadPixels() 970 971``` 972Image_ErrorCode OH_PixelmapNative_ReadPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize) 973``` 974 975**Description** 976 977Reads the pixels of a PixelMap and writes the result to the buffer based on the pixel format of the PixelMap. 978 979**Since**: 12 980 981 982**Parameters** 983 984| Name| Description| 985| -- | -- | 986| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 987| uint8_t *destination | Pointer to the buffer to which the pixels will be written.| 988| size_t *bufferSize | Pointer to the buffer size. 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.| 989 990**Returns** 991 992| Type| Description| 993| -- | -- | 994| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_UNKNOWN_ERROR**: An unknown error occurs.| 995 996### OH_PixelmapNative_WritePixels() 997 998``` 999Image_ErrorCode OH_PixelmapNative_WritePixels(OH_PixelmapNative *pixelmap, uint8_t *source, size_t bufferSize) 1000``` 1001 1002**Description** 1003 1004Reads the pixels in the buffer and writes the result to the PixelMap based on the pixel format of the PixelMap. 1005 1006**Since**: 12 1007 1008 1009**Parameters** 1010 1011| Name| Description| 1012| -- | -- | 1013| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1014| uint8_t *source | Pointer to the buffer from which the pixels will be read.| 1015| size_t bufferSize | Buffer size.| 1016 1017**Returns** 1018 1019| Type| Description| 1020| -- | -- | 1021| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_UNSUPPORTED_OPERATION**: The operation is not supported.<br> **IMAGE_UNKNOWN_ERROR**: An unknown error occurs.| 1022 1023### OH_PixelmapNative_GetArgbPixels() 1024 1025``` 1026Image_ErrorCode OH_PixelmapNative_GetArgbPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize) 1027``` 1028 1029**Description** 1030 1031Reads data in ARGB format from a PixelMap. 1032 1033**Since**: 13 1034 1035 1036**Parameters** 1037 1038| Name| Description| 1039| -- | -- | 1040| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1041| uint8_t *destination | Pointer to the buffer to which the pixels will be written.| 1042| size_t *bufferSize | Pointer to the buffer size.| 1043 1044**Returns** 1045 1046| Type| Description| 1047| -- | -- | 1048| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> IMAGE_UNSUPPORTED_CONVERSION: The PixelMap format does not support reading ARGB data.<br> **IMAGE_ALLOC_FAILED**: Memory allocation fails.<br> **IMAGE_COPY_FAILED**: Memory data copy, read, or operation fails.| 1049 1050### OH_PixelmapNative_ToSdr() 1051 1052``` 1053Image_ErrorCode OH_PixelmapNative_ToSdr(OH_PixelmapNative *pixelmap) 1054``` 1055 1056**Description** 1057 1058Converts a PixelMap from the HDR format to the SDR format. 1059 1060**Since**: 12 1061 1062 1063**Parameters** 1064 1065| Name| Description| 1066| -- | -- | 1067| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1068 1069**Returns** 1070 1071| Type| Description| 1072| -- | -- | 1073| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_UNSUPPORTED_OPERATION**: The operation is not supported.| 1074 1075### OH_PixelmapNative_GetImageInfo() 1076 1077``` 1078Image_ErrorCode OH_PixelmapNative_GetImageInfo(OH_PixelmapNative *pixelmap, OH_Pixelmap_ImageInfo *imageInfo) 1079``` 1080 1081**Description** 1082 1083Obtains the image information of a PixelMap. 1084 1085**Since**: 12 1086 1087 1088**Parameters** 1089 1090| Name| Description| 1091| -- | -- | 1092| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1093| [OH_Pixelmap_ImageInfo](capi-image-nativemodule-oh-pixelmap-imageinfo.md) *imageInfo | Pointer to the image information.| 1094 1095**Returns** 1096 1097| Type| Description| 1098| -- | -- | 1099| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1100 1101### OH_PixelmapNative_Opacity() 1102 1103``` 1104Image_ErrorCode OH_PixelmapNative_Opacity(OH_PixelmapNative *pixelmap, float rate) 1105``` 1106 1107**Description** 1108 1109Sets the opacity rate to enable the PixelMap to achieve the corresponding opacity effect. 1110 1111**Since**: 12 1112 1113 1114**Parameters** 1115 1116| Name| Description| 1117| -- | -- | 1118| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1119| float rate | Opacity rate.| 1120 1121**Returns** 1122 1123| Type| Description| 1124| -- | -- | 1125| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1126 1127### OH_PixelmapNative_Scale() 1128 1129``` 1130Image_ErrorCode OH_PixelmapNative_Scale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY) 1131``` 1132 1133**Description** 1134 1135Scales a PixelMap based on a given width and height. 1136 1137**Since**: 12 1138 1139 1140**Parameters** 1141 1142| Name| Description| 1143| -- | -- | 1144| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1145| float scaleX | Scale ratio of the width.| 1146| float scaleY | Scale ratio of the height.| 1147 1148**Returns** 1149 1150| Type| Description| 1151| -- | -- | 1152| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1153 1154### OH_PixelmapNative_ScaleWithAntiAliasing() 1155 1156``` 1157Image_ErrorCode OH_PixelmapNative_ScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY,OH_PixelmapNative_AntiAliasingLevel level) 1158``` 1159 1160**Description** 1161 1162Scales a PixelMap based on the specified anti-aliasing level, width, and height. 1163 1164**Since**: 12 1165 1166 1167**Parameters** 1168 1169| Name| Description| 1170| -- | -- | 1171| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1172| float scaleX | Scale ratio of the width.| 1173| float scaleY | Scale ratio of the height.| 1174| [OH_PixelmapNative_AntiAliasingLevel](#oh_pixelmapnative_antialiasinglevel) level | Anti-aliasing level.| 1175 1176**Returns** 1177 1178| Type| Description| 1179| -- | -- | 1180| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_TOO_LARGE**: The image is too large.<br> **IMAGE_ALLOC_FAILED**: Memory allocation fails.<br> **IMAGE_UNKNOWN_ERROR**: The struct that **pixelmap** points to is released.| 1181 1182### OH_PixelmapNative_CreateScaledPixelMap() 1183 1184``` 1185Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMap(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap,float scaleX, float scaleY) 1186``` 1187 1188**Description** 1189 1190Creates a PixelMap that has been resized based on the specified scale factors of the width and height. 1191 1192**Since**: 16 1193 1194 1195**Parameters** 1196 1197| Name| Description| 1198| -- | -- | 1199| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *srcPixelmap | Pointer to the source PixelMap, which is an OH_PixelmapNative object.| 1200| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **dstPixelmap | Double pointer to the destination PixelMap, which is an OH_PixelmapNative object.| 1201| float scaleX | Scale ratio of the width.| 1202| float scaleY | Scale ratio of the height.| 1203 1204**Returns** 1205 1206| Type| Description| 1207| -- | -- | 1208| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1209 1210### OH_PixelmapNative_CreateScaledPixelMapWithAntiAliasing() 1211 1212``` 1213Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMapWithAntiAliasing(OH_PixelmapNative *srcPixelmap,OH_PixelmapNative **dstPixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level) 1214``` 1215 1216**Description** 1217 1218Creates a PixelMap that has been resized based on the specified anti-aliasing level and the scale factors of the width and height. 1219 1220**Since**: 16 1221 1222 1223**Parameters** 1224 1225| Name| Description| 1226| -- | -- | 1227| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *srcPixelmap | Pointer to the source PixelMap, which is an OH_PixelmapNative object.| 1228| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **dstPixelmap | Double pointer to the destination PixelMap, which is an OH_PixelmapNative object.| 1229| float scaleX | Scale ratio of the width.| 1230| float scaleY | Scale ratio of the height.| 1231| [OH_PixelmapNative_AntiAliasingLevel](#oh_pixelmapnative_antialiasinglevel) level | Anti-aliasing level.| 1232 1233**Returns** 1234 1235| Type| Description| 1236| -- | -- | 1237| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_TOO_LARGE**: The image is too large.<br> **IMAGE_ALLOC_FAILED**: Memory allocation fails.| 1238 1239### OH_PixelmapNative_Translate() 1240 1241``` 1242Image_ErrorCode OH_PixelmapNative_Translate(OH_PixelmapNative *pixelmap, float x, float y) 1243``` 1244 1245**Description** 1246 1247Translates a PixelMap based on given coordinates. 1248 1249**Since**: 12 1250 1251 1252**Parameters** 1253 1254| Name| Description| 1255| -- | -- | 1256| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1257| float x | X coordinate to translate.| 1258| float y | Y coordinate to translate.| 1259 1260**Returns** 1261 1262| Type| Description| 1263| -- | -- | 1264| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1265 1266### OH_PixelmapNative_Rotate() 1267 1268``` 1269Image_ErrorCode OH_PixelmapNative_Rotate(OH_PixelmapNative *pixelmap, float angle) 1270``` 1271 1272**Description** 1273 1274Rotates a PixelMap based on a given angle. 1275 1276**Since**: 12 1277 1278 1279**Parameters** 1280 1281| Name| Description| 1282| -- | -- | 1283| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1284| float angle | Image rotation angle, in degrees.| 1285 1286**Returns** 1287 1288| Type| Description| 1289| -- | -- | 1290| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1291 1292### OH_PixelmapNative_Flip() 1293 1294``` 1295Image_ErrorCode OH_PixelmapNative_Flip(OH_PixelmapNative *pixelmap, bool shouldFilpHorizontally, bool shouldFilpVertically) 1296``` 1297 1298**Description** 1299 1300Flips a PixelMap based on a given angle. 1301 1302**Since**: 12 1303 1304 1305**Parameters** 1306 1307| Name| Description| 1308| -- | -- | 1309| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1310| bool shouldFilpHorizontally | Whether to flip the image horizontally.| 1311| bool shouldFilpVertically | Whether to flip the image vertically.| 1312 1313**Returns** 1314 1315| Type| Description| 1316| -- | -- | 1317| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1318 1319### OH_PixelmapNative_Crop() 1320 1321``` 1322Image_ErrorCode OH_PixelmapNative_Crop(OH_PixelmapNative *pixelmap, Image_Region *region) 1323``` 1324 1325**Description** 1326 1327Crops a PixelMap based on a given size. 1328 1329**Since**: 12 1330 1331 1332**Parameters** 1333 1334| Name| Description| 1335| -- | -- | 1336| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1337| [Image_Region](capi-image-nativemodule-image-region.md) *region | Pointer to the region of the image after cropping.| 1338 1339**Returns** 1340 1341| Type| Description| 1342| -- | -- | 1343| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1344 1345### OH_PixelmapNative_Release() 1346 1347``` 1348Image_ErrorCode OH_PixelmapNative_Release(OH_PixelmapNative *pixelmap) 1349``` 1350 1351**Description** 1352 1353Releases the pointer to an OH_PixelmapNative object. [OH_PixelmapNative_Destroy](#oh_pixelmapnative_destroy) is recommended. 1354 1355**Since**: 12 1356 1357 1358**Parameters** 1359 1360| Name| Description| 1361| -- | -- | 1362| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1363 1364**Returns** 1365 1366| Type| Description| 1367| -- | -- | 1368| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1369 1370### OH_PixelmapNative_Destroy() 1371 1372``` 1373Image_ErrorCode OH_PixelmapNative_Destroy(OH_PixelmapNative **pixelmap) 1374``` 1375 1376**Description** 1377 1378Releases the pointer to an OH_PixelmapNative object. 1379 1380**Since**: 18 1381 1382 1383**Parameters** 1384 1385| Name| Description| 1386| -- | -- | 1387| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmap | Pointer to an OH_PixelmapNative object.| 1388 1389**Returns** 1390 1391| Type| Description| 1392| -- | -- | 1393| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1394 1395### OH_PixelmapNative_ConvertAlphaFormat() 1396 1397``` 1398Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixelmap,OH_PixelmapNative* dstpixelmap, const bool isPremul) 1399``` 1400 1401**Description** 1402 1403Converts pixel data of a PixelMap from premultiplied alpha to non-premultiplied alpha, or vice versa. 1404 1405**Since**: 12 1406 1407 1408**Parameters** 1409 1410| Name| Description| 1411| -- | -- | 1412| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md)* srcpixelmap | Pointer to the source PixelMap, which is an OH_PixelmapNative object.| 1413| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md)* dstpixelmap | Pointer to the destination PixelMap, which is an OH_PixelmapNative object.| 1414| const bool isPremul | Conversion mode. 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.| 1415 1416**Returns** 1417 1418| Type| Description| 1419| -- | -- | 1420| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1421 1422### OH_PixelmapNative_CreateEmptyPixelmap() 1423 1424``` 1425Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap(OH_Pixelmap_InitializationOptions *options,OH_PixelmapNative **pixelmap) 1426``` 1427 1428**Description** 1429 1430Creates an empty PixelMap object based on **OH_Pixelmap_InitializationOptions**. The memory data is 0. 1431 1432**Since**: 12 1433 1434 1435**Parameters** 1436 1437| Name| Description| 1438| -- | -- | 1439| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to the properties.| 1440| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmap | Double pointer to the OH_PixelmapNative object created.| 1441 1442**Returns** 1443 1444| Type| Description| 1445| -- | -- | 1446| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1447 1448### OH_PixelmapNative_CreateEmptyPixelmapUsingAllocator() 1449 1450``` 1451Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmapUsingAllocator(OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap) 1452``` 1453 1454**Description** 1455 1456Creates an empty PixelMap object based on the options and memory type, where **allocator** specifies the memory type of the PixelMap. By default, the system selects an appropriate memory type based on the image type, image size, and platform capability. When processing the returned PixelMap object, consider the impact of stride. 1457 1458**Since**: 20 1459 1460 1461**Parameters** 1462 1463| Name| Description| 1464| -- | -- | 1465| [OH_Pixelmap_InitializationOptions](capi-image-nativemodule-oh-pixelmap-initializationoptions.md) *options | Pointer to the options used for creating the PixelMap.| 1466| [IMAGE_ALLOCATOR_MODE](capi-image-common-h.md#image_allocator_mode) allocator | Type of memory allocation for the PixelMap.| 1467| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmap | Double pointer to the OH_PixelmapNative object created.| 1468 1469**Returns** 1470 1471| Type| Description| 1472| -- | -- | 1473| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_UNSUPPORTED_OPERATION**: The operation is not supported.<br> **IMAGE_TOO_LARGE**: The image is too large to allocate memory.<br> **IMAGE_DMA_OPERATION_FAILED**: The DMA memory operation fails.<br> **IMAGE_ALLOCATOR_MODE_UNSUPPORTED**: The current memory allocation type is not supported, for example, creating an HDR image using shared memory.| 1474 1475### OH_PixelmapNative_GetNativeBuffer() 1476 1477``` 1478Image_ErrorCode OH_PixelmapNative_GetNativeBuffer(OH_PixelmapNative *pixelmap, OH_NativeBuffer **nativeBuffer) 1479``` 1480 1481**Description** 1482 1483Obtains the NativeBuffer object from a PixelMap in the DMA memory. 1484 1485**Since**: 12 1486 1487 1488**Parameters** 1489 1490| Name| Description| 1491| -- | -- | 1492| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to the PixelMap.| 1493| [OH_NativeBuffer](capi-image-nativemodule-image-nativemodule-oh-nativebuffer.md) **nativeBuffer | Double pointer to the NativeBuffer object obtained.| 1494 1495**Returns** 1496 1497| Type| Description| 1498| -- | -- | 1499| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_DMA_NOT_EXIST**: DMA memory does not exist.<br> **IMAGE_DMA_OPERATION_FAILED**: The DMA memory operation fails.| 1500 1501### OH_PixelmapNative_GetMetadata() 1502 1503``` 1504Image_ErrorCode OH_PixelmapNative_GetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key,OH_Pixelmap_HdrMetadataValue **value) 1505``` 1506 1507**Description** 1508 1509Obtains the metadata. 1510 1511**Since**: 12 1512 1513 1514**Parameters** 1515 1516| Name| Description| 1517| -- | -- | 1518| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1519| [OH_Pixelmap_HdrMetadataKey](#oh_pixelmap_hdrmetadatakey) key | HDR metadata key.| 1520| [OH_Pixelmap_HdrMetadataValue](capi-image-nativemodule-oh-pixelmap-hdrmetadatavalue.md) **value | Double pointer to the value of the metadata key.| 1521 1522**Returns** 1523 1524| Type| Description| 1525| -- | -- | 1526| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_DMA_NOT_EXIST**: DMA memory does not exist.<br> **IMAGE_COPY_FAILED**: Memory copy fails.| 1527 1528### OH_PixelmapNative_SetMetadata() 1529 1530``` 1531Image_ErrorCode OH_PixelmapNative_SetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key,OH_Pixelmap_HdrMetadataValue *value) 1532``` 1533 1534**Description** 1535 1536Sets the metadata. 1537 1538**Since**: 12 1539 1540 1541**Parameters** 1542 1543| Name| Description| 1544| -- | -- | 1545| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1546| [OH_Pixelmap_HdrMetadataKey](#oh_pixelmap_hdrmetadatakey) key | HDR metadata key.| 1547| [OH_Pixelmap_HdrMetadataValue](capi-image-nativemodule-oh-pixelmap-hdrmetadatavalue.md) *value | Pointer to the value of the metadata key.| 1548 1549**Returns** 1550 1551| Type| Description| 1552| -- | -- | 1553| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br> **IMAGE_DMA_NOT_EXIST**: DMA memory does not exist.<br> **IMAGE_COPY_FAILED**: Memory copy fails.| 1554 1555### OH_PixelmapNative_SetColorSpaceNative() 1556 1557``` 1558Image_ErrorCode OH_PixelmapNative_SetColorSpaceNative(OH_PixelmapNative *pixelmap,OH_NativeColorSpaceManager *colorSpaceNative) 1559``` 1560 1561**Description** 1562 1563Sets a NativeColorSpaceManager object. 1564 1565**Since**: 13 1566 1567 1568**Parameters** 1569 1570| Name| Description| 1571| -- | -- | 1572| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to the target PixelMap of the NativeColorSpaceManager object.| 1573| [OH_NativeColorSpaceManager](capi-image-nativemodule-oh-nativecolorspacemanager.md) *colorSpaceNative | Pointer to a NativeColorSpaceManager object.| 1574 1575**Returns** 1576 1577| Type| Description| 1578| -- | -- | 1579| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1580 1581### OH_PixelmapNative_GetColorSpaceNative() 1582 1583``` 1584Image_ErrorCode OH_PixelmapNative_GetColorSpaceNative(OH_PixelmapNative *pixelmap,OH_NativeColorSpaceManager **colorSpaceNative) 1585``` 1586 1587**Description** 1588 1589Obtains a NativeColorSpaceManager object. 1590 1591**Since**: 13 1592 1593 1594**Parameters** 1595 1596| Name| Description| 1597| -- | -- | 1598| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to the source PixelMap of the NativeColorSpaceManager.| 1599| [OH_NativeColorSpaceManager](capi-image-nativemodule-oh-nativecolorspacemanager.md) **colorSpaceNative | Double pointer to the NativeColorSpaceManager object obtained.| 1600 1601**Returns** 1602 1603| Type| Description| 1604| -- | -- | 1605| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 1606 1607### OH_PixelmapNative_SetMemoryName() 1608 1609``` 1610Image_ErrorCode OH_PixelmapNative_SetMemoryName(OH_PixelmapNative *pixelmap, char *name, size_t *size) 1611``` 1612 1613**Description** 1614 1615Sets the memory name of a PixelMap. 1616 1617**Since**: 13 1618 1619 1620**Parameters** 1621 1622| Name| Description| 1623| -- | -- | 1624| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to an OH_PixelmapNative object.| 1625| char *name | Pointer to the memory name.| 1626| size_t *size | Pointer to the memory size (in bytes).| 1627 1628**Returns** 1629 1630| Type| Description| 1631| -- | -- | 1632| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **Image_BAD_PARAMETER**: The name contains more than 31 characters or less than 1 character.<br> **IMAGE_UNSUPPORTED_MEMORY_FORMAT**: The memory is neither DMA memory nor ASHMEM memory.| 1633 1634### OH_PixelmapNative_GetByteCount() 1635 1636``` 1637Image_ErrorCode OH_PixelmapNative_GetByteCount(OH_PixelmapNative *pixelmap, uint32_t *byteCount) 1638``` 1639 1640**Description** 1641 1642Obtains the total number of bytes occupied by all pixels in a PixelMap, excluding any memory padding. 1643 1644**Since**: 16 1645 1646 1647**Parameters** 1648 1649| Name| Description| 1650| -- | -- | 1651| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to a PixelMap.| 1652| uint32_t *byteCount | Pointer to the number of bytes obtained.| 1653 1654**Returns** 1655 1656| Type| Description| 1657| -- | -- | 1658| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **Image_BAD_PARAMETER**: The **pixelmap** or **byteCount** parameter is invalid.| 1659 1660### OH_PixelmapNative_GetAllocationByteCount() 1661 1662``` 1663Image_ErrorCode OH_PixelmapNative_GetAllocationByteCount(OH_PixelmapNative *pixelmap, uint32_t *allocationByteCount) 1664``` 1665 1666**Description** 1667 1668Obtains the number of bytes in the memory allocated by a PixelMap to store pixels. 1669 1670**Since**: 16 1671 1672 1673**Parameters** 1674 1675| Name| Description| 1676| -- | -- | 1677| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to a PixelMap.| 1678| uint32_t *allocationByteCount | Pointer to the number of bytes obtained.| 1679 1680**Returns** 1681 1682| Type| Description| 1683| -- | -- | 1684| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **Image_BAD_PARAMETER**: The **pixelmap** or **allocationByteCount** parameter is invalid.| 1685 1686### OH_PixelmapNative_AccessPixels() 1687 1688``` 1689Image_ErrorCode OH_PixelmapNative_AccessPixels(OH_PixelmapNative *pixelmap, void **addr) 1690``` 1691 1692**Description** 1693 1694Obtains the memory address where the pixels of a PixelMap are stored and locks the memory.<br>When the memory is locked, any attempts to alter or free the pixel data of the PixelMap will fail or be ineffective. 1695 1696**Since**: 15 1697 1698 1699**Parameters** 1700 1701| Name| Description| 1702| -- | -- | 1703| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to a PixelMap.| 1704| void **addr | Double pointer to the memory address.| 1705 1706**Returns** 1707 1708| Type| Description| 1709| -- | -- | 1710| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **Image_BAD_PARAMETER**: The **pixelmap** or **addr** parameter is invalid.<br> **Image_LOCK_UNLOCK_FAILED**: Memory locking fails.| 1711 1712### OH_PixelmapNative_UnaccessPixels() 1713 1714``` 1715Image_ErrorCode OH_PixelmapNative_UnaccessPixels(OH_PixelmapNative *pixelmap) 1716``` 1717 1718**Description** 1719 1720Unlocks the memory allocated to store the pixels of a PixelMap.<br>This function must be used together with [OH_PixelmapNative_AccessPixels](#oh_pixelmapnative_accesspixels). 1721 1722**Since**: 15 1723 1724 1725**Parameters** 1726 1727| Name| Description| 1728| -- | -- | 1729| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to a PixelMap.| 1730 1731**Returns** 1732 1733| Type| Description| 1734| -- | -- | 1735| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **Image_BAD_PARAMETER**: The **pixelmap** parameter is invalid.<br> **IMAGE_LOCK_UNLOCK_FAILED**: Memory unlocking fails.| 1736