image.md 17.3 KB
Newer Older
Z
zengyawen 已提交
1
# Image
Z
zengyawen 已提交
2 3 4 5


Provides APIs for obtaining pixel map data and information.

G
Gloria 已提交
6 7 8 9 10
To use the APIs in this file, **libpixelmap_ndk.z.so** is required.

@Syscap SystemCapability.Multimedia.Image

**Since**
Z
zengyawen 已提交
11 12 13 14 15 16 17 18 19

8


## Summary


### Files

G
Gloria 已提交
20
| Name| Description|
Z
zengyawen 已提交
21
| -------- | -------- |
G
Gloria 已提交
22
| [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>|
Z
zengyawen 已提交
23 24 25 26


### Structs

G
Gloria 已提交
27
| Name| Description|
Z
zengyawen 已提交
28
| -------- | -------- |
G
Gloria 已提交
29 30
| [OhosPixelMapInfo](_ohos_pixel_map_info.md) | Defines the pixel map information.|
| [OhosPixelMapCreateOps](_ohos_pixel_map_create_ops.md) | Defines the options used for creating a pixel map.|
Z
zengyawen 已提交
31 32 33 34


### Types

G
Gloria 已提交
35
| Name| Description|
Z
zengyawen 已提交
36
| -------- | -------- |
G
Gloria 已提交
37
| [NativePixelMap](#nativepixelmap) | Defines the data type name of the native pixel map.|
Z
zengyawen 已提交
38 39 40 41


### Enums

G
Gloria 已提交
42
| Name| Description|
Z
zengyawen 已提交
43
| -------- | -------- |
G
Gloria 已提交
44 45 46 47 48
| { OHOS_IMAGE_RESULT_SUCCESS = 0, OHOS_IMAGE_RESULT_BAD_PARAMETER = -1 } | Enumerates the error codes returned by the functions.|
| { OHOS_PIXEL_MAP_FORMAT_NONE = 0, OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3, OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2 } | Enumerates the pixel formats.|
| { OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN = 0, OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE = 1, OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL = 2, OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL = 3 } | Enumerates the pixel map alpha types.|
| { OHOS_PIXEL_MAP_SCALE_MODE_FIT_TARGET_SIZE = 0, OHOS_PIXEL_MAP_SCALE_MODE_CENTER_CROP = 1 } | Enumerates the pixel map scale modes.|
| { OHOS_PIXEL_MAP_READ_ONLY = 0, OHOS_PIXEL_MAP_EDITABLE = 1 } | Enumerates the pixel map editing types.|
Z
zengyawen 已提交
49 50 51 52


### Functions

G
Gloria 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| Name| Description|
| -------- | -------- |
| [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.|
| [OH_AccessPixels](#oh_accesspixels) (napi_env env, napi_value value, void \*\*addrPtr) | Obtains the memory address of a **PixelMap** object and locks the memory.|
| [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.|
| [OH_PixelMap_CreatePixelMap](#oh_pixelmap_createpixelmap) (napi_env env, [OhosPixelMapCreateOps](_ohos_pixel_map_create_ops.md) info, void \*buf, size_t len, napi_value \*res) | Creates a **PixelMap** object.|
| [OH_PixelMap_CreateAlphaPixelMap](#oh_pixelmap_createalphapixelmap) (napi_env env, napi_value source, napi_value \*alpha) | Creates a **PixelMap** object that contains only alpha channel information.|
| [OH_PixelMap_InitNativePixelMap](#oh_pixelmap_initnativepixelmap) (napi_env env, napi_value source) | Initializes a **PixelMap** object.|
| [OH_PixelMap_GetBytesNumberPerRow](#oh_pixelmap_getbytesnumberperrow) (const [NativePixelMap](#nativepixelmap) \*native, int32_t \*num) | Obtains the number of bytes per row of a **PixelMap** object.|
| [OH_PixelMap_GetIsEditable](#oh_pixelmap_getiseditable) (const [NativePixelMap](#nativepixelmap) \*native, int32_t \*[editable](image__pixel__map__napi_8h.md#editable)) | Checks whether a **PixelMap** object is editable.|
| [OH_PixelMap_IsSupportAlpha](#oh_pixelmap_issupportalpha) (const [NativePixelMap](#nativepixelmap) \*native, int32_t \*alpha) | Checks whether a **PixelMap** object supports alpha channels.|
| [OH_PixelMap_SetAlphaAble](#oh_pixelmap_setalphaable) (const [NativePixelMap](#nativepixelmap) \*native, int32_t alpha) | Sets an alpha channel for a **PixelMap** object.|
| [OH_PixelMap_GetDensity](#oh_pixelmap_getdensity) (const [NativePixelMap](#nativepixelmap) \*native, int32_t \*density) | Obtains the pixel density of a **PixelMap** object.|
| [OH_PixelMap_SetDensity](#oh_pixelmap_setdensity) (const [NativePixelMap](#nativepixelmap) \*native, int32_t density) | Sets the pixel density for a **PixelMap** object.|
| [OH_PixelMap_SetOpacity](#oh_pixelmap_setopacity) (const [NativePixelMap](#nativepixelmap) \*native, float opacity) | Sets the opacity for a **PixelMap** object.|
| [OH_PixelMap_Scale](#oh_pixelmap_scale) (const [NativePixelMap](#nativepixelmap) \*native, float x, float y) | Scales a **PixelMap** object.|
| [OH_PixelMap_Translate](#oh_pixelmap_translate) (const [NativePixelMap](#nativepixelmap) \*native, float x, float y) | Translates a **PixelMap** object.|
| [OH_PixelMap_Rotate](#oh_pixelmap_rotate) (const [NativePixelMap](#nativepixelmap) \*native, float angle) | Rotates a **PixelMap** object.|
| [OH_PixelMap_Flip](#oh_pixelmap_flip) (const [NativePixelMap](#nativepixelmap) \*native, int32_t x, int32_t y) | Flips a **PixelMap** object.|
| [OH_PixelMap_Crop](#oh_pixelmap_crop) (const [NativePixelMap](#nativepixelmap) \*native, int32_t x, int32_t y, int32_t [width](image__pixel__map__napi_8h.md#width), int32_t [height](image__pixel__map__napi_8h.md#height)) | Crops a **PixelMap** object.|

Z
zengyawen 已提交
74 75 76 77 78

## Type Description


### NativePixelMap
Z
zengyawen 已提交
79

G
Gloria 已提交
80

Z
zengyawen 已提交
81
```
G
Gloria 已提交
82
typedef struct NativePixelMap
Z
zengyawen 已提交
83
```
G
Gloria 已提交
84 85
**Description**

Z
zengyawen 已提交
86
Defines the data type name of the native pixel map.
Z
zengyawen 已提交
87

G
Gloria 已提交
88 89 90 91 92
**Since**

9


Z
zengyawen 已提交
93 94 95 96 97
## Enum Description


### anonymous enum

G
Gloria 已提交
98

Z
zengyawen 已提交
99 100 101
```
anonymous enum
```
G
Gloria 已提交
102 103 104
**Description**

Enumerates the error codes returned by the functions.
Z
zengyawen 已提交
105

G
Gloria 已提交
106
| Value| Description|
Z
zengyawen 已提交
107
| -------- | -------- |
G
Gloria 已提交
108 109
| OHOS_IMAGE_RESULT_SUCCESS| Operation success.|
| OHOS_IMAGE_RESULT_BAD_PARAMETER| Invalid value.|
Z
zengyawen 已提交
110

G
Gloria 已提交
111 112 113
**Since**

8
Z
zengyawen 已提交
114 115 116

### anonymous enum

G
Gloria 已提交
117

Z
zengyawen 已提交
118 119 120
```
anonymous enum
```
G
Gloria 已提交
121 122
**Description**

Z
zengyawen 已提交
123 124
Enumerates the pixel formats.

G
Gloria 已提交
125
| Value| Description|
Z
zengyawen 已提交
126
| -------- | -------- |
G
Gloria 已提交
127 128 129 130 131 132 133
| OHOS_PIXEL_MAP_FORMAT_NONE| Unknown format.|
| 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.|
| 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.|

**Since**

8
Z
zengyawen 已提交
134

Z
zengyawen 已提交
135 136
### anonymous enum

G
Gloria 已提交
137

Z
zengyawen 已提交
138 139 140
```
anonymous enum
```
G
Gloria 已提交
141 142
**Description**

Z
zengyawen 已提交
143 144
Enumerates the pixel map alpha types.

G
Gloria 已提交
145
| Value| Description|
Z
zengyawen 已提交
146
| -------- | -------- |
G
Gloria 已提交
147 148 149 150 151 152
| OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN| Unknown format.|
| OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE| Opaque format.|
| OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL| Premultiplied format.|
| OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL| Unpremultiplied format.|

**Since**
Z
zengyawen 已提交
153

G
Gloria 已提交
154
9
Z
zengyawen 已提交
155 156 157

### anonymous enum

G
Gloria 已提交
158

Z
zengyawen 已提交
159 160 161
```
anonymous enum
```
G
Gloria 已提交
162 163
**Description**

Z
zengyawen 已提交
164 165
Enumerates the pixel map scale modes.

G
Gloria 已提交
166
| Value| Description|
Z
zengyawen 已提交
167
| -------- | -------- |
G
Gloria 已提交
168 169 170 171 172 173
| OHOS_PIXEL_MAP_SCALE_MODE_FIT_TARGET_SIZE| Adaptation to the target image size.|
| OHOS_PIXEL_MAP_SCALE_MODE_CENTER_CROP| Cropping the center portion of an image to the target size.|

**Since**

9
Z
zengyawen 已提交
174 175 176 177


### anonymous enum

G
Gloria 已提交
178

Z
zengyawen 已提交
179 180 181
```
anonymous enum
```
G
Gloria 已提交
182 183
**Description**

Z
zengyawen 已提交
184 185
Enumerates the pixel map editing types.

G
Gloria 已提交
186
| Value| Description|
Z
zengyawen 已提交
187
| -------- | -------- |
G
Gloria 已提交
188 189 190 191 192 193
| OHOS_PIXEL_MAP_READ_ONLY| Read-only.|
| OHOS_PIXEL_MAP_EDITABLE| Editable.|

**Since**

9
Z
zengyawen 已提交
194

Z
zengyawen 已提交
195 196 197 198 199 200

## Function Description


### OH_AccessPixels()

G
Gloria 已提交
201

Z
zengyawen 已提交
202 203 204
```
int32_t OH_AccessPixels (napi_env env, napi_value value, void ** addrPtr )
```
G
Gloria 已提交
205 206 207
**Description**

Obtains the memory address of a **PixelMap** object and locks the memory.
Z
zengyawen 已提交
208

G
Gloria 已提交
209
After 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.
Z
zengyawen 已提交
210

G
Gloria 已提交
211
**Parameters**
Z
zengyawen 已提交
212

G
Gloria 已提交
213
| Name| Description|
Z
zengyawen 已提交
214
| -------- | -------- |
G
Gloria 已提交
215 216 217
| env | Indicates the NAPI environment pointer.|
| value | Indicates the **PixelMap** object at the application layer.|
| addrPtr | Indicates the double pointer to the memory address.|
Z
zengyawen 已提交
218

G
Gloria 已提交
219
**See**
Z
zengyawen 已提交
220 221 222 223 224

UnAccessPixels

**Returns**

G
Gloria 已提交
225 226 227 228
Returns **OHOS_IMAGE_RESULT_SUCCESS** if the operation is successful; returns an error code otherwise.

**Since**
8
Z
zengyawen 已提交
229 230 231 232


### OH_GetImageInfo()

G
Gloria 已提交
233

Z
zengyawen 已提交
234
```
G
Gloria 已提交
235
struct OhosPixelMapCreateOps OH_GetImageInfo (napi_env env, napi_value value, OhosPixelMapInfo * info )
Z
zengyawen 已提交
236
```
G
Gloria 已提交
237 238 239
**Description**

Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) struct.
Z
zengyawen 已提交
240

G
Gloria 已提交
241
**Parameters**
Z
zengyawen 已提交
242

G
Gloria 已提交
243
| Name| Description|
Z
zengyawen 已提交
244
| -------- | -------- |
G
Gloria 已提交
245 246 247
| env | Indicates the NAPI environment pointer.|
| value | Indicates the **PixelMap** object at the application layer.|
| info | Indicates the pointer to the object that stores the information obtained. For details, see [OhosPixelMapInfo](_ohos_pixel_map_info.md).|
Z
zengyawen 已提交
248 249 250 251 252

**Returns**

Returns **0** if the information is obtained and stored successfully; returns an error code otherwise.

G
Gloria 已提交
253
**See**
Z
zengyawen 已提交
254 255 256

[OhosPixelMapInfo](_ohos_pixel_map_info.md)

G
Gloria 已提交
257
**Since**
Z
zengyawen 已提交
258

G
Gloria 已提交
259
8
Z
zengyawen 已提交
260

Z
zengyawen 已提交
261 262 263

### OH_PixelMap_CreateAlphaPixelMap()

G
Gloria 已提交
264

Z
zengyawen 已提交
265 266 267
```
int32_t OH_PixelMap_CreateAlphaPixelMap (napi_env env, napi_value source, napi_value * alpha )
```
G
Gloria 已提交
268 269
**Description**

Z
zengyawen 已提交
270 271
Creates a **PixelMap** object that contains only alpha channel information.

G
Gloria 已提交
272
**Parameters**
Z
zengyawen 已提交
273

G
Gloria 已提交
274
| Name| Description|
Z
zengyawen 已提交
275
| -------- | -------- |
G
Gloria 已提交
276 277 278
| env | Indicates the NAPI environment pointer.|
| source | Indicates the options for setting the **PixelMap** object.|
| alpha | Indicates the pointer to the alpha channel.|
Z
zengyawen 已提交
279 280 281 282 283

**Returns**

Returns a **PixelMap** object if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
284
**See**
Z
zengyawen 已提交
285 286 287

CreateAlphaPixelMap

G
Gloria 已提交
288 289 290 291
**Since**

9

Z
zengyawen 已提交
292 293 294

### OH_PixelMap_CreatePixelMap()

G
Gloria 已提交
295

Z
zengyawen 已提交
296 297 298
```
int32_t OH_PixelMap_CreatePixelMap (napi_env env, OhosPixelMapCreateOps info, void * buf, size_t len, napi_value * res )
```
G
Gloria 已提交
299 300
**Description**

Z
zengyawen 已提交
301 302
Creates a **PixelMap** object.

G
Gloria 已提交
303
**Parameters**
Z
zengyawen 已提交
304

G
Gloria 已提交
305
| Name| Description|
Z
zengyawen 已提交
306
| -------- | -------- |
G
Gloria 已提交
307 308 309 310 311
| env | Indicates the NAPI environment pointer.|
| info | Indicates the options for setting the **PixelMap** object.|
| buf | Indicates the pointer to the buffer of the image.|
| len | Indicates the image size.|
| res | Indicates the pointer to the **PixelMap** object at the application layer.|
Z
zengyawen 已提交
312 313 314 315 316

**Returns**

Returns a **PixelMap** object if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
317
**See**
Z
zengyawen 已提交
318 319 320

CreatePixelMap

G
Gloria 已提交
321 322 323 324
**Since**

9

Z
zengyawen 已提交
325 326 327

### OH_PixelMap_Crop()

G
Gloria 已提交
328

Z
zengyawen 已提交
329 330 331
```
int32_t OH_PixelMap_Crop (const NativePixelMap * native, int32_t x, int32_t y, int32_t width, int32_t height )
```
G
Gloria 已提交
332 333
**Description**

Z
zengyawen 已提交
334 335
Crops a **PixelMap** object.

G
Gloria 已提交
336
**Parameters**
Z
zengyawen 已提交
337

G
Gloria 已提交
338
| Name| Description|
Z
zengyawen 已提交
339
| -------- | -------- |
G
Gloria 已提交
340 341 342 343 344
| native | Indicates the pointer to a **NativePixelMap** object.|
| x | Indicates the x-coordinate of the upper left corner of the target image.|
| y | Indicates the y-coordinate of the upper left corner of the target image.|
| width | Indicates the width of the cropped region.|
| height | Indicates the height of the cropped region.|
Z
zengyawen 已提交
345 346 347 348 349

**Returns**

Returns **0** if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
350
**See**
Z
zengyawen 已提交
351 352 353

Crop

G
Gloria 已提交
354 355 356 357
**Since**

9

Z
zengyawen 已提交
358 359 360

### OH_PixelMap_Flip()

G
Gloria 已提交
361

Z
zengyawen 已提交
362 363 364
```
int32_t OH_PixelMap_Flip (const NativePixelMap * native, int32_t x, int32_t y )
```
G
Gloria 已提交
365 366
**Description**

Z
zengyawen 已提交
367 368
Flips a **PixelMap** object.

G
Gloria 已提交
369
**Parameters**
Z
zengyawen 已提交
370

G
Gloria 已提交
371
| Name| Description|
Z
zengyawen 已提交
372
| -------- | -------- |
G
Gloria 已提交
373 374 375
| native | Indicates the pointer to a **NativePixelMap** object.|
| x | Specifies whether to flip around the x axis.|
| y | Specifies whether to flip around the y axis.|
Z
zengyawen 已提交
376 377 378 379 380

**Returns**

Returns **0** if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
381
**See**
Z
zengyawen 已提交
382 383 384

Flip

G
Gloria 已提交
385 386 387 388
**Since**

9

Z
zengyawen 已提交
389 390 391

### OH_PixelMap_GetBytesNumberPerRow()

G
Gloria 已提交
392

Z
zengyawen 已提交
393 394 395
```
int32_t OH_PixelMap_GetBytesNumberPerRow (const NativePixelMap * native, int32_t * num )
```
G
Gloria 已提交
396 397
**Description**

Z
zengyawen 已提交
398 399
Obtains the number of bytes per row of a **PixelMap** object.

G
Gloria 已提交
400
**Parameters**
Z
zengyawen 已提交
401

G
Gloria 已提交
402
| Name| Description|
Z
zengyawen 已提交
403
| -------- | -------- |
G
Gloria 已提交
404 405
| native | Indicates the pointer to a **NativePixelMap** object.|
| num | Indicates the pointer to the number of bytes per row of the **PixelMap** object.|
Z
zengyawen 已提交
406 407 408 409 410

**Returns**

Returns the number of bytes per row of the **PixelMap** object if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
411
**See**
Z
zengyawen 已提交
412 413 414

GetBytesNumberPerRow

G
Gloria 已提交
415 416 417
**Since**

9
Z
zengyawen 已提交
418 419 420

### OH_PixelMap_GetDensity()

G
Gloria 已提交
421

Z
zengyawen 已提交
422 423 424
```
int32_t OH_PixelMap_GetDensity (const NativePixelMap * native, int32_t * density )
```
G
Gloria 已提交
425 426
**Description**

Z
zengyawen 已提交
427 428
Obtains the pixel density of a **PixelMap** object.

G
Gloria 已提交
429
**Parameters**
Z
zengyawen 已提交
430

G
Gloria 已提交
431
| Name| Description|
Z
zengyawen 已提交
432
| -------- | -------- |
G
Gloria 已提交
433 434
| native | Indicates the pointer to a **NativePixelMap** object.|
| density | Indicates the pointer to the pixel density.|
Z
zengyawen 已提交
435 436 437 438 439

**Returns**

Returns the pixel density if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
440
**See**
Z
zengyawen 已提交
441 442 443

GetDensity

G
Gloria 已提交
444
**Since**
Z
zengyawen 已提交
445

G
Gloria 已提交
446
9
Z
zengyawen 已提交
447 448 449 450


### OH_PixelMap_GetIsEditable()

G
Gloria 已提交
451

Z
zengyawen 已提交
452 453 454
```
int32_t OH_PixelMap_GetIsEditable (const NativePixelMap * native, int32_t * editable )
```
G
Gloria 已提交
455 456
**Description**

Z
zengyawen 已提交
457 458
Checks whether a **PixelMap** object is editable.

G
Gloria 已提交
459
**Parameters**
Z
zengyawen 已提交
460

G
Gloria 已提交
461
| Name| Description|
Z
zengyawen 已提交
462
| -------- | -------- |
G
Gloria 已提交
463 464
| native | Indicates the pointer to a **NativePixelMap** object.|
| editable | Indicates the pointer to the editing type of the **PixelMap** object.|
Z
zengyawen 已提交
465 466 467 468 469

**Returns**

Returns an enumerated value that indicates the editing type of the **PixelMap** object if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
470
**See**
Z
zengyawen 已提交
471 472 473

GetIsEditable

G
Gloria 已提交
474 475 476 477
**Since**

9

Z
zengyawen 已提交
478 479 480

### OH_PixelMap_InitNativePixelMap()

G
Gloria 已提交
481

Z
zengyawen 已提交
482 483 484
```
NativePixelMap* OH_PixelMap_InitNativePixelMap (napi_env env, napi_value source )
```
G
Gloria 已提交
485 486
**Description**

Z
zengyawen 已提交
487 488
Initializes a **PixelMap** object.

G
Gloria 已提交
489
**Parameters**
Z
zengyawen 已提交
490

G
Gloria 已提交
491
| Name| Description|
Z
zengyawen 已提交
492
| -------- | -------- |
G
Gloria 已提交
493 494
| env | Indicates the NAPI environment pointer.|
| source | Indicates the options for setting the **PixelMap** object.|
Z
zengyawen 已提交
495 496 497 498 499

**Returns**

Returns a pointer to the **NativePixelMap** object if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
500
**See**
Z
zengyawen 已提交
501 502 503

InitNativePixelMap

G
Gloria 已提交
504 505 506 507
**Since**

9

Z
zengyawen 已提交
508 509 510

### OH_PixelMap_IsSupportAlpha()

G
Gloria 已提交
511

Z
zengyawen 已提交
512 513 514
```
int32_t OH_PixelMap_IsSupportAlpha (const NativePixelMap * native, int32_t * alpha )
```
G
Gloria 已提交
515 516
**Description**

Z
zengyawen 已提交
517 518
Checks whether a **PixelMap** object supports alpha channels.

G
Gloria 已提交
519
**Parameters**
Z
zengyawen 已提交
520

G
Gloria 已提交
521
| Name| Description|
Z
zengyawen 已提交
522
| -------- | -------- |
G
Gloria 已提交
523 524
| native | Indicates the pointer to a **NativePixelMap** object.|
| alpha | Indicates the pointer to the support for alpha channels.|
Z
zengyawen 已提交
525 526 527 528 529

**Returns**

Returns **0** if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
530
**See**
Z
zengyawen 已提交
531 532 533

IsSupportAlpha

G
Gloria 已提交
534 535 536 537 538
**Since**

9


Z
zengyawen 已提交
539 540 541

### OH_PixelMap_Rotate()

G
Gloria 已提交
542

Z
zengyawen 已提交
543 544 545
```
int32_t OH_PixelMap_Rotate (const NativePixelMap * native, float angle )
```
G
Gloria 已提交
546 547
**Description**

Z
zengyawen 已提交
548 549
Rotates a **PixelMap** object.

G
Gloria 已提交
550
**Parameters**
Z
zengyawen 已提交
551

G
Gloria 已提交
552
| Name| Description|
Z
zengyawen 已提交
553
| -------- | -------- |
G
Gloria 已提交
554 555
| native | Indicates the pointer to a **NativePixelMap** object.|
| angle | Indicates the angle to rotate.|
Z
zengyawen 已提交
556 557 558 559 560

**Returns**

Returns **0** if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
561
**See**
Z
zengyawen 已提交
562 563 564

Rotate

G
Gloria 已提交
565 566 567 568
**Since**

9

Z
zengyawen 已提交
569 570 571

### OH_PixelMap_Scale()

G
Gloria 已提交
572

Z
zengyawen 已提交
573 574 575
```
int32_t OH_PixelMap_Scale (const NativePixelMap * native, float x, float y )
```
G
Gloria 已提交
576 577
**Description**

Z
zengyawen 已提交
578 579
Scales a **PixelMap** object.

G
Gloria 已提交
580
**Parameters**
Z
zengyawen 已提交
581

G
Gloria 已提交
582
| Name| Description|
Z
zengyawen 已提交
583
| -------- | -------- |
G
Gloria 已提交
584 585 586
| native | Indicates the pointer to a **NativePixelMap** object.|
| x | Indicates the scaling ratio of the width.|
| y | Indicates the scaling ratio of the height.|
Z
zengyawen 已提交
587 588 589 590 591

**Returns**

Returns **0** if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
592
**See**
Z
zengyawen 已提交
593 594 595

Scale

G
Gloria 已提交
596 597 598 599
**Since**

9

Z
zengyawen 已提交
600 601 602

### OH_PixelMap_SetAlphaAble()

G
Gloria 已提交
603

Z
zengyawen 已提交
604 605 606
```
int32_t OH_PixelMap_SetAlphaAble (const NativePixelMap * native, int32_t alpha )
```
G
Gloria 已提交
607 608
**Description**

Z
zengyawen 已提交
609 610
Sets an alpha channel for a **PixelMap** object.

G
Gloria 已提交
611
**Parameters**
Z
zengyawen 已提交
612

G
Gloria 已提交
613
| Name| Description|
Z
zengyawen 已提交
614
| -------- | -------- |
G
Gloria 已提交
615 616
| native | Indicates the pointer to a **NativePixelMap** object.|
| alpha | Indicates the alpha channel to set.|
Z
zengyawen 已提交
617 618 619 620 621

**Returns**

Returns **0** if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
622
**See**
Z
zengyawen 已提交
623 624 625

SetAlphaAble

G
Gloria 已提交
626 627 628 629
**Since**

9

Z
zengyawen 已提交
630 631 632

### OH_PixelMap_SetDensity()

G
Gloria 已提交
633

Z
zengyawen 已提交
634 635 636
```
int32_t OH_PixelMap_SetDensity (const NativePixelMap * native, int32_t density )
```
G
Gloria 已提交
637 638
**Description**

Z
zengyawen 已提交
639 640
Sets the pixel density for a **PixelMap** object.

G
Gloria 已提交
641
**Parameters**
Z
zengyawen 已提交
642

G
Gloria 已提交
643
| Name| Description|
Z
zengyawen 已提交
644
| -------- | -------- |
G
Gloria 已提交
645 646
| native | Indicates the pointer to a **NativePixelMap** object.|
| density | Indicates the pixel density to set.|
Z
zengyawen 已提交
647 648 649 650 651

**Returns**

Returns **0** if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
652
**See**
Z
zengyawen 已提交
653 654 655

GetDensity

G
Gloria 已提交
656 657 658 659
**Since**

9

Z
zengyawen 已提交
660 661 662

### OH_PixelMap_SetOpacity()

G
Gloria 已提交
663

Z
zengyawen 已提交
664 665 666
```
int32_t OH_PixelMap_SetOpacity (const NativePixelMap * native, float opacity )
```
G
Gloria 已提交
667 668
**Description**

Z
zengyawen 已提交
669 670
Sets the opacity for a **PixelMap** object.

G
Gloria 已提交
671
**Parameters**
Z
zengyawen 已提交
672

G
Gloria 已提交
673
| Name| Description|
Z
zengyawen 已提交
674
| -------- | -------- |
G
Gloria 已提交
675 676
| native | Indicates the pointer to a **NativePixelMap** object.|
| opacity | Indicates the opacity to set.|
Z
zengyawen 已提交
677 678 679 680 681

**Returns**

Returns **0** if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
682
**See**
Z
zengyawen 已提交
683 684 685

SetOpacity

G
Gloria 已提交
686 687 688 689
**Since**

9

Z
zengyawen 已提交
690 691 692

### OH_PixelMap_Translate()

G
Gloria 已提交
693

Z
zengyawen 已提交
694 695 696
```
int32_t OH_PixelMap_Translate (const NativePixelMap * native, float x, float y )
```
G
Gloria 已提交
697 698
**Description**

Z
zengyawen 已提交
699 700
Translates a **PixelMap** object.

G
Gloria 已提交
701
**Parameters**
Z
zengyawen 已提交
702

G
Gloria 已提交
703
| Name| Description|
Z
zengyawen 已提交
704
| -------- | -------- |
G
Gloria 已提交
705 706 707
| native | Indicates the pointer to a **NativePixelMap** object.|
| x | Indicates the horizontal distance to translate.|
| y | Indicates the vertical distance to translate.|
Z
zengyawen 已提交
708 709 710 711 712

**Returns**

Returns **0** if the operation is successful; returns an error code otherwise.

G
Gloria 已提交
713
**See**
Z
zengyawen 已提交
714 715 716

Translate

G
Gloria 已提交
717
**Since**
Z
zengyawen 已提交
718

G
Gloria 已提交
719
9
720 721


Z
zengyawen 已提交
722 723
### OH_UnAccessPixels()

G
Gloria 已提交
724

Z
zengyawen 已提交
725 726 727
```
int32_t OH_UnAccessPixels (napi_env env, napi_value value )
```
G
Gloria 已提交
728 729
**Description**

Z
zengyawen 已提交
730 731
Unlocks the memory of a **PixelMap** object. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs.

G
Gloria 已提交
732
**Parameters**
Z
zengyawen 已提交
733

G
Gloria 已提交
734
| Name| Description|
Z
zengyawen 已提交
735
| -------- | -------- |
G
Gloria 已提交
736 737
| env | Indicates the NAPI environment pointer.|
| value | Indicates the **PixelMap** object at the application layer.|
Z
zengyawen 已提交
738 739 740

**Returns**

G
Gloria 已提交
741
Returns **OHOS_IMAGE_RESULT_SUCCESS** if the operation is successful; returns an error code otherwise.
Z
zengyawen 已提交
742

G
Gloria 已提交
743
**See**
Z
zengyawen 已提交
744 745

AccessPixels
G
Gloria 已提交
746 747 748 749

**Since**

8