1# image_pixel_map_napi.h 2 3## Overview 4 5The **image_pixel_map_napi.h** file declares the APIs used to lock, access, and unlock a PixelMap. 6 7**Library**: libpixelmap_ndk.so 8 9**File to include**: <multimedia/image_framework/image_pixel_map_napi.h> 10 11**Since**: 8 12 13**Related module**: [Image](capi-image.md) 14 15## Summary 16 17### Structs 18 19| Name| typedef Keyword| Description| 20| -- | -- | -- | 21| [OhosPixelMapInfo](capi-image-ohospixelmapinfo.md) | - | Describes the information about a PixelMap.| 22 23### Enums 24 25| Name| Description| 26| -- | -- | 27| [Error Codes Returned by Functions](#error-codes-returned-by-functions)| Enumerates the error codes returned by the functions.| 28| [Pixel Formats](#pixel-formats)| Enumerates the pixel formats.| 29| [anonymous enum](#pixelmap-scale-modes)| Enumerates the PixelMap scale modes.| 30 31### Functions 32 33| Name| Description| 34| -- | -- | 35| [int32_t OH_GetImageInfo(napi_env env, napi_value value, OhosPixelMapInfo *info)](#oh_getimageinfo) | Obtains the information about a PixelMap object and stores the information to the [OhosPixelMapInfo](capi-image-ohospixelmapinfo.md) struct.| 36| [int32_t OH_AccessPixels(napi_env env, napi_value value, void** addrPtr)](#oh_accesspixels) | Obtains the memory address of a PixelMap object and locks the memory.<br>**\*addrPtr** is the memory address obtained. After finishing the access, you must use [OH_UnAccessPixels](#oh_unaccesspixels) to unlock the memory. Then the memory cannot be accessed or operated.| 37| [int32_t OH_UnAccessPixels(napi_env env, napi_value value)](#oh_unaccesspixels) | Unlocks the memory of a PixelMap object. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs.| 38 39## Enum Description 40 41### Error Codes Returned by Functions 42 43``` 44enum anonymous enum 45``` 46 47**Description** 48 49Enumerates the error codes returned by the functions. 50 51**Since**: 8 52 53**Deprecated from**: 10 54 55| Enum Item| Description| 56| -- | -- | 57| OHOS_IMAGE_RESULT_SUCCESS = 0 | Operation success.| 58| OHOS_IMAGE_RESULT_BAD_PARAMETER = -1 | Invalid value.| 59 60### Pixel Formats 61 62``` 63enum anonymous enum 64``` 65 66**Description** 67 68Enumerates the pixel formats. 69 70**Since**: 8 71 72**Deprecated from**: 10 73 74| Enum Item| Description| 75| -- | -- | 76| OHOS_PIXEL_MAP_FORMAT_NONE = 0 | Unknown format.| 77| OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3 | RGBA_8888 format.| 78| OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2 | RGB_565 format.| 79 80### PixelMap Scale Modes 81 82``` 83enum anonymous enum 84``` 85 86**Description** 87 88Enumerates the PixelMap scale modes. 89 90**Since**: 10 91 92| Enum Item| Description| 93| -- | -- | 94| OHOS_PIXEL_MAP_SCALE_MODE_FIT_TARGET_SIZE = 0 | Adapting to the target image size.| 95| OHOS_PIXEL_MAP_SCALE_MODE_CENTER_CROP = 1 | Cropping the center portion of an image to the target size.| 96 97 98## Function Description 99 100### OH_GetImageInfo() 101 102``` 103int32_t OH_GetImageInfo(napi_env env, napi_value value, OhosPixelMapInfo *info) 104``` 105 106**Description** 107 108Obtains the information about a PixelMap object and stores the information to the [OhosPixelMapInfo](capi-image-ohospixelmapinfo.md) struct. 109 110**Since**: 8 111 112**Deprecated from**: 10 113 114 115**Parameters** 116 117| Name| Description| 118| -- | -- | 119| napi_env env | Pointer to the NAPI environment.| 120| napi_value value | PixelMap object at the application layer.| 121| [OhosPixelMapInfo](capi-image-ohospixelmapinfo.md) *info | Pointer to the object that stores the information obtained.| 122 123**Returns** 124 125| Type| Description| 126| -- | -- | 127| int32_t | One of the following [error codes](#error-codes-returned-by-functions):<br>**OHOS_IMAGE_RESULT_SUCCESS**: The operation is successful.<br>**OHOS_IMAGE_RESULT_BAD_PARAMETER**: The operation fails.| 128 129### OH_AccessPixels() 130 131``` 132int32_t OH_AccessPixels(napi_env env, napi_value value, void** addrPtr) 133``` 134 135**Description** 136 137Obtains the memory address of a PixelMap object and locks the memory. 138 139**\*addrPtr** is the memory address obtained. After finishing the access, you must use [OH_UnAccessPixels](#oh_unaccesspixels) to unlock the memory. Then the memory cannot be accessed or operated. 140 141**Since**: 8 142 143**Deprecated from**: 10 144 145 146**Parameters** 147 148| Name| Description| 149| -- | -- | 150| napi_env env | Pointer to the NAPI environment.| 151| napi_value value | PixelMap object at the application layer.| 152| void** addrPtr | Double pointer to the memory address.| 153 154**Returns** 155 156| Type| Description| 157| -- | -- | 158| int32_t | One of the following [error codes](#error-codes-returned-by-functions):<br>**OHOS_IMAGE_RESULT_SUCCESS**: The operation is successful.<br>**OHOS_IMAGE_RESULT_BAD_PARAMETER**: The operation fails.| 159 160### OH_UnAccessPixels() 161 162``` 163int32_t OH_UnAccessPixels(napi_env env, napi_value value) 164``` 165 166**Description** 167 168Unlocks the memory of a PixelMap object. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs. 169 170**Since**: 8 171 172**Deprecated from**: 10 173 174 175**Parameters** 176 177| Name| Description| 178| -- | -- | 179| napi_env env | Pointer to the NAPI environment.| 180| napi_value value | PixelMap object at the application layer.| 181 182**Returns** 183 184| Type| Description| 185| -- | -- | 186| int32_t | One of the following [error codes](#error-codes-returned-by-functions):<br>**OHOS_IMAGE_RESULT_SUCCESS**: The operation is successful.<br>**OHOS_IMAGE_RESULT_BAD_PARAMETER**: The operation fails.| 187