1# image_packer_native.h 2<!--Kit: Image Kit--> 3<!--Subsystem: Multimedia--> 4<!--Owner: @aulight02--> 5<!--SE: @liyang_bryan--> 6<!--TSE: @xchaosioda--> 7 8## Overview 9 10The file declares the APIs for image encoding. 11 12**Library**: libimage_packer.so 13 14**System capability**: SystemCapability.Multimedia.Image.ImagePacker 15 16**Since**: 12 17 18**Related module**: [Image_NativeModule](capi-image-nativemodule.md) 19 20## Summary 21 22### Structs 23 24| Name| typedef Keyword| Description| 25| -- | -- | -- | 26| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) | OH_ImagePackerNative | Describes the image packer, which is used to perform operations related to an image packer.| 27| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) | OH_PackingOptions | Describes the image packing options, which are encapsulated at the native layer. The struct cannot be directly operated. Instead, functions must be called to create and release the struct and operate the fields in the struct.| 28| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) | OH_PackingOptionsForSequence | Describes the image sequence encoding parameters.| 29 30### Enums 31 32| Name| typedef Keyword| Description| 33| -- | -- | -- | 34| [IMAGE_PACKER_DYNAMIC_RANGE](#image_packer_dynamic_range) | IMAGE_PACKER_DYNAMIC_RANGE | Enumerates the dynamic range for encoding.| 35 36### Functions 37 38| Name| Description| 39| -- | -- | 40| [Image_ErrorCode OH_PackingOptions_Create(OH_PackingOptions **options)](#oh_packingoptions_create) | Creates the pointer to an OH_PackingOptions struct.| 41| [Image_ErrorCode OH_PackingOptions_GetMimeType(OH_PackingOptions *options,Image_MimeType *format)](#oh_packingoptions_getmimetype) | Obtains the MIME type.| 42| [Image_ErrorCode OH_PackingOptions_GetMimeTypeWithNull(OH_PackingOptions *options,Image_MimeType *format)](#oh_packingoptions_getmimetypewithnull) | Obtains the MIME type in the packing options. The output **format.data** is terminated with a string terminator.| 43| [Image_ErrorCode OH_PackingOptions_SetMimeType(OH_PackingOptions *options,Image_MimeType *format)](#oh_packingoptions_setmimetype) | Sets the MIME type.| 44| [Image_ErrorCode OH_PackingOptions_GetQuality(OH_PackingOptions *options,uint32_t *quality)](#oh_packingoptions_getquality) | Obtains the encoding quality.| 45| [Image_ErrorCode OH_PackingOptions_SetQuality(OH_PackingOptions *options,uint32_t quality)](#oh_packingoptions_setquality) | Sets the encoding quality.| 46| [ Image_ErrorCode OH_PackingOptions_GetNeedsPackProperties(OH_PackingOptions *options,bool *needsPackProperties)](#oh_packingoptions_getneedspackproperties) | Obtains the **needsPackProperties** parameter in the OH_PackingOptions struct.| 47| [Image_ErrorCode OH_PackingOptions_SetNeedsPackProperties(OH_PackingOptions *options,bool needsPackProperties)](#oh_packingoptions_setneedspackproperties) | Sets the **needsPackProperties** parameter in the OH_PackingOptions struct.| 48| [Image_ErrorCode OH_PackingOptions_GetDesiredDynamicRange(OH_PackingOptions *options, int32_t* desiredDynamicRange)](#oh_packingoptions_getdesireddynamicrange) | Obtains the desired dynamic range during encoding.| 49| [Image_ErrorCode OH_PackingOptions_SetDesiredDynamicRange(OH_PackingOptions *options, int32_t desiredDynamicRange)](#oh_packingoptions_setdesireddynamicrange) | Sets the desired dynamic range during encoding.| 50| [Image_ErrorCode OH_PackingOptions_Release(OH_PackingOptions *options)](#oh_packingoptions_release) | Releases the pointer to an OH_PackingOptions struct.| 51| [Image_ErrorCode OH_PackingOptionsForSequence_Create(OH_PackingOptionsForSequence **options)](#oh_packingoptionsforsequence_create) | Creates the pointer to an OH_PackingOptionsForSequence struct.| 52| [Image_ErrorCode OH_PackingOptionsForSequence_SetFrameCount(OH_PackingOptionsForSequence *options,uint32_t frameCount)](#oh_packingoptionsforsequence_setframecount) | Sets the number of frames for image sequence encoding.| 53| [Image_ErrorCode OH_PackingOptionsForSequence_GetFrameCount(OH_PackingOptionsForSequence *options,uint32_t *frameCount)](#oh_packingoptionsforsequence_getframecount) | Obtains the number of frames for image sequence encoding.| 54| [Image_ErrorCode OH_PackingOptionsForSequence_SetDelayTimeList(OH_PackingOptionsForSequence *options,int32_t *delayTimeList, size_t delayTimeListLength)](#oh_packingoptionsforsequence_setdelaytimelist) | Sets the delay time array for image sequence encoding.| 55| [Image_ErrorCode OH_PackingOptionsForSequence_GetDelayTimeList(OH_PackingOptionsForSequence *options,int32_t *delayTimeList, size_t delayTimeListLength)](#oh_packingoptionsforsequence_getdelaytimelist) | Obtains the delay time array for image sequence encoding.| 56| [Image_ErrorCode OH_PackingOptionsForSequence_SetDisposalTypes(OH_PackingOptionsForSequence *options,uint32_t *disposalTypes, size_t disposalTypesLength)](#oh_packingoptionsforsequence_setdisposaltypes) | Sets the disposal type array for image sequence encoding.| 57| [Image_ErrorCode OH_PackingOptionsForSequence_GetDisposalTypes(OH_PackingOptionsForSequence *options,uint32_t *disposalTypes, size_t disposalTypesLength)](#oh_packingoptionsforsequence_getdisposaltypes) | Obtains the disposal type array for image sequence encoding.| 58| [Image_ErrorCode OH_PackingOptionsForSequence_SetLoopCount(OH_PackingOptionsForSequence *options, uint32_t loopCount)](#oh_packingoptionsforsequence_setloopcount) | Sets the number of loops for image sequence encoding. The value range is [0, 65535], where **0** means an infinite loop. If this field is not carried, loop playback is not performed.| 59| [Image_ErrorCode OH_PackingOptionsForSequence_GetLoopCount(OH_PackingOptionsForSequence *options, uint32_t *loopCount)](#oh_packingoptionsforsequence_getloopcount) | Obtains the number of loops for image sequence encoding.| 60| [Image_ErrorCode OH_PackingOptionsForSequence_Release(OH_PackingOptionsForSequence *options)](#oh_packingoptionsforsequence_release) | Releases the pointer to an OH_PackingOptionsForSequence struct.| 61| [Image_ErrorCode OH_ImagePackerNative_Create(OH_ImagePackerNative **imagePacker)](#oh_imagepackernative_create) | Creates the pointer to an OH_ImagePackerNative struct.| 62| [Image_ErrorCode OH_ImagePackerNative_PackToDataFromImageSource(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_ImageSourceNative *imageSource, uint8_t *outData, size_t *size)](#oh_imagepackernative_packtodatafromimagesource) | Encodes an image source into data in a given format.| 63| [Image_ErrorCode OH_ImagePackerNative_PackToDataFromPixelmap(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_PixelmapNative *pixelmap, uint8_t *outData, size_t *size)](#oh_imagepackernative_packtodatafrompixelmap) | Encodes a PixelMap into data in a given format.| 64| [Image_ErrorCode OH_ImagePackerNative_PackToDataFromPicture(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_PictureNative *picture, uint8_t *outData, size_t *size)](#oh_imagepackernative_packtodatafrompicture) | Encodes a picture into data in a given format.| 65| [Image_ErrorCode OH_ImagePackerNative_PackToDataFromPixelmapSequence(OH_ImagePackerNative *imagePacker,OH_PackingOptionsForSequence *options, OH_PixelmapNative **pixelmapSequence,size_t sequenceLength, uint8_t *outData, size_t *outDataSize)](#oh_imagepackernative_packtodatafrompixelmapsequence) | Encodes a PixelMap sequence into data.| 66| [Image_ErrorCode OH_ImagePackerNative_PackToFileFromImageSource(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_ImageSourceNative *imageSource, int32_t fd)](#oh_imagepackernative_packtofilefromimagesource) | Encodes an image source into a file.| 67| [Image_ErrorCode OH_ImagePackerNative_PackToFileFromPixelmap(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_PixelmapNative *pixelmap, int32_t fd)](#oh_imagepackernative_packtofilefrompixelmap) | Encodes a PixelMap into a file.| 68| [Image_ErrorCode OH_ImagePackerNative_PackToFileFromPicture(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_PictureNative *picture, int32_t fd)](#oh_imagepackernative_packtofilefrompicture) | Encodes a picture into a file.| 69| [Image_ErrorCode OH_ImagePackerNative_PackToFileFromPixelmapSequence(OH_ImagePackerNative *imagePacker,OH_PackingOptionsForSequence *options, OH_PixelmapNative **pixelmapSequence, size_t sequenceLength, int32_t fd)](#oh_imagepackernative_packtofilefrompixelmapsequence) | Encodes a PixelMap sequence into a file.| 70| [Image_ErrorCode OH_ImagePackerNative_GetSupportedFormats(Image_MimeType **supportedFormats, size_t *length)](#oh_imagepackernative_getsupportedformats) | Obtains the supported image formats that can be encoded.| 71| [Image_ErrorCode OH_ImagePackerNative_Release(OH_ImagePackerNative *imagePacker)](#oh_imagepackernative_release) | Releases the pointer to an OH_ImagePackerNative struct.| 72 73## Enum Description 74 75### IMAGE_PACKER_DYNAMIC_RANGE 76 77``` 78enum IMAGE_PACKER_DYNAMIC_RANGE 79``` 80 81**Description** 82 83Enumerates the dynamic range for encoding. 84 85**Since**: 12 86 87| Enum Item| Description| 88| -- | -- | 89| IMAGE_PACKER_DYNAMIC_RANGE_AUTO = 0 | Adaptive processing.| 90| IMAGE_PACKER_DYNAMIC_RANGE_SDR = 1 | Standard dynamic range (SDR).| 91 92 93## Function Description 94 95### OH_PackingOptions_Create() 96 97``` 98Image_ErrorCode OH_PackingOptions_Create(OH_PackingOptions **options) 99``` 100 101**Description** 102 103Creates the pointer to an OH_PackingOptions struct. 104 105**Since**: 12 106 107 108**Parameters** 109 110| Name| Description| 111| -- | -- | 112| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) **options | Double pointer to the OH_PackingOptions struct created.| 113 114**Returns** 115 116| Type| Description| 117| -- | -- | 118| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 119 120### OH_PackingOptions_GetMimeType() 121 122``` 123Image_ErrorCode OH_PackingOptions_GetMimeType(OH_PackingOptions *options,Image_MimeType *format) 124``` 125 126**Description** 127 128Obtains the MIME type. 129 130**Since**: 12 131 132 133**Parameters** 134 135| Name| Description| 136| -- | -- | 137| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 138| [Image_MimeType](capi-image-nativemodule-image-string.md) *format | Pointer to the image format. You can pass in a null pointer with the size set to zero. In this case, the system will allocate memory, but you must release the memory after use.| 139 140**Returns** 141 142| Type| Description| 143| -- | -- | 144| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 145 146### OH_PackingOptions_GetMimeTypeWithNull() 147 148``` 149Image_ErrorCode OH_PackingOptions_GetMimeTypeWithNull(OH_PackingOptions *options,Image_MimeType *format) 150``` 151 152**Description** 153 154Obtains the MIME type in the packing options. The output **format.data** is terminated with a string terminator. 155 156**Since**: 19 157 158 159**Parameters** 160 161| Name| Description| 162| -- | -- | 163| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 164| [Image_MimeType](capi-image-nativemodule-image-string.md) *format | Pointer to the MIME type.| 165 166**Returns** 167 168| Type| Description| 169| -- | -- | 170| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_PACKER_INVALID_PARAMETER**: The **options** or **format** parameter is a null pointer.| 171 172### OH_PackingOptions_SetMimeType() 173 174``` 175Image_ErrorCode OH_PackingOptions_SetMimeType(OH_PackingOptions *options,Image_MimeType *format) 176``` 177 178**Description** 179 180Sets the MIME type. 181 182**Since**: 12 183 184 185**Parameters** 186 187| Name| Description| 188| -- | -- | 189| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 190| [Image_MimeType](capi-image-nativemodule-image-string.md) *format | Pointer to the image format.| 191 192**Returns** 193 194| Type| Description| 195| -- | -- | 196| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 197 198### OH_PackingOptions_GetQuality() 199 200``` 201Image_ErrorCode OH_PackingOptions_GetQuality(OH_PackingOptions *options,uint32_t *quality) 202``` 203 204**Description** 205 206Obtains the encoding quality. 207 208**Since**: 12 209 210 211**Parameters** 212 213| Name| Description| 214| -- | -- | 215| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 216| uint32_t *quality | Pointer to the encoding quality.| 217 218**Returns** 219 220| Type| Description| 221| -- | -- | 222| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 223 224### OH_PackingOptions_SetQuality() 225 226``` 227Image_ErrorCode OH_PackingOptions_SetQuality(OH_PackingOptions *options,uint32_t quality) 228``` 229 230**Description** 231 232Sets the encoding quality. 233 234**Since**: 12 235 236 237**Parameters** 238 239| Name| Description| 240| -- | -- | 241| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 242| uint32_t quality | Encoding quality.| 243 244**Returns** 245 246| Type| Description| 247| -- | -- | 248| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 249 250### OH_PackingOptions_GetNeedsPackProperties() 251 252``` 253 Image_ErrorCode OH_PackingOptions_GetNeedsPackProperties(OH_PackingOptions *options,bool *needsPackProperties) 254``` 255 256**Description** 257 258Obtains the **needsPackProperties** parameter in the OH_PackingOptions struct. 259 260**Since**: 12 261 262 263**Parameters** 264 265| Name| Description| 266| -- | -- | 267| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 268| bool *needsPackProperties | Pointer to the parameter that specifies whether to encode image property information, for example, EXIF.| 269 270**Returns** 271 272| Type| Description| 273| -- | -- | 274| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 275 276### OH_PackingOptions_SetNeedsPackProperties() 277 278``` 279Image_ErrorCode OH_PackingOptions_SetNeedsPackProperties(OH_PackingOptions *options,bool needsPackProperties) 280``` 281 282**Description** 283 284Sets the **needsPackProperties** parameter in the OH_PackingOptions struct. 285 286**Since**: 12 287 288 289**Parameters** 290 291| Name| Description| 292| -- | -- | 293| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 294| bool needsPackProperties | Whether to encode image property information, for example, EXIF.| 295 296**Returns** 297 298| Type| Description| 299| -- | -- | 300| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 301 302### OH_PackingOptions_GetDesiredDynamicRange() 303 304``` 305Image_ErrorCode OH_PackingOptions_GetDesiredDynamicRange(OH_PackingOptions *options, int32_t* desiredDynamicRange) 306``` 307 308**Description** 309 310Obtains the desired dynamic range during encoding. 311 312**Since**: 12 313 314 315**Parameters** 316 317| Name| Description| 318| -- | -- | 319| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 320| int32_t* desiredDynamicRange | Pointer to the desired dynamic range. For details about the available options, see [IMAGE_PACKER_DYNAMIC_RANGE](#image_packer_dynamic_range).| 321 322**Returns** 323 324| Type| Description| 325| -- | -- | 326| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 327 328### OH_PackingOptions_SetDesiredDynamicRange() 329 330``` 331Image_ErrorCode OH_PackingOptions_SetDesiredDynamicRange(OH_PackingOptions *options, int32_t desiredDynamicRange) 332``` 333 334**Description** 335 336Sets the desired dynamic range during encoding. 337 338**Since**: 12 339 340 341**Parameters** 342 343| Name| Description| 344| -- | -- | 345| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 346| int32_t desiredDynamicRange | Desired dynamic range. For details about the available options, see [IMAGE_PACKER_DYNAMIC_RANGE](#image_packer_dynamic_range).| 347 348**Returns** 349 350| Type| Description| 351| -- | -- | 352| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 353 354### OH_PackingOptions_Release() 355 356``` 357Image_ErrorCode OH_PackingOptions_Release(OH_PackingOptions *options) 358``` 359 360**Description** 361 362Releases the pointer to an OH_PackingOptions struct. 363 364**Since**: 12 365 366 367**Parameters** 368 369| Name| Description| 370| -- | -- | 371| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 372 373**Returns** 374 375| Type| Description| 376| -- | -- | 377| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 378 379### OH_PackingOptionsForSequence_Create() 380 381``` 382Image_ErrorCode OH_PackingOptionsForSequence_Create(OH_PackingOptionsForSequence **options) 383``` 384 385**Description** 386 387Creates the pointer to an OH_PackingOptionsForSequence struct. 388 389**Since**: 13 390 391 392**Parameters** 393 394| Name| Description| 395| -- | -- | 396| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) **options | Double pointer to the OH_PackingOptionsForSequence struct created.| 397 398**Returns** 399 400| Type| Description| 401| -- | -- | 402| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 403 404### OH_PackingOptionsForSequence_SetFrameCount() 405 406``` 407Image_ErrorCode OH_PackingOptionsForSequence_SetFrameCount(OH_PackingOptionsForSequence *options,uint32_t frameCount) 408``` 409 410**Description** 411 412Sets the number of frames for image sequence encoding. 413 414**Since**: 13 415 416 417**Parameters** 418 419| Name| Description| 420| -- | -- | 421| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an OH_PackingOptionsForSequence struct.| 422| uint32_t frameCount | Number of frames.| 423 424**Returns** 425 426| Type| Description| 427| -- | -- | 428| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 429 430### OH_PackingOptionsForSequence_GetFrameCount() 431 432``` 433Image_ErrorCode OH_PackingOptionsForSequence_GetFrameCount(OH_PackingOptionsForSequence *options,uint32_t *frameCount) 434``` 435 436**Description** 437 438Obtains the number of frames for image sequence encoding. 439 440**Since**: 13 441 442 443**Parameters** 444 445| Name| Description| 446| -- | -- | 447| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an OH_PackingOptionsForSequence struct.| 448| uint32_t *frameCount | Pointer to the number of frames.| 449 450**Returns** 451 452| Type| Description| 453| -- | -- | 454| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 455 456### OH_PackingOptionsForSequence_SetDelayTimeList() 457 458``` 459Image_ErrorCode OH_PackingOptionsForSequence_SetDelayTimeList(OH_PackingOptionsForSequence *options,int32_t *delayTimeList, size_t delayTimeListLength) 460``` 461 462**Description** 463 464Sets the delay time array for image sequence encoding. 465 466**Since**: 13 467 468 469**Parameters** 470 471| Name| Description| 472| -- | -- | 473| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an OH_PackingOptionsForSequence struct.| 474| int32_t *delayTimeList | Pointer to the delay time array.| 475| size_t delayTimeListLength | Length of the delay time array.| 476 477**Returns** 478 479| Type| Description| 480| -- | -- | 481| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 482 483### OH_PackingOptionsForSequence_GetDelayTimeList() 484 485``` 486Image_ErrorCode OH_PackingOptionsForSequence_GetDelayTimeList(OH_PackingOptionsForSequence *options,int32_t *delayTimeList, size_t delayTimeListLength) 487``` 488 489**Description** 490 491Obtains the delay time array for image sequence encoding. 492 493**Since**: 13 494 495 496**Parameters** 497 498| Name| Description| 499| -- | -- | 500| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an OH_PackingOptionsForSequence struct.| 501| int32_t *delayTimeList | Pointer to the delay time array.| 502| size_t delayTimeListLength | Length of the delay time array.| 503 504**Returns** 505 506| Type| Description| 507| -- | -- | 508| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 509 510### OH_PackingOptionsForSequence_SetDisposalTypes() 511 512``` 513Image_ErrorCode OH_PackingOptionsForSequence_SetDisposalTypes(OH_PackingOptionsForSequence *options,uint32_t *disposalTypes, size_t disposalTypesLength) 514``` 515 516**Description** 517 518Sets the disposal type array for image sequence encoding. 519 520**Since**: 13 521 522 523**Parameters** 524 525| Name| Description| 526| -- | -- | 527| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an OH_PackingOptionsForSequence struct.| 528| uint32_t *disposalTypes | Pointer to an array that defines how each image frame transitions. If the array length is less than **frameCount**, the last value in the array will be used for the remaining frames. The values can be:<br>**0**: No operation is required.<br>**1**: Keeps the image unchanged.<br>**2**: Restores the background color.<br>**3**: Restores to the previous state.| 529| size_t disposalTypesLength | Length of the disposal type array.| 530 531**Returns** 532 533| Type| Description| 534| -- | -- | 535| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 536 537### OH_PackingOptionsForSequence_GetDisposalTypes() 538 539``` 540Image_ErrorCode OH_PackingOptionsForSequence_GetDisposalTypes(OH_PackingOptionsForSequence *options,uint32_t *disposalTypes, size_t disposalTypesLength) 541``` 542 543**Description** 544 545Obtains the disposal type array for image sequence encoding. 546 547**Since**: 13 548 549 550**Parameters** 551 552| Name| Description| 553| -- | -- | 554| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an OH_PackingOptionsForSequence struct.| 555| uint32_t *disposalTypes | Pointer to the disposal type array.| 556| size_t disposalTypesLength | Length of the disposal type array.| 557 558**Returns** 559 560| Type| Description| 561| -- | -- | 562| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 563 564### OH_PackingOptionsForSequence_SetLoopCount() 565 566``` 567Image_ErrorCode OH_PackingOptionsForSequence_SetLoopCount(OH_PackingOptionsForSequence *options, uint32_t loopCount) 568``` 569 570**Description** 571 572Sets the number of loops for image sequence encoding. The value range is [0, 65535], where **0** means an infinite loop. If this field is not carried, loop playback is not performed. 573 574**Since**: 13 575 576 577**Parameters** 578 579| Name| Description| 580| -- | -- | 581| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an OH_PackingOptionsForSequence struct.| 582| uint32_t loopCount | Number of loops.| 583 584**Returns** 585 586| Type| Description| 587| -- | -- | 588| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 589 590### OH_PackingOptionsForSequence_GetLoopCount() 591 592``` 593Image_ErrorCode OH_PackingOptionsForSequence_GetLoopCount(OH_PackingOptionsForSequence *options, uint32_t *loopCount) 594``` 595 596**Description** 597 598Obtains the number of loops for image sequence encoding. 599 600**Since**: 13 601 602 603**Parameters** 604 605| Name| Description| 606| -- | -- | 607| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an OH_PackingOptionsForSequence struct.| 608| uint32_t *loopCount | Pointer to the number of loops.| 609 610**Returns** 611 612| Type| Description| 613| -- | -- | 614| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 615 616### OH_PackingOptionsForSequence_Release() 617 618``` 619Image_ErrorCode OH_PackingOptionsForSequence_Release(OH_PackingOptionsForSequence *options) 620``` 621 622**Description** 623 624Releases the pointer to an OH_PackingOptionsForSequence struct. 625 626**Since**: 13 627 628 629**Parameters** 630 631| Name| Description| 632| -- | -- | 633| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an OH_PackingOptionsForSequence struct.| 634 635**Returns** 636 637| Type| Description| 638| -- | -- | 639| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 640 641### OH_ImagePackerNative_Create() 642 643``` 644Image_ErrorCode OH_ImagePackerNative_Create(OH_ImagePackerNative **imagePacker) 645``` 646 647**Description** 648 649Creates the pointer to an OH_ImagePackerNative struct. 650 651**Since**: 12 652 653 654**Parameters** 655 656| Name| Description| 657| -- | -- | 658| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) **imagePacker | Double pointer to the OH_ImagePackerNative object created.| 659 660**Returns** 661 662| Type| Description| 663| -- | -- | 664| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 665 666### OH_ImagePackerNative_PackToDataFromImageSource() 667 668``` 669Image_ErrorCode OH_ImagePackerNative_PackToDataFromImageSource(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_ImageSourceNative *imageSource, uint8_t *outData, size_t *size) 670``` 671 672**Description** 673 674Encodes an image source into data in a given format. 675 676**Since**: 12 677 678 679**Parameters** 680 681| Name| Description| 682| -- | -- | 683| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) *imagePacker | Pointer to an OH_ImagePackerNative object.| 684| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 685| [OH_ImageSourceNative](capi-image-nativemodule-oh-imagesourcenative.md) *imageSource | Pointer to the image source to encode.| 686| uint8_t *outData | Pointer to the buffer used to store the output data.| 687| size_t *size | Pointer to the size of the buffer.| 688 689**Returns** 690 691| Type| Description| 692| -- | -- | 693| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br>**IMAGE_DECODE_FAILED**: Decoding fails.<br>**IMAGE_ALLOC_FAILED**: Memory allocation fails.<br> **IMAGE_TOO_LARGE**: The data or image is too large.<br>**IMAGE_UNKNOWN_ERROR**: An unknown error occurs.| 694 695### OH_ImagePackerNative_PackToDataFromPixelmap() 696 697``` 698Image_ErrorCode OH_ImagePackerNative_PackToDataFromPixelmap(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_PixelmapNative *pixelmap, uint8_t *outData, size_t *size) 699``` 700 701**Description** 702 703Encodes a PixelMap into data in a given format. 704 705**Since**: 12 706 707 708**Parameters** 709 710| Name| Description| 711| -- | -- | 712| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) *imagePacker | Pointer to an OH_ImagePackerNative object.| 713| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 714| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to the PixelMap to encode.| 715| uint8_t *outData | Pointer to the buffer used to store the output data.| 716| size_t *size | Pointer to the size of the buffer.| 717 718**Returns** 719 720| Type| Description| 721| -- | -- | 722| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br>**IMAGE_DECODE_FAILED**: Decoding fails.<br>**IMAGE_ALLOC_FAILED**: Memory allocation fails.<br> **IMAGE_TOO_LARGE**: The data or image is too large.<br>**IMAGE_UNKNOWN_ERROR**: An unknown error occurs.| 723 724### OH_ImagePackerNative_PackToDataFromPicture() 725 726``` 727Image_ErrorCode OH_ImagePackerNative_PackToDataFromPicture(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_PictureNative *picture, uint8_t *outData, size_t *size) 728``` 729 730**Description** 731 732Encodes a picture into data in a given format. 733 734**Since**: 13 735 736 737**Parameters** 738 739| Name| Description| 740| -- | -- | 741| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) *imagePacker | Pointer to an OH_ImagePackerNative object.| 742| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 743| [OH_PictureNative](capi-image-nativemodule-oh-picturenative.md) *picture | Pointer to the picture to encode.| 744| uint8_t *outData | Pointer to the buffer used to store the output data.| 745| size_t *size | Pointer to the size of the buffer.| 746 747**Returns** 748 749| Type| Description| 750| -- | -- | 751| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br>**IMAGE_DECODE_FAILED**: Decoding fails.| 752 753### OH_ImagePackerNative_PackToDataFromPixelmapSequence() 754 755``` 756Image_ErrorCode OH_ImagePackerNative_PackToDataFromPixelmapSequence(OH_ImagePackerNative *imagePacker,OH_PackingOptionsForSequence *options, OH_PixelmapNative **pixelmapSequence,size_t sequenceLength, uint8_t *outData, size_t *outDataSize) 757``` 758 759**Description** 760 761Encodes a PixelMap sequence into data. 762 763**Since**: 13 764 765 766**Parameters** 767 768| Name| Description| 769| -- | -- | 770| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) *imagePacker | Pointer to an OH_ImagePackerNative object.| 771| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) struct.| 772| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmapSequence | Double pointer to the PixelMap sequence to encode.| 773| size_t sequenceLength | Length of the PixelMap sequence.| 774| uint8_t *outData | Pointer to the buffer used to store the output data.| 775| size_t *outDataSize | Pointer to the size of the buffer.| 776 777**Returns** 778 779| Type| Description| 780| -- | -- | 781| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br>**IMAGE_DECODE_FAILED**: Decoding fails.| 782 783### OH_ImagePackerNative_PackToFileFromImageSource() 784 785``` 786Image_ErrorCode OH_ImagePackerNative_PackToFileFromImageSource(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_ImageSourceNative *imageSource, int32_t fd) 787``` 788 789**Description** 790 791Encodes an image source into a file. 792 793**Since**: 12 794 795 796**Parameters** 797 798| Name| Description| 799| -- | -- | 800| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) *imagePacker | Pointer to an OH_ImagePackerNative object.| 801| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 802| [OH_ImageSourceNative](capi-image-nativemodule-oh-imagesourcenative.md) *imageSource | Pointer to the image source to encode.| 803| int32_t fd | File descriptor, which is writable.| 804 805**Returns** 806 807| Type| Description| 808| -- | -- | 809| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br>**IMAGE_DECODE_FAILED**: Decoding fails.<br>**IMAGE_UNKNOWN_ERROR**: An unknown error occurs.| 810 811### OH_ImagePackerNative_PackToFileFromPixelmap() 812 813``` 814Image_ErrorCode OH_ImagePackerNative_PackToFileFromPixelmap(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_PixelmapNative *pixelmap, int32_t fd) 815``` 816 817**Description** 818 819Encodes a PixelMap into a file. 820 821**Since**: 12 822 823 824**Parameters** 825 826| Name| Description| 827| -- | -- | 828| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) *imagePacker | Pointer to an OH_ImagePackerNative object.| 829| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 830| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *pixelmap | Pointer to the PixelMap to encode.| 831| int32_t fd | File descriptor, which is writable.| 832 833**Returns** 834 835| Type| Description| 836| -- | -- | 837| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br>**IMAGE_DECODE_FAILED**: Decoding fails.<br>**IMAGE_UNKNOWN_ERROR**: An unknown error occurs.| 838 839### OH_ImagePackerNative_PackToFileFromPicture() 840 841``` 842Image_ErrorCode OH_ImagePackerNative_PackToFileFromPicture(OH_ImagePackerNative *imagePacker,OH_PackingOptions *options, OH_PictureNative *picture, int32_t fd) 843``` 844 845**Description** 846 847Encodes a picture into a file. 848 849**Since**: 13 850 851 852**Parameters** 853 854| Name| Description| 855| -- | -- | 856| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) *imagePacker | Pointer to an OH_ImagePackerNative object.| 857| [OH_PackingOptions](capi-image-nativemodule-oh-packingoptions.md) *options | Pointer to an OH_PackingOptions struct.| 858| [OH_PictureNative](capi-image-nativemodule-oh-picturenative.md) *picture | Pointer to the picture to encode.| 859| int32_t fd | File descriptor, which is writable.| 860 861**Returns** 862 863| Type| Description| 864| -- | -- | 865| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br>**IMAGE_DECODE_FAILED**: Decoding fails.<br>**IMAGE_UNKNOWN_ERROR**: An unknown error occurs.| 866 867### OH_ImagePackerNative_PackToFileFromPixelmapSequence() 868 869``` 870Image_ErrorCode OH_ImagePackerNative_PackToFileFromPixelmapSequence(OH_ImagePackerNative *imagePacker,OH_PackingOptionsForSequence *options, OH_PixelmapNative **pixelmapSequence, size_t sequenceLength, int32_t fd) 871``` 872 873**Description** 874 875Encodes a PixelMap sequence into a file. 876 877**Since**: 13 878 879 880**Parameters** 881 882| Name| Description| 883| -- | -- | 884| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) *imagePacker | Pointer to an OH_ImagePackerNative object.| 885| [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) *options | Pointer to an [OH_PackingOptionsForSequence](capi-image-nativemodule-oh-packingoptionsforsequence.md) struct.| 886| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmapSequence | Double pointer to the PixelMap sequence to encode.| 887| size_t sequenceLength | Length of the PixelMap sequence.| 888| int32_t fd | File descriptor, which is writable.| 889 890**Returns** 891 892| Type| Description| 893| -- | -- | 894| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br>**IMAGE_DECODE_FAILED**: Decoding fails.| 895 896### OH_ImagePackerNative_GetSupportedFormats() 897 898``` 899Image_ErrorCode OH_ImagePackerNative_GetSupportedFormats(Image_MimeType **supportedFormats, size_t *length) 900``` 901 902**Description** 903 904Obtains the supported image formats that can be encoded. 905 906**Since**: 20 907 908 909**Parameters** 910 911| Name| Description| 912| -- | -- | 913| [Image_MimeType](capi-image-nativemodule-image-string.md) **supportedFormats | Double pointer to the supported image formats.| 914| size_t *length | Pointer to the size of the array.| 915 916**Returns** 917 918| Type| Description| 919| -- | -- | 920| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br> **IMAGE_PACKER_INVALID_PARAMETER**: The **supportedFormats** or **length** parameter is a null pointer.| 921 922### OH_ImagePackerNative_Release() 923 924``` 925Image_ErrorCode OH_ImagePackerNative_Release(OH_ImagePackerNative *imagePacker) 926``` 927 928**Description** 929 930Releases the pointer to an OH_ImagePackerNative struct. 931 932**Since**: 12 933 934 935**Parameters** 936 937| Name| Description| 938| -- | -- | 939| [OH_ImagePackerNative](capi-image-nativemodule-oh-imagepackernative.md) *imagePacker | Pointer to an OH_ImagePackerNative object.| 940 941**Returns** 942 943| Type| Description| 944| -- | -- | 945| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 946