image_packer_mdk.h
Overview
The file declares the APIs used to pack an image or a PixelMap into a buffer or file.
The packing process is as follows:
Create an encoder object using OH_ImagePacker_Create.
Convert the encoder object to a native encoder object using OH_ImagePacker_InitNative.
Call OH_ImagePacker_PackToData or OH_ImagePacker_PackToFile to pack the source into the target area with the specified packing options.
Release the encoder object using OH_ImagePacker_Release.
File to include: <multimedia/image_framework/image_packer_mdk.h>
Library: libimage_packer_ndk.z.so
System capability: SystemCapability.Multimedia.Image.Core
Since: 11
Related module: Image
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| ImagePacker_Opts_ | ImagePacker_Opts | Describes the image packing options. |
| ImagePacker_Native_ | ImagePacker_Native | Describes the ImagePacker instance at the native layer. |
Functions
| Name | Description |
|---|---|
| int32_t OH_ImagePacker_Create(napi_env env, napi_value *res) | Obtains an ImagePacker object at the JavaScript native layer. |
| ImagePacker_Native* OH_ImagePacker_InitNative(napi_env env, napi_value packer) | Converts an ImagePacker object at the JavaScript native layer into an ImagePacker_Native object. |
| int32_t OH_ImagePacker_PackToData(ImagePacker_Native* native, napi_value source,ImagePacker_Opts* opts, uint8_t* outData, size_t* size) | Packs a PixelMap object or an ImagePacker object at the JavaScript native layer to a buffer (defined by outData) based on the specified ImagePacker_Opts struct. |
| int32_t OH_ImagePacker_PackToFile(ImagePacker_Native* native, napi_value source, ImagePacker_Opts* opts, int fd) | Packs a PixelMap object or an ImagePacker object at the JavaScript native layer to a file based on the specified ImagePacker_Opts struct. |
| int32_t OH_ImagePacker_Release(ImagePacker_Native* native) | Releases an ImagePacker_Native object. It is not used to release the ImagePacker object at the JavaScript native layer. |
Function Description
OH_ImagePacker_Create()
int32_t OH_ImagePacker_Create(napi_env env, napi_value *res)
Description
Obtains an ImagePacker object at the JavaScript native layer.
Since: 11
Parameters
| Name | Description |
|---|---|
| napi_env env | Pointer to the JNI environment. |
| napi_value *res | Pointer to an ImagePacker object at the JavaScript native layer. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code defined in IRNdkErrCode: IMAGE_RESULT_SUCCESS: The operation is successful. IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid. |
OH_ImagePacker_InitNative()
ImagePacker_Native* OH_ImagePacker_InitNative(napi_env env, napi_value packer)
Description
Converts an ImagePacker object at the JavaScript native layer into an ImagePacker_Native object.
Since: 11
Parameters
| Name | Description |
|---|---|
| napi_env env | Pointer to the JNI environment. |
| napi_value packer | ImagePacker object at the JavaScript native layer. |
Returns
| Type | Description |
|---|---|
| ImagePacker_Native* | Pointer to an ImagePacker_Native object. If the operation fails, a null pointer is returned. |
See also
OH_ImagePacker_PackToData()
int32_t OH_ImagePacker_PackToData(ImagePacker_Native* native, napi_value source,ImagePacker_Opts* opts, uint8_t* outData, size_t* size)
Description
Packs a PixelMap object or an ImagePacker object at the JavaScript native layer to a buffer (defined by outData) based on the specified ImagePacker_Opts struct.
Since: 11
Parameters
| Name | Description |
|---|---|
| ImagePacker_Native* native | Pointer to an ImagePacker_Native object. |
| napi_value source | PixelMap object or ImageSource object at the JavaScript native layer. |
| ImagePacker_Opts* opts | Pointer to the packing options. |
| uint8_t* outData | Pointer to the output buffer. |
| size_t* size | Pointer to the size of the buffer. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code defined in IRNdkErrCode: IMAGE_RESULT_SUCCESS: The operation is successful. IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid. ERR_IMAGE_DATA_ABNORMAL: The output buffer is abnormal. ERR_IMAGE_MISMATCHED_FORMAT: The format is incorrect. ERR_IMAGE_MALLOC_ABNORMAL: An error occurs in the malloc internal buffer. ERR_IMAGE_DECODE_ABNORMAL: An internal error occurs during codec initialization. ERR_IMAGE_ENCODE_FAILED: An error occurs during encoding. |
See also
OH_ImagePacker_PackToFile()
int32_t OH_ImagePacker_PackToFile(ImagePacker_Native* native, napi_value source,ImagePacker_Opts* opts, int fd)
Description
Packs a PixelMap object or an ImagePacker object at the JavaScript native layer to a file based on the specified ImagePacker_Opts struct.
Since: 11
Parameters
| Name | Description |
|---|---|
| ImagePacker_Native* native | Pointer to an ImagePacker_Native object. |
| napi_value source | PixelMap object or ImageSource object at the JavaScript native layer. |
| ImagePacker_Opts* opts | Pointer to the packing options. |
| int fd | File descriptor of the output file. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code defined in IRNdkErrCode: IMAGE_RESULT_SUCCESS: The operation is successful. IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid. ERR_IMAGE_DATA_ABNORMAL: The output buffer is abnormal. ERR_IMAGE_MISMATCHED_FORMAT: The format is incorrect. ERR_IMAGE_MALLOC_ABNORMAL: An error occurs in the malloc internal buffer. ERR_IMAGE_DECODE_ABNORMAL: An internal error occurs during codec initialization. ERR_IMAGE_ENCODE_FAILED: An error occurs during encoding. |
See also
OH_ImagePacker_Release()
int32_t OH_ImagePacker_Release(ImagePacker_Native* native)
Description
Releases an ImagePacker_Native object.
It is not used to release the ImagePacker object at the JavaScript native layer.
It is parsed by calling OH_ImagePacker_InitNative.
Since: 11
Parameters
| Name | Description |
|---|---|
| ImagePacker_Native* native | Pointer to an ImagePacker_Native object. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code defined in IRNdkErrCode: IMAGE_RESULT_SUCCESS: The operation is successful. |
See also
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 capi-image-nativemodule-oh-pixelmap-hdrmetadatavalue
openharmony 鸿蒙 capi-image-imagepacker-opts-
openharmony 鸿蒙 capi-image-nativemodule-image-region
openharmony 鸿蒙 capi-image-imagepacker-native-
openharmony 鸿蒙 capi-image-imagenative-
openharmony 鸿蒙 capi-image-processing-h
openharmony 鸿蒙 capi-image-ohosimagesourcesupportedformat
openharmony 鸿蒙 capi-image-nativemodule-image-size