1e41f4b71Sopenharmony_ci# image_packer_mdk.h
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciThe **image_packer_mdk.h** file declares the APIs used to pack an image or a pixel map into a buffer or file.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ciThe packing process is as follows:
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci1. Call **OH_ImagePacker_Create** to create an **ImagePacker** object.
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci2. Call **OH_ImagePacker_InitNative** to convert the **ImagePacker** object to an **ImagePacker_Native** object.
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci3. Call **OH_ImagePacker_PackToData** or **OH_ImagePacker_PackToFile** to pack the source into the target area with the specified packing options.
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci4. Call **OH_ImagePacker_Release** to release an **ImagePacker_Native** object.
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci**Library**: libimage_packer_ndk.z.so
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**File to include**: <multimedia/image_framework/image_packer_mdk.h>
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Image
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**Since**: 11
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**Related module**: [Image](image.md)
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## Summary
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci### Structs
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci| Name| Description| 
35e41f4b71Sopenharmony_ci| -------- | -------- |
36e41f4b71Sopenharmony_ci| struct  [ImagePacker_Opts_](_image_packer___opts__.md) | Defines the image packing options. | 
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci### Types
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci| Name| Description| 
42e41f4b71Sopenharmony_ci| -------- | -------- |
43e41f4b71Sopenharmony_ci| typedef struct ImagePacker_Native_ [ImagePacker_Native](image.md#imagepacker_native) | Defines the **ImagePacker** instance at the native layer. | 
44e41f4b71Sopenharmony_ci| typedef struct [ImagePacker_Opts_](_image_packer___opts__.md) [ImagePacker_Opts](image.md#imagepacker_opts) | Defines the alias of the image packing options. | 
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci### Functions
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci| Name| Description| 
50e41f4b71Sopenharmony_ci| -------- | -------- |
51e41f4b71Sopenharmony_ci| int32_t [OH_ImagePacker_Create](image.md#oh_imagepacker_create) (napi_env env, napi_value \*res) | Obtains an **ImagePacker** object at the JavaScript native layer. | 
52e41f4b71Sopenharmony_ci| [ImagePacker_Native](image.md#imagepacker_native) \* [OH_ImagePacker_InitNative](image.md#oh_imagepacker_initnative) (napi_env env, napi_value packer) | Converts an **ImagePacker** object at the JavaScript native layer into an **ImagePacker_Native** object. | 
53e41f4b71Sopenharmony_ci| int32_t [OH_ImagePacker_PackToData](image.md#oh_imagepacker_packtodata) ([ImagePacker_Native](image.md#imagepacker_native) \*native, napi_value source, [ImagePacker_Opts](image.md#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.| 
54e41f4b71Sopenharmony_ci| int32_t [OH_ImagePacker_PackToFile](image.md#oh_imagepacker_packtofile) ([ImagePacker_Native](image.md#imagepacker_native) \*native, napi_value source, [ImagePacker_Opts](image.md#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. | 
55e41f4b71Sopenharmony_ci| int32_t [OH_ImagePacker_Release](image.md#oh_imagepacker_release) ([ImagePacker_Native](image.md#imagepacker_native) \*native) | Releases an [ImagePacker_Native](image.md#imagepacker_native) object.| 
56