提交 37a9263b 编写于 作者: G Gloria 提交者: wusongqing

fixed be39245c from https://gitee.com/wusongqing/docs/pulls/18792

Update docs against 17962

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 499c4561
# Image # Image
## Overview
Provides APIs for obtaining pixel map data and information. Provides APIs for obtaining pixel map data and information.
\@Syscap SystemCapability.Multimedia.Image To use the APIs in this file, **libpixelmap_ndk.z.so** is required.
@Syscap SystemCapability.Multimedia.Image
**Since**
**Since:**
8 8
...@@ -16,59 +17,60 @@ Provides APIs for obtaining pixel map data and information. ...@@ -16,59 +17,60 @@ Provides APIs for obtaining pixel map data and information.
### Files ### Files
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| [image_pixel_map_napi.h](image__pixel__map__napi_8h.md) | Declares the APIs that can lock, access, and unlock pixel map data. <br>File to Include: <multimedia/image_framework/image_pixel_map_napi.h> | | [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>|
### Structs ### Structs
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| [OhosPixelMapInfo](_ohos_pixel_map_info.md) | Defines the pixel map information. | | [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. | | [OhosPixelMapCreateOps](_ohos_pixel_map_create_ops.md) | Defines the options used for creating a pixel map.|
### Types ### Types
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| [NativePixelMap](#nativepixelmap) | Defines the data type name of the native pixel map. | | [NativePixelMap](#nativepixelmap) | Defines the data type name of the native pixel map.|
### Enums ### Enums
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| { OHOS_IMAGE_RESULT_SUCCESS = 0, OHOS_IMAGE_RESULT_BAD_PARAMETER = -1 } | Enumerates the error codes returned by a function. | | { 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_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_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_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. | | { OHOS_PIXEL_MAP_READ_ONLY = 0, OHOS_PIXEL_MAP_EDITABLE = 1 } | Enumerates the pixel map editing types.|
### Functions ### Functions
| Name | Description | | 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) structure. | | [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 the **PixelMap** object data and locks the memory. | | [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 the **PixelMap** object data. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs. | | [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_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_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_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_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_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_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_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_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_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_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_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_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_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_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. | | [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.|
## Type Description ## Type Description
...@@ -77,11 +79,17 @@ Provides APIs for obtaining pixel map data and information. ...@@ -77,11 +79,17 @@ Provides APIs for obtaining pixel map data and information.
``` ```
typedef struct NativePixelMapNativePixelMap typedef struct NativePixelMap
``` ```
**Description:**<br/> **Description**
Defines the data type name of the native pixel map. Defines the data type name of the native pixel map.
**Since**
9
## Enum Description ## Enum Description
...@@ -91,14 +99,18 @@ Defines the data type name of the native pixel map. ...@@ -91,14 +99,18 @@ Defines the data type name of the native pixel map.
``` ```
anonymous enum anonymous enum
``` ```
**Description**<br> **Description**
Enumerates the error codes returned by a function.
| Name | Description | Enumerates the error codes returned by the functions.
| Value| Description|
| -------- | -------- | | -------- | -------- |
| OHOS_IMAGE_RESULT_SUCCESS | Operation success. | | OHOS_IMAGE_RESULT_SUCCESS| Operation success.|
| OHOS_IMAGE_RESULT_BAD_PARAMETER | Invalid value. | | OHOS_IMAGE_RESULT_BAD_PARAMETER| Invalid value.|
**Since**
8
### anonymous enum ### anonymous enum
...@@ -106,14 +118,19 @@ Enumerates the error codes returned by a function. ...@@ -106,14 +118,19 @@ Enumerates the error codes returned by a function.
``` ```
anonymous enum anonymous enum
``` ```
**Description**<br> **Description**
Enumerates the pixel formats. Enumerates the pixel formats.
| Name | Description | | Value| Description|
| -------- | -------- | | -------- | -------- |
| OHOS_PIXEL_MAP_FORMAT_NONE | Unknown format. | | 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_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. | | 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
### anonymous enum ### anonymous enum
...@@ -121,16 +138,20 @@ Enumerates the pixel formats. ...@@ -121,16 +138,20 @@ Enumerates the pixel formats.
``` ```
anonymous enum anonymous enum
``` ```
**Description:**<br/> **Description**
Enumerates the pixel map alpha types. Enumerates the pixel map alpha types.
| Name | Description | | Value| Description|
| -------- | -------- | | -------- | -------- |
| OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN | Unknown format. | | OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN| Unknown format.|
| OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE | Opaque format. | | OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE| Opaque format.|
| OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL | Premultiplied format. | | OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL| Premultiplied format.|
| OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL | Unpremultiplied format. | | OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL| Unpremultiplied format.|
**Since**
9
### anonymous enum ### anonymous enum
...@@ -138,13 +159,18 @@ Enumerates the pixel map alpha types. ...@@ -138,13 +159,18 @@ Enumerates the pixel map alpha types.
``` ```
anonymous enum anonymous enum
``` ```
**Description:**<br/> **Description**
Enumerates the pixel map scale modes. Enumerates the pixel map scale modes.
| Name | Description | | Value| Description|
| -------- | -------- | | -------- | -------- |
| OHOS_PIXEL_MAP_SCALE_MODE_FIT_TARGET_SIZE | Adaptation to the target image size. | | 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. | | OHOS_PIXEL_MAP_SCALE_MODE_CENTER_CROP| Cropping the center portion of an image to the target size.|
**Since**
9
### anonymous enum ### anonymous enum
...@@ -153,13 +179,18 @@ Enumerates the pixel map scale modes. ...@@ -153,13 +179,18 @@ Enumerates the pixel map scale modes.
``` ```
anonymous enum anonymous enum
``` ```
**Description:**<br/> **Description**
Enumerates the pixel map editing types. Enumerates the pixel map editing types.
| Name | Description | | Value| Description|
| -------- | -------- | | -------- | -------- |
| OHOS_PIXEL_MAP_READ_ONLY | Read-only. | | OHOS_PIXEL_MAP_READ_ONLY| Read-only.|
| OHOS_PIXEL_MAP_EDITABLE | Editable. | | OHOS_PIXEL_MAP_EDITABLE| Editable.|
**Since**
9
## Function Description ## Function Description
...@@ -171,77 +202,62 @@ Enumerates the pixel map editing types. ...@@ -171,77 +202,62 @@ Enumerates the pixel map editing types.
``` ```
int32_t OH_AccessPixels (napi_env env, napi_value value, void ** addrPtr ) int32_t OH_AccessPixels (napi_env env, napi_value value, void ** addrPtr )
``` ```
**Description**<br> **Description**
Obtains the memory address of the **PixelMap** object data and locks the memory.
Obtains the memory address of a **PixelMap** object and locks the memory.
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 being unlocked, the memory address cannot be accessed or operated. 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.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| env | Indicates the NAPI environment pointer. | | env | Indicates the NAPI environment pointer.|
| value | Indicates the **PixelMap** object at the application layer. | | value | Indicates the **PixelMap** object at the application layer.|
| addrPtr | Indicates the double pointer to the memory address. | | addrPtr | Indicates the double pointer to the memory address.|
**See** **See**
UnAccessPixels UnAccessPixels
**Returns** **Returns**
Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise. Returns **OHOS_IMAGE_RESULT_SUCCESS** if the operation is successful; returns an error code otherwise.
**Since**
8
### OH_GetImageInfo() ### OH_GetImageInfo()
``` ```
int32_t OH_GetImageInfo (napi_env env, napi_value value, OhosPixelMapInfo * info ) struct OhosPixelMapCreateOps OH_GetImageInfo (napi_env env, napi_value value, OhosPixelMapInfo * info )
``` ```
**Description**<br> **Description**
Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) structure.
**Parameters** Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) struct.
| Name | Description | **Parameters**
| Name| Description|
| -------- | -------- | | -------- | -------- |
| env | Indicates the NAPI environment pointer. | | env | Indicates the NAPI environment pointer.|
| value | Indicates the **PixelMap** object at the application layer. | | 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). | | info | Indicates the pointer to the object that stores the information obtained. For details, see [OhosPixelMapInfo](_ohos_pixel_map_info.md).|
**Returns** **Returns**
Returns **0** if the information is obtained and stored successfully; returns an error code otherwise. Returns **0** if the information is obtained and stored successfully; returns an error code otherwise.
**See** **See**
[OhosPixelMapInfo](_ohos_pixel_map_info.md) [OhosPixelMapInfo](_ohos_pixel_map_info.md)
**Since**
### OH_UnAccessPixels() 8
```
int32_t OH_UnAccessPixels (napi_env env, napi_value value )
```
**Description**<br>
Unlocks the memory of the **PixelMap** object data. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs.
**Parameters**
| Name | Description |
| -------- | -------- |
| env | Indicates the NAPI environment pointer. |
| value | Indicates the **PixelMap** object at the application layer. |
**Returns**
Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise.
**See**
AccessPixels
### OH_PixelMap_CreateAlphaPixelMap() ### OH_PixelMap_CreateAlphaPixelMap()
...@@ -249,25 +265,30 @@ AccessPixels ...@@ -249,25 +265,30 @@ AccessPixels
``` ```
int32_t OH_PixelMap_CreateAlphaPixelMap (napi_env env, napi_value source, napi_value * alpha ) int32_t OH_PixelMap_CreateAlphaPixelMap (napi_env env, napi_value source, napi_value * alpha )
``` ```
**Description:**<br/> **Description**
Creates a **PixelMap** object that contains only alpha channel information. Creates a **PixelMap** object that contains only alpha channel information.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| env | Indicates the NAPI environment pointer. | | env | Indicates the NAPI environment pointer.|
| source | Indicates the options for setting the **PixelMap** object. | | source | Indicates the options for setting the **PixelMap** object.|
| alpha | Indicates the pointer to the alpha channel. | | alpha | Indicates the pointer to the alpha channel.|
**Returns** **Returns**
Returns a **PixelMap** object if the operation is successful; returns an error code otherwise. Returns a **PixelMap** object if the operation is successful; returns an error code otherwise.
**See** **See**
CreateAlphaPixelMap CreateAlphaPixelMap
**Since**
9
### OH_PixelMap_CreatePixelMap() ### OH_PixelMap_CreatePixelMap()
...@@ -275,27 +296,32 @@ CreateAlphaPixelMap ...@@ -275,27 +296,32 @@ CreateAlphaPixelMap
``` ```
int32_t OH_PixelMap_CreatePixelMap (napi_env env, OhosPixelMapCreateOps info, void * buf, size_t len, napi_value * res ) int32_t OH_PixelMap_CreatePixelMap (napi_env env, OhosPixelMapCreateOps info, void * buf, size_t len, napi_value * res )
``` ```
**Description:**<br/> **Description**
Creates a **PixelMap** object. Creates a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| env | Indicates the NAPI environment pointer. | | env | Indicates the NAPI environment pointer.|
| info | Indicates the options for setting the **PixelMap** object. | | info | Indicates the options for setting the **PixelMap** object.|
| buf | Indicates the pointer to the buffer of the image. | | buf | Indicates the pointer to the buffer of the image.|
| len | Indicates the image size. | | len | Indicates the image size.|
| res | Indicates the pointer to the **PixelMap** object at the application layer. | | res | Indicates the pointer to the **PixelMap** object at the application layer.|
**Returns** **Returns**
Returns a **PixelMap** object if the operation is successful; returns an error code otherwise. Returns a **PixelMap** object if the operation is successful; returns an error code otherwise.
**See** **See**
CreatePixelMap CreatePixelMap
**Since**
9
### OH_PixelMap_Crop() ### OH_PixelMap_Crop()
...@@ -303,27 +329,32 @@ CreatePixelMap ...@@ -303,27 +329,32 @@ CreatePixelMap
``` ```
int32_t OH_PixelMap_Crop (const NativePixelMap * native, int32_t x, int32_t y, int32_t width, int32_t height ) int32_t OH_PixelMap_Crop (const NativePixelMap * native, int32_t x, int32_t y, int32_t width, int32_t height )
``` ```
**Description:**<br/> **Description**
Crops a **PixelMap** object. Crops a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| x | Indicates the x-coordinate of the upper left corner of the target image. | | 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. | | y | Indicates the y-coordinate of the upper left corner of the target image.|
| width | Indicates the width of the cropped region. | | width | Indicates the width of the cropped region.|
| height | Indicates the height of the cropped region. | | height | Indicates the height of the cropped region.|
**Returns** **Returns**
Returns **0** if the operation is successful; returns an error code otherwise. Returns **0** if the operation is successful; returns an error code otherwise.
**See** **See**
Crop Crop
**Since**
9
### OH_PixelMap_Flip() ### OH_PixelMap_Flip()
...@@ -331,25 +362,30 @@ Crop ...@@ -331,25 +362,30 @@ Crop
``` ```
int32_t OH_PixelMap_Flip (const NativePixelMap * native, int32_t x, int32_t y ) int32_t OH_PixelMap_Flip (const NativePixelMap * native, int32_t x, int32_t y )
``` ```
**Description:**<br/> **Description**
Flips a **PixelMap** object. Flips a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| x | Specifies whether to flip around the x axis. | | x | Specifies whether to flip around the x axis.|
| y | Specifies whether to flip around the y axis. | | y | Specifies whether to flip around the y axis.|
**Returns** **Returns**
Returns **0** if the operation is successful; returns an error code otherwise. Returns **0** if the operation is successful; returns an error code otherwise.
**See** **See**
Flip Flip
**Since**
9
### OH_PixelMap_GetBytesNumberPerRow() ### OH_PixelMap_GetBytesNumberPerRow()
...@@ -357,24 +393,28 @@ Flip ...@@ -357,24 +393,28 @@ Flip
``` ```
int32_t OH_PixelMap_GetBytesNumberPerRow (const NativePixelMap * native, int32_t * num ) int32_t OH_PixelMap_GetBytesNumberPerRow (const NativePixelMap * native, int32_t * num )
``` ```
**Description:**<br/> **Description**
Obtains the number of bytes per row of a **PixelMap** object. Obtains the number of bytes per row of a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| num | Indicates the pointer to the number of bytes per row of the **PixelMap** object. | | num | Indicates the pointer to the number of bytes per row of the **PixelMap** object.|
**Returns** **Returns**
Returns the number of bytes per row of the **PixelMap** object if the operation is successful; returns an error code otherwise. Returns the number of bytes per row of the **PixelMap** object if the operation is successful; returns an error code otherwise.
**See** **See**
GetBytesNumberPerRow GetBytesNumberPerRow
**Since**
9
### OH_PixelMap_GetDensity() ### OH_PixelMap_GetDensity()
...@@ -382,48 +422,28 @@ GetBytesNumberPerRow ...@@ -382,48 +422,28 @@ GetBytesNumberPerRow
``` ```
int32_t OH_PixelMap_GetDensity (const NativePixelMap * native, int32_t * density ) int32_t OH_PixelMap_GetDensity (const NativePixelMap * native, int32_t * density )
``` ```
**Description:**<br/> **Description**
Obtains the pixel density of a **PixelMap** object. Obtains the pixel density of a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| density | Indicates the pointer to the pixel density. | | density | Indicates the pointer to the pixel density.|
**Returns** **Returns**
Returns the pixel density if the operation is successful; returns an error code otherwise. Returns the pixel density if the operation is successful; returns an error code otherwise.
**See** **See**
GetDensity GetDensity
**Since**
### OH_PixelMap_GetImageInfo() 9
```
int32_t OH_PixelMap_GetImageInfo (const NativePixelMap * native, OhosPixelMapInfo * info )
```
**Description:**<br/>
Obtains the image information of a **PixelMap** object.
**Parameters**
| Name | Description |
| -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. |
| info | Indicates the pointer to the image information. |
**Returns**
Returns **0** if the operation is successful; returns an error code otherwise.
**See**
[OhosPixelMapInfo](_ohos_pixel_map_info.md)
### OH_PixelMap_GetIsEditable() ### OH_PixelMap_GetIsEditable()
...@@ -432,24 +452,29 @@ Returns **0** if the operation is successful; returns an error code otherwise. ...@@ -432,24 +452,29 @@ Returns **0** if the operation is successful; returns an error code otherwise.
``` ```
int32_t OH_PixelMap_GetIsEditable (const NativePixelMap * native, int32_t * editable ) int32_t OH_PixelMap_GetIsEditable (const NativePixelMap * native, int32_t * editable )
``` ```
**Description:**<br/> **Description**
Checks whether a **PixelMap** object is editable. Checks whether a **PixelMap** object is editable.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| editable | Indicates the pointer to the editing type of the **PixelMap** object. | | editable | Indicates the pointer to the editing type of the **PixelMap** object.|
**Returns** **Returns**
Returns an enumerated value that indicates the editing type of the **PixelMap** object if the operation is successful; returns an error code otherwise. Returns an enumerated value that indicates the editing type of the **PixelMap** object if the operation is successful; returns an error code otherwise.
**See** **See**
GetIsEditable GetIsEditable
**Since**
9
### OH_PixelMap_InitNativePixelMap() ### OH_PixelMap_InitNativePixelMap()
...@@ -457,24 +482,29 @@ GetIsEditable ...@@ -457,24 +482,29 @@ GetIsEditable
``` ```
NativePixelMap* OH_PixelMap_InitNativePixelMap (napi_env env, napi_value source ) NativePixelMap* OH_PixelMap_InitNativePixelMap (napi_env env, napi_value source )
``` ```
**Description:**<br/> **Description**
Initializes a **PixelMap** object. Initializes a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| env | Indicates the NAPI environment pointer. | | env | Indicates the NAPI environment pointer.|
| source | Indicates the options for setting the **PixelMap** object. | | source | Indicates the options for setting the **PixelMap** object.|
**Returns** **Returns**
Returns a pointer to the **NativePixelMap** object if the operation is successful; returns an error code otherwise. Returns a pointer to the **NativePixelMap** object if the operation is successful; returns an error code otherwise.
**See** **See**
InitNativePixelMap InitNativePixelMap
**Since**
9
### OH_PixelMap_IsSupportAlpha() ### OH_PixelMap_IsSupportAlpha()
...@@ -482,24 +512,30 @@ InitNativePixelMap ...@@ -482,24 +512,30 @@ InitNativePixelMap
``` ```
int32_t OH_PixelMap_IsSupportAlpha (const NativePixelMap * native, int32_t * alpha ) int32_t OH_PixelMap_IsSupportAlpha (const NativePixelMap * native, int32_t * alpha )
``` ```
**Description:**<br/> **Description**
Checks whether a **PixelMap** object supports alpha channels. Checks whether a **PixelMap** object supports alpha channels.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| alpha | Indicates the pointer to the support for alpha channels. | | alpha | Indicates the pointer to the support for alpha channels.|
**Returns** **Returns**
Returns **0** if the operation is successful; returns an error code otherwise. Returns **0** if the operation is successful; returns an error code otherwise.
**See** **See**
IsSupportAlpha IsSupportAlpha
**Since**
9
### OH_PixelMap_Rotate() ### OH_PixelMap_Rotate()
...@@ -507,24 +543,29 @@ IsSupportAlpha ...@@ -507,24 +543,29 @@ IsSupportAlpha
``` ```
int32_t OH_PixelMap_Rotate (const NativePixelMap * native, float angle ) int32_t OH_PixelMap_Rotate (const NativePixelMap * native, float angle )
``` ```
**Description:**<br/> **Description**
Rotates a **PixelMap** object. Rotates a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| angle | Indicates the angle to rotate. | | angle | Indicates the angle to rotate.|
**Returns** **Returns**
Returns **0** if the operation is successful; returns an error code otherwise. Returns **0** if the operation is successful; returns an error code otherwise.
**See** **See**
Rotate Rotate
**Since**
9
### OH_PixelMap_Scale() ### OH_PixelMap_Scale()
...@@ -532,25 +573,30 @@ Rotate ...@@ -532,25 +573,30 @@ Rotate
``` ```
int32_t OH_PixelMap_Scale (const NativePixelMap * native, float x, float y ) int32_t OH_PixelMap_Scale (const NativePixelMap * native, float x, float y )
``` ```
**Description:**<br/> **Description**
Scales a **PixelMap** object. Scales a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| x | Indicates the scaling ratio of the width. | | x | Indicates the scaling ratio of the width.|
| y | Indicates the scaling ratio of the height. | | y | Indicates the scaling ratio of the height.|
**Returns** **Returns**
Returns **0** if the operation is successful; returns an error code otherwise. Returns **0** if the operation is successful; returns an error code otherwise.
**See** **See**
Scale Scale
**Since**
9
### OH_PixelMap_SetAlphaAble() ### OH_PixelMap_SetAlphaAble()
...@@ -558,24 +604,29 @@ Scale ...@@ -558,24 +604,29 @@ Scale
``` ```
int32_t OH_PixelMap_SetAlphaAble (const NativePixelMap * native, int32_t alpha ) int32_t OH_PixelMap_SetAlphaAble (const NativePixelMap * native, int32_t alpha )
``` ```
**Description:**<br/> **Description**
Sets an alpha channel for a **PixelMap** object. Sets an alpha channel for a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| alpha | Indicates the alpha channel to set. | | alpha | Indicates the alpha channel to set.|
**Returns** **Returns**
Returns **0** if the operation is successful; returns an error code otherwise. Returns **0** if the operation is successful; returns an error code otherwise.
**See** **See**
SetAlphaAble SetAlphaAble
**Since**
9
### OH_PixelMap_SetDensity() ### OH_PixelMap_SetDensity()
...@@ -583,24 +634,29 @@ SetAlphaAble ...@@ -583,24 +634,29 @@ SetAlphaAble
``` ```
int32_t OH_PixelMap_SetDensity (const NativePixelMap * native, int32_t density ) int32_t OH_PixelMap_SetDensity (const NativePixelMap * native, int32_t density )
``` ```
**Description:**<br/> **Description**
Sets the pixel density for a **PixelMap** object. Sets the pixel density for a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| density | Indicates the pixel density to set. | | density | Indicates the pixel density to set.|
**Returns** **Returns**
Returns **0** if the operation is successful; returns an error code otherwise. Returns **0** if the operation is successful; returns an error code otherwise.
**See** **See**
GetDensity GetDensity
**Since**
9
### OH_PixelMap_SetOpacity() ### OH_PixelMap_SetOpacity()
...@@ -608,24 +664,29 @@ GetDensity ...@@ -608,24 +664,29 @@ GetDensity
``` ```
int32_t OH_PixelMap_SetOpacity (const NativePixelMap * native, float opacity ) int32_t OH_PixelMap_SetOpacity (const NativePixelMap * native, float opacity )
``` ```
**Description:**<br/> **Description**
Sets the opacity for a **PixelMap** object. Sets the opacity for a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| opacity | Indicates the opacity to set. | | opacity | Indicates the opacity to set.|
**Returns** **Returns**
Returns **0** if the operation is successful; returns an error code otherwise. Returns **0** if the operation is successful; returns an error code otherwise.
**See** **See**
SetOpacity SetOpacity
**Since**
9
### OH_PixelMap_Translate() ### OH_PixelMap_Translate()
...@@ -633,73 +694,29 @@ SetOpacity ...@@ -633,73 +694,29 @@ SetOpacity
``` ```
int32_t OH_PixelMap_Translate (const NativePixelMap * native, float x, float y ) int32_t OH_PixelMap_Translate (const NativePixelMap * native, float x, float y )
``` ```
**Description:**<br/> **Description**
Translates a **PixelMap** object. Translates a **PixelMap** object.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. | | native | Indicates the pointer to a **NativePixelMap** object.|
| x | Indicates the horizontal distance to translate. | | x | Indicates the horizontal distance to translate.|
| y | Indicates the vertical distance to translate. | | y | Indicates the vertical distance to translate.|
**Returns** **Returns**
Returns **0** if the operation is successful; returns an error code otherwise. Returns **0** if the operation is successful; returns an error code otherwise.
**See** **See**
Translate Translate
**Since**
### OH_PixelMap_UnAccessPixels() 9
```
int32_t OH_PixelMap_UnAccessPixels (const NativePixelMap * native)
```
**Description:**<br/>
Unlocks the memory of the **NativePixelMap** object data. This function is used with [OH_PixelMap_AccessPixels](#oh_pixelmap_accesspixels) in pairs.
**Parameters**
| Name | Description |
| -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. |
**Returns**
Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise.
**See**
AccessPixels
### OH_PixelMap_AccessPixels()
```
int32_t OH_PixelMap_AccessPixels(const NativePixelMap* native, void** addr)
```
**Description:**<br/>
Obtains the memory address of a **NativePixelMap** object and locks the memory.
**Parameters**
| Name | Description |
| -------- | -------- |
| native | Indicates the pointer to a **NativePixelMap** object. |
| addr | Indicates the double pointer to the memory address. |
**Returns**
Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise.
**See**
UnAccessPixels
### OH_UnAccessPixels() ### OH_UnAccessPixels()
...@@ -708,20 +725,25 @@ UnAccessPixels ...@@ -708,20 +725,25 @@ UnAccessPixels
``` ```
int32_t OH_UnAccessPixels (napi_env env, napi_value value ) int32_t OH_UnAccessPixels (napi_env env, napi_value value )
``` ```
**Description:**<br/> **Description**
Unlocks the memory of a **PixelMap** object. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs. Unlocks the memory of a **PixelMap** object. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs.
**Parameters** **Parameters**
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| env | Indicates the NAPI environment pointer. | | env | Indicates the NAPI environment pointer.|
| value | Indicates the **PixelMap** object at the application layer. | | value | Indicates the **PixelMap** object at the application layer.|
**Returns** **Returns**
Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise. Returns **OHOS_IMAGE_RESULT_SUCCESS** if the operation is successful; returns an error code otherwise.
**See** **See**
AccessPixels AccessPixels
**Since**
8
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册