• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Image
2
3
4Provides APIs for obtaining pixel map data and information.
5
6To use the APIs in this file, **libpixelmap_ndk.z.so** is required.
7
8@Syscap SystemCapability.Multimedia.Image
9
10**Since**
11
12
138
14
15
16## Summary
17
18
19### Files
20
21| Name| Description|
22| -------- | -------- |
23| [image_pixel_map_napi.h](image__pixel__map__napi_8h.md) | Declares the APIs that can lock, access, and unlock a pixel map.<br>File to include: <multimedia/image_framework/image_pixel_map_napi.h> |
24
25
26### Structs
27
28| Name| Description|
29| -------- | -------- |
30| [OhosPixelMapInfo](_ohos_pixel_map_info.md) | Defines the pixel map information.|
31
32
33### Types
34
35| Name| Description|
36| -------- | -------- |
37| { OHOS_IMAGE_RESULT_SUCCESS = 0, OHOS_IMAGE_RESULT_BAD_PARAMETER = -1 } | Enumerates the error codes returned by the functions.|
38| { OHOS_PIXEL_MAP_FORMAT_NONE = 0, OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3, OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2 } | Enumerates the pixel formats.|
39
40
41### Functions
42
43| Name| Description|
44| -------- | -------- |
45| [OH_GetImageInfo](#oh_getimageinfo) (napi_env env, napi_value value, [OhosPixelMapInfo](_ohos_pixel_map_info.md) \*info) | Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) struct.|
46| [OH_AccessPixels](#oh_accesspixels) (napi_env env, napi_value value, void \*\*addrPtr) | Obtains the memory address of a **PixelMap** object and locks the memory.|
47| [OH_UnAccessPixels](#oh_unaccesspixels) (napi_env env, napi_value value) | Unlocks the memory of a **PixelMap** object. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs.|
48
49
50## Type Description
51
52
53### anonymous enum
54
55
56```
57anonymous enum
58```
59**Description**
60
61Enumerates the error codes returned by the functions.
62
63| Value| Description|
64| -------- | -------- |
65| OHOS_IMAGE_RESULT_SUCCESS| Operation success.|
66| OHOS_IMAGE_RESULT_BAD_PARAMETER| Invalid value.|
67
68**Since**
69
708
71
72### anonymous enum
73
74
75```
76anonymous enum
77```
78**Description**
79
80Enumerates the pixel formats.
81
82| Value| Description|
83| -------- | -------- |
84| OHOS_PIXEL_MAP_FORMAT_NONE| Unknown format.|
85| OHOS_PIXEL_MAP_FORMAT_RGBA_8888| 32-bit RGBA, with 8 bits each for R (red), G (green), B (blue), and A (alpha). The data is stored from the most significant bit to the least significant bit.|
86| OHOS_PIXEL_MAP_FORMAT_RGB_565| 16-bit RGB, with 5, 6, and 5 bits for R, G, and B, respectively. The storage sequence is from the most significant bit to the least significant bit.|
87
88**Since**
89
908
91
92## anonymous enum
93
94
95### OH_AccessPixels()
96
97
98```
99int32_t OH_AccessPixels (napi_env env, napi_value value, void ** addrPtr )
100```
101**Description**
102
103Obtains the memory address of a **PixelMap** object and locks the memory.
104
105After the function is executed successfully, **\*addrPtr** is the address of the memory to be accessed. After the access operation is complete, you must use [OH_UnAccessPixels](#oh_unaccesspixels) to unlock the memory. Otherwise, the resources in the memory cannot be released. After the memory is unlocked, its address cannot be accessed or operated.
106
107**Parameters**
108
109| Name| Description|
110| -------- | -------- |
111| env | Indicates the NAPI environment pointer.|
112| value | Indicates the **PixelMap** object at the application layer.|
113| addrPtr | Indicates the double pointer to the memory address.|
114
115**See**
116
117UnAccessPixels
118
119**Returns**
120
121Returns **OHOS_IMAGE_RESULT_SUCCESS** if the operation is successful; returns an error code otherwise.
122
123**Since**
1248
125
126
127### OH_GetImageInfo()
128
129
130```
131struct OhosPixelMapCreateOps OH_GetImageInfo (napi_env env, napi_value value, OhosPixelMapInfo * info )
132```
133**Description**
134
135Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) struct.
136
137**Parameters**
138
139| Name| Description|
140| -------- | -------- |
141| env | Indicates the NAPI environment pointer.|
142| value | Indicates the **PixelMap** object at the application layer.|
143| info | Indicates the pointer to the object that stores the information obtained. For details, see [OhosPixelMapInfo](_ohos_pixel_map_info.md).|
144
145**Returns**
146
147Returns **0** if the information is obtained and stored successfully; returns an error code otherwise.
148
149**See**
150
151[OhosPixelMapInfo](_ohos_pixel_map_info.md)
152
153**Since**
154
1558
156
157### OH_UnAccessPixels()
158
159
160```
161int32_t OH_UnAccessPixels (napi_env env, napi_value value )
162```
163**Description**
164
165Unlocks the memory of a **PixelMap** object. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs.
166
167**Parameters**
168
169| Name| Description|
170| -------- | -------- |
171| env | Indicates the NAPI environment pointer.|
172| value | Indicates the **PixelMap** object at the application layer.|
173
174**Returns**
175
176Returns **OHOS_IMAGE_RESULT_SUCCESS** if the operation is successful; returns an error code otherwise.
177
178**See**
179
180AccessPixels
181
182**Since**
183
1848
185
186