openharmony 鸿蒙 capi-image-packer-mdk-h

2026-08-25 浏览 (1)

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

Nametypedef KeywordDescription
ImagePacker_Opts_ImagePacker_OptsDescribes the image packing options.
ImagePacker_Native_ImagePacker_NativeDescribes the ImagePacker instance at the native layer.

Functions

NameDescription
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

NameDescription
napi_env envPointer to the JNI environment.
napi_value *resPointer to an ImagePacker object at the JavaScript native layer.

Returns

TypeDescription
int32_tResult 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

NameDescription
napi_env envPointer to the JNI environment.
napi_value packerImagePacker object at the JavaScript native layer.

Returns

TypeDescription
ImagePacker_Native*Pointer to an ImagePacker_Native object. If the operation fails, a null pointer is returned.

See also

OH_ImagePacker_Release

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

NameDescription
ImagePacker_Native* nativePointer to an ImagePacker_Native object.
napi_value sourcePixelMap object or ImageSource object at the JavaScript native layer.
ImagePacker_Opts* optsPointer to the packing options.
uint8_t* outDataPointer to the output buffer.
size_t* sizePointer to the size of the buffer.

Returns

TypeDescription
int32_tResult 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

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

NameDescription
ImagePacker_Native* nativePointer to an ImagePacker_Native object.
napi_value sourcePixelMap object or ImageSource object at the JavaScript native layer.
ImagePacker_Opts* optsPointer to the packing options.
int fdFile descriptor of the output file.

Returns

TypeDescription
int32_tResult 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_PackToData

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

NameDescription
ImagePacker_Native* nativePointer to an ImagePacker_Native object.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.

See also

OH_ImagePacker_InitNative

你可能感兴趣的鸿蒙文章

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

openharmony 鸿蒙 capi-image-mdk-h

openharmony 鸿蒙 capi-image-ohosimagesourcedelaytimelist

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/yt8uk1Uz