• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# image_source_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 decoding.
11
12**File to include**: <multimedia/image_framework/image/image_source_native.h>
13
14**Library**: libimage_source.so
15
16**System capability**: SystemCapability.Multimedia.Image.ImageSource
17
18**Since**: 12
19
20**Related module**: [Image_NativeModule](capi-image-nativemodule.md)
21
22## Summary
23
24### Structs
25
26| Name| typedef Keyword| Description|
27| -- | -- | -- |
28| [OH_ImageSourceNative](capi-image-nativemodule-oh-imagesourcenative.md) | OH_ImageSourceNative | Describes the image source, which is encapsulated at the native layer and is used to create image data.|
29| [OH_ImageSource_Info](capi-image-nativemodule-imagesource-info.md) | OH_ImageSource_Info | Describes the image source information, which is 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.|
30| [OH_DecodingOptionsForPicture](capi-image-nativemodule-oh-decodingoptionsforpicture.md) | OH_DecodingOptionsForPicture | Describes the decoding options for pictures. They are obtained by calling [OH_DecodingOptionsForPicture_Create](#oh_decodingoptionsforpicture_create).|
31| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) | OH_DecodingOptions | Describes the decoding options, which are encapsulated at the native layer. The struct is used to set decoding options and is passed in as an input parameter for creating a PixelMap. For details, see [OH_ImageSourceNative_CreatePixelmap](#oh_imagesourcenative_createpixelmap).|
32
33### Enums
34
35| Name| typedef Keyword| Description|
36| -- | -- | -- |
37| [IMAGE_DYNAMIC_RANGE](#image_dynamic_range) | IMAGE_DYNAMIC_RANGE | Enumerates the desired dynamic range for decoding.|
38| [IMAGE_ALLOCATOR_TYPE](#image_allocator_type) | IMAGE_ALLOCATOR_TYPE | Enumerates the types of allocators used to allocate PixelMap memory.|
39| [Image_CropAndScaleStrategy](#image_cropandscalestrategy) | Image_CropAndScaleStrategy | Enumerates the cropping and scaling strategies when **desiredSize** and **desiredRegion** are both specified.|
40
41### Functions
42
43| Name| Description|
44| -- | -- |
45| [Image_ErrorCode OH_ImageSourceInfo_Create(OH_ImageSource_Info **info)](#oh_imagesourceinfo_create) | Creates the pointer to an OH_ImageSource_Info object.|
46| [Image_ErrorCode OH_ImageSourceInfo_GetWidth(OH_ImageSource_Info *info, uint32_t *width)](#oh_imagesourceinfo_getwidth) | Obtains the image width.|
47| [Image_ErrorCode OH_ImageSourceInfo_GetHeight(OH_ImageSource_Info *info, uint32_t *height)](#oh_imagesourceinfo_getheight) | Obtains the image height.|
48| [Image_ErrorCode OH_ImageSourceInfo_GetDynamicRange(OH_ImageSource_Info *info, bool *isHdr)](#oh_imagesourceinfo_getdynamicrange) | Obtains the dynamic range of an image.|
49| [Image_ErrorCode OH_ImageSourceInfo_GetMimetype(OH_ImageSource_Info *info, Image_MimeType *mimetype)](#oh_imagesourceinfo_getmimetype) | Obtains the MIME type of an image.|
50| [Image_ErrorCode OH_ImageSourceInfo_Release(OH_ImageSource_Info *info)](#oh_imagesourceinfo_release) | Releases the pointer to an OH_ImageSource_Info object.|
51| [Image_ErrorCode OH_DecodingOptions_Create(OH_DecodingOptions **options)](#oh_decodingoptions_create) | Creates the pointer to an OH_DecodingOptions object.|
52| [Image_ErrorCode OH_DecodingOptions_GetPixelFormat(OH_DecodingOptions *options,int32_t *pixelFormat)](#oh_decodingoptions_getpixelformat) | Obtains the pixel format.|
53| [Image_ErrorCode OH_DecodingOptions_SetPixelFormat(OH_DecodingOptions *options,int32_t pixelFormat)](#oh_decodingoptions_setpixelformat) | Sets the pixel format.|
54| [Image_ErrorCode OH_DecodingOptions_GetIndex(OH_DecodingOptions *options, uint32_t *index)](#oh_decodingoptions_getindex) | Obtains the index of an image.|
55| [Image_ErrorCode OH_DecodingOptions_SetIndex(OH_DecodingOptions *options, uint32_t index)](#oh_decodingoptions_setindex) | Sets the index for an image.|
56| [Image_ErrorCode OH_DecodingOptions_GetRotate(OH_DecodingOptions *options, float *rotate)](#oh_decodingoptions_getrotate) | Obtains the rotation degree.|
57| [Image_ErrorCode OH_DecodingOptions_SetRotate(OH_DecodingOptions *options, float rotate)](#oh_decodingoptions_setrotate) | Sets the rotation angle.|
58| [Image_ErrorCode OH_DecodingOptions_GetDesiredSize(OH_DecodingOptions *options,Image_Size *desiredSize)](#oh_decodingoptions_getdesiredsize) | Obtains the desired output size.|
59| [Image_ErrorCode OH_DecodingOptions_SetDesiredSize(OH_DecodingOptions *options,Image_Size *desiredSize)](#oh_decodingoptions_setdesiredsize) | Sets the desired output size.|
60| [Image_ErrorCode OH_DecodingOptions_GetDesiredRegion(OH_DecodingOptions *options,Image_Region *desiredRegion)](#oh_decodingoptions_getdesiredregion) | Obtains the region to decode.<br> Since the corresponding **SetDesiredRegion** function cannot meet the regional decoding requirements, starting from API 19, you are advised to use [OH_DecodingOptions_GetCropRegion](#oh_decodingoptions_getcropregion) instead.|
61| [Image_ErrorCode OH_DecodingOptions_SetDesiredRegion(OH_DecodingOptions *options,Image_Region *desiredRegion)](#oh_decodingoptions_setdesiredregion) | Sets the region to decode.<br> The actual decoding will process the entire original image, without any regional decoding effect. Starting from API 19, you are advised to use [OH_DecodingOptions_SetCropRegion](#oh_decodingoptions_setcropregion) instead.|
62| [Image_ErrorCode OH_DecodingOptions_GetDesiredDynamicRange(OH_DecodingOptions *options,int32_t *desiredDynamicRange)](#oh_decodingoptions_getdesireddynamicrange) | Obtains the desired dynamic range configured during decoding.|
63| [Image_ErrorCode OH_DecodingOptions_SetDesiredDynamicRange(OH_DecodingOptions *options,int32_t desiredDynamicRange)](#oh_decodingoptions_setdesireddynamicrange) | Sets the desired dynamic range during decoding.|
64| [Image_ErrorCode OH_DecodingOptions_GetDesiredColorSpace(OH_DecodingOptions *options, int32_t *colorSpace)](#oh_decodingoptions_getdesiredcolorspace) | Obtains the color space set in the decoding options.|
65| [Image_ErrorCode OH_DecodingOptions_SetDesiredColorSpace(OH_DecodingOptions *options, int32_t colorSpace)](#oh_decodingoptions_setdesiredcolorspace) | Sets the desired color space for the decoding options.|
66| [Image_ErrorCode OH_DecodingOptions_SetCropAndScaleStrategy(OH_DecodingOptions *options,int32_t cropAndScaleStrategy)](#oh_decodingoptions_setcropandscalestrategy) | Sets the cropping and scaling strategy used during decoding.|
67| [Image_ErrorCode OH_DecodingOptions_GetCropAndScaleStrategy(OH_DecodingOptions *options,int32_t *cropAndScaleStrategy)](#oh_decodingoptions_getcropandscalestrategy) | Obtains the cropping and scaling strategy used during decoding.|
68| [Image_ErrorCode OH_DecodingOptions_GetCropRegion(OH_DecodingOptions *options, Image_Region *cropRegion)](#oh_decodingoptions_getcropregion) | Obtains the cropping region in the decoding options.|
69| [Image_ErrorCode OH_DecodingOptions_SetCropRegion(OH_DecodingOptions *options, Image_Region *cropRegion)](#oh_decodingoptions_setcropregion) | Sets the cropping region in the decoding options.|
70| [Image_ErrorCode OH_DecodingOptions_Release(OH_DecodingOptions *options)](#oh_decodingoptions_release) | Releases the pointer to an OH_DecodingOptions object.|
71| [Image_ErrorCode OH_ImageSourceNative_CreateFromUri(char *uri, size_t uriSize, OH_ImageSourceNative **res)](#oh_imagesourcenative_createfromuri) | Creates the pointer to an OH_ImageSourceNative object based on a URI.|
72| [Image_ErrorCode OH_ImageSourceNative_CreateFromFd(int32_t fd, OH_ImageSourceNative **res)](#oh_imagesourcenative_createfromfd) | Creates the pointer to an OH_ImageSourceNative object based on a file descriptor.|
73| [Image_ErrorCode OH_ImageSourceNative_CreateFromData(uint8_t *data, size_t dataSize, OH_ImageSourceNative **res)](#oh_imagesourcenative_createfromdata) | Creates the pointer to an OH_ImageSourceNative object based on buffer data.<br> The buffer data must be undecoded. Do not pass the pixel buffer data such as RBGA and YUV. If you want to create a PixelMap based on the pixel buffer data, call [OH_PixelmapNative_CreatePixelmap](capi-pixelmap-native-h.md#oh_pixelmapnative_createpixelmap).|
74| [Image_ErrorCode OH_ImageSourceNative_CreateFromDataWithUserBuffer(uint8_t *data, size_t datalength,OH_ImageSourceNative **imageSource)](#oh_imagesourcenative_createfromdatawithuserbuffer) | Creates an image source from data buffer. The data buffer is directly accessed by the image source object, and therefore the data buffer must remain accessible within the lifecycle of the image source object.|
75| [Image_ErrorCode OH_ImageSourceNative_CreateFromRawFile(RawFileDescriptor *rawFile, OH_ImageSourceNative **res)](#oh_imagesourcenative_createfromrawfile) | Creates the pointer to an OH_ImageSourceNative object by using the raw file descriptor of an image resource file.|
76| [Image_ErrorCode OH_ImageSourceNative_CreatePixelmap(OH_ImageSourceNative *source, OH_DecodingOptions *options,OH_PixelmapNative **pixelmap)](#oh_imagesourcenative_createpixelmap) | Creates the pointer to an OH_PixelmapNative object based on decoding options.|
77| [Image_ErrorCode OH_ImageSourceNative_CreatePixelmapUsingAllocator(OH_ImageSourceNative *source,OH_DecodingOptions *options, IMAGE_ALLOCATOR_TYPE allocator, OH_PixelmapNative **pixelmap)](#oh_imagesourcenative_createpixelmapusingallocator) | Creates an OH_PixelmapNative object based on decoding options and memory type, where **allocatorType** specifies the memory type of the PixelMap.<br> By default, the system selects an appropriate memory type based on the image type, image size, and platform capability. When processing the returned PixelMap object, consider the impact of stride.|
78| [Image_ErrorCode OH_ImageSourceNative_CreatePixelmapList(OH_ImageSourceNative *source, OH_DecodingOptions *options,OH_PixelmapNative *resVecPixMap[], size_t size)](#oh_imagesourcenative_createpixelmaplist) | Creates an array of OH_PixelmapNative objects based on decoding options.<br> This function decodes all frames at once. If the number of frames is high or the size of individual frames is large, it can lead to significant memory usage. In these cases, you are advised to use the **Image** component for displaying animations. The **Image** component decodes frames one by one, which uses less memory than this function.|
79| [Image_ErrorCode OH_ImageSourceNative_CreatePicture(OH_ImageSourceNative *source, OH_DecodingOptionsForPicture *options,OH_PictureNative **picture)](#oh_imagesourcenative_createpicture) | Creates the pointer to an OH_PictureNative object based on decoding options.|
80| [Image_ErrorCode OH_ImageSourceNative_CreatePictureAtIndex(OH_ImageSourceNative *source, uint32_t index,OH_PictureNative **picture)](#oh_imagesourcenative_createpictureatindex) | Creates the pointer to an OH_PictureNative object at the specified index.|
81| [Image_ErrorCode OH_ImageSourceNative_GetDelayTimeList(OH_ImageSourceNative *source, int32_t *delayTimeList, size_t size)](#oh_imagesourcenative_getdelaytimelist) | Obtains the image delay time list.|
82| [Image_ErrorCode OH_ImageSourceNative_GetImageInfo(OH_ImageSourceNative *source, int32_t index,OH_ImageSource_Info *info)](#oh_imagesourcenative_getimageinfo) | Obtains the information about an image with a given index.|
83| [Image_ErrorCode OH_ImageSourceNative_GetImageProperty(OH_ImageSourceNative *source, Image_String *key,Image_String *value)](#oh_imagesourcenative_getimageproperty) | Obtains the value of an image property.|
84| [Image_ErrorCode OH_ImageSourceNative_GetImagePropertyWithNull(OH_ImageSourceNative *source, Image_String *key,Image_String *value)](#oh_imagesourcenative_getimagepropertywithnull) | Obtains the value of an image property. The output **value.data** is terminated with a string terminator.|
85| [Image_ErrorCode OH_ImageSourceNative_ModifyImageProperty(OH_ImageSourceNative *source, Image_String *key,Image_String *value)](#oh_imagesourcenative_modifyimageproperty) | Modifies the value of an image property.|
86| [Image_ErrorCode OH_ImageSourceNative_GetFrameCount(OH_ImageSourceNative *source, uint32_t *frameCount)](#oh_imagesourcenative_getframecount) | Obtains the number of image frames.|
87| [Image_ErrorCode OH_ImageSourceNative_GetSupportedFormats(Image_MimeType **supportedFormats, size_t *length)](#oh_imagesourcenative_getsupportedformats) | Obtains the supported image formats that can be decoded.|
88| [Image_ErrorCode OH_ImageSourceNative_Release(OH_ImageSourceNative *source)](#oh_imagesourcenative_release) | Releases the pointer to an OH_ImageSourceNative object.|
89| [Image_ErrorCode OH_DecodingOptionsForPicture_Create(OH_DecodingOptionsForPicture **options)](#oh_decodingoptionsforpicture_create) | Creates the pointer to an OH_DecodingOptionsForPicture object.|
90| [Image_ErrorCode OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options,Image_AuxiliaryPictureType **desiredAuxiliaryPictures, size_t *length)](#oh_decodingoptionsforpicture_getdesiredauxiliarypictures) | Obtains desired auxiliary pictures in the decoding options (auxiliary pictures contained in **picture** expected to be decoded.)|
91| [Image_ErrorCode OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options,Image_AuxiliaryPictureType *desiredAuxiliaryPictures, size_t length)](#oh_decodingoptionsforpicture_setdesiredauxiliarypictures) | Sets desired auxiliary pictures in the decoding options.|
92| [Image_ErrorCode OH_DecodingOptionsForPicture_Release(OH_DecodingOptionsForPicture *options)](#oh_decodingoptionsforpicture_release) | Releases the pointer to an OH_DecodingOptionsForPicture object.|
93
94## Enum Description
95
96### IMAGE_DYNAMIC_RANGE
97
98```
99enum IMAGE_DYNAMIC_RANGE
100```
101
102**Description**
103
104Enumerates the desired dynamic range for decoding.
105
106**Since**: 12
107
108| Enum Item| Description|
109| -- | -- |
110| IMAGE_DYNAMIC_RANGE_AUTO = 0 | Adaptive processing.|
111| IMAGE_DYNAMIC_RANGE_SDR = 1 | Standard dynamic range (SDR).|
112| IMAGE_DYNAMIC_RANGE_HDR = 2 | High dynamic range (HDR).|
113
114### IMAGE_ALLOCATOR_TYPE
115
116```
117enum IMAGE_ALLOCATOR_TYPE
118```
119
120**Description**
121
122Enumerates the types of allocators used to allocate PixelMap memory.
123
124**Since**: 15
125
126| Enum Item| Description|
127| -- | -- |
128| IMAGE_ALLOCATOR_TYPE_AUTO = 0 | The system determines whether to use DMA memory or shared memory to create a PixelMap.|
129| IMAGE_ALLOCATOR_TYPE_DMA = 1 | DMA memory is used to create a PixelMap.|
130| IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY = 2 | Shared memory is used to create a PixelMap.|
131
132### Image_CropAndScaleStrategy
133
134```
135enum Image_CropAndScaleStrategy
136```
137
138**Description**
139
140Enumerates the cropping and scaling strategies when **desiredSize** and **desiredRegion** are both specified.<br> If the **ImageCropAndScaleStrategy** parameter is not specified in [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) and both **desiredRegion** and **desiredSize** are set, the final decoding result may vary slightly due to differences in decoding algorithms used for different image formats.<br> For example, if the original image size is 200x200, and you specify **desiredSize:{width: 150, height: 150}, desiredRegion:{x: 0, y: 0, width: 100, height: 100}**, the expectation is to decode the top-left 1/4 region of the original image and then scale the pixelMap size to 150x150.<br> For JPEG and WebP images (as well as some DNG images that decode a JPEG preview within the file and therefore are treated as JPEG format), the system first performs downsampling. For instance, it might downsample by 7/8 and then crop the region based on a 175x175 image size. As a result, the final cropped region will be slightly larger than the top-left 1/4 of the original image.<br> For SVG images, which are vector-based and can be scaled without losing clarity, the system scales the image based on the ratio of **desiredSize** to the original image size and then crops the region. This results in a decoded region that may differ from the exact 1/4 region of the original image.<br> To ensure consistent results when both **desiredRegion** and **desiredSize** are set, set the **ImageCropAndScaleStrategy** parameter to **CROP_FIRST**.
141
142**Since**: 18
143
144| Enum Item| Description|
145| -- | -- |
146| IMAGE_CROP_AND_SCALE_STRATEGY_SCALE_FIRST = 1 | Crops and then scales the image.|
147| IMAGE_CROP_AND_SCALE_STRATEGY_CROP_FIRST = 2 | Scales and then crops the image.|
148
149
150## Function Description
151
152### OH_ImageSourceInfo_Create()
153
154```
155Image_ErrorCode OH_ImageSourceInfo_Create(OH_ImageSource_Info **info)
156```
157
158**Description**
159
160Creates the pointer to an OH_ImageSource_Info object.
161
162**Since**: 12
163
164
165**Parameters**
166
167| Name| Description|
168| -- | -- |
169| [OH_ImageSource_Info](capi-image-nativemodule-imagesource-info.md) **info | Double pointer to the OH_ImageSource_Info object created.|
170
171**Returns**
172
173| Type| Description|
174| -- | -- |
175| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
176
177### OH_ImageSourceInfo_GetWidth()
178
179```
180Image_ErrorCode OH_ImageSourceInfo_GetWidth(OH_ImageSource_Info *info, uint32_t *width)
181```
182
183**Description**
184
185Obtains the image width.
186
187**Since**: 12
188
189
190**Parameters**
191
192| Name| Description|
193| -- | -- |
194| [OH_ImageSource_Info](capi-image-nativemodule-imagesource-info.md) *info | Pointer to an OH_ImageSource_Info object.|
195| uint32_t *width | Pointer to the image width, in px.|
196
197**Returns**
198
199| Type| Description|
200| -- | -- |
201| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
202
203### OH_ImageSourceInfo_GetHeight()
204
205```
206Image_ErrorCode OH_ImageSourceInfo_GetHeight(OH_ImageSource_Info *info, uint32_t *height)
207```
208
209**Description**
210
211Obtains the image height.
212
213**Since**: 12
214
215
216**Parameters**
217
218| Name| Description|
219| -- | -- |
220| [OH_ImageSource_Info](capi-image-nativemodule-imagesource-info.md) *info | Pointer to an OH_ImageSource_Info object.|
221| uint32_t *height | Pointer to the image height, in px.|
222
223**Returns**
224
225| Type| Description|
226| -- | -- |
227| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
228
229### OH_ImageSourceInfo_GetDynamicRange()
230
231```
232Image_ErrorCode OH_ImageSourceInfo_GetDynamicRange(OH_ImageSource_Info *info, bool *isHdr)
233```
234
235**Description**
236
237Obtains the dynamic range of an image.
238
239**Since**: 12
240
241
242**Parameters**
243
244| Name| Description|
245| -- | -- |
246| [OH_ImageSource_Info](capi-image-nativemodule-imagesource-info.md) *info | Pointer to an OH_ImageSource_Info object.|
247| bool *isHdr | Pointer to a Boolean that specifies whether the HDR is used.|
248
249**Returns**
250
251| Type| Description|
252| -- | -- |
253| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
254
255### OH_ImageSourceInfo_GetMimetype()
256
257```
258Image_ErrorCode OH_ImageSourceInfo_GetMimetype(OH_ImageSource_Info *info, Image_MimeType *mimetype)
259```
260
261**Description**
262
263Obtains the MIME type of an image.
264
265**Since**: 20
266
267
268**Parameters**
269
270| Name| Description|
271| -- | -- |
272| [OH_ImageSource_Info](capi-image-nativemodule-imagesource-info.md) *info | Pointer to an OH_ImageSource_Info object.|
273| [Image_MimeType](capi-image-nativemodule-image-string.md) *mimetype | Pointer to the MIME type.|
274
275**Returns**
276
277| Type| Description|
278| -- | -- |
279| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_SOURCE_INVALID_PARAMETER**: A parameter is incorrect. The **info** or **mimetype** parameter is a null pointer.|
280
281### OH_ImageSourceInfo_Release()
282
283```
284Image_ErrorCode OH_ImageSourceInfo_Release(OH_ImageSource_Info *info)
285```
286
287**Description**
288
289Releases the pointer to an OH_ImageSource_Info object.
290
291**Since**: 12
292
293
294**Parameters**
295
296| Name| Description|
297| -- | -- |
298| [OH_ImageSource_Info](capi-image-nativemodule-imagesource-info.md) *info | Pointer to an OH_ImageSource_Info object.|
299
300**Returns**
301
302| Type| Description|
303| -- | -- |
304| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
305
306### OH_DecodingOptions_Create()
307
308```
309Image_ErrorCode OH_DecodingOptions_Create(OH_DecodingOptions **options)
310```
311
312**Description**
313
314Creates the pointer to an OH_DecodingOptions object.
315
316**Since**: 12
317
318
319**Parameters**
320
321| Name| Description|
322| -- | -- |
323| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) **options | Double pointer to the OH_DecodingOptions object created.|
324
325**Returns**
326
327| Type| Description|
328| -- | -- |
329| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
330
331### OH_DecodingOptions_GetPixelFormat()
332
333```
334Image_ErrorCode OH_DecodingOptions_GetPixelFormat(OH_DecodingOptions *options,int32_t *pixelFormat)
335```
336
337**Description**
338
339Obtains the pixel format.
340
341**Since**: 12
342
343
344**Parameters**
345
346| Name| Description|
347| -- | -- |
348| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
349| int32_t *pixelFormat | Pointer to the pixel format. For details about the available options, see [PIXEL_FORMAT](capi-pixelmap-native-h.md#pixel_format).|
350
351**Returns**
352
353| Type| Description|
354| -- | -- |
355| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
356
357### OH_DecodingOptions_SetPixelFormat()
358
359```
360Image_ErrorCode OH_DecodingOptions_SetPixelFormat(OH_DecodingOptions *options,int32_t pixelFormat)
361```
362
363**Description**
364
365Sets the pixel format.
366
367**Since**: 12
368
369
370**Parameters**
371
372| Name| Description|
373| -- | -- |
374| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
375| int32_t pixelFormat | Pixel format. For details about the available options, see [PIXEL_FORMAT](capi-pixelmap-native-h.md#pixel_format).|
376
377**Returns**
378
379| Type| Description|
380| -- | -- |
381| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
382
383### OH_DecodingOptions_GetIndex()
384
385```
386Image_ErrorCode OH_DecodingOptions_GetIndex(OH_DecodingOptions *options, uint32_t *index)
387```
388
389**Description**
390
391Obtains the index of an image.
392
393**Since**: 12
394
395
396**Parameters**
397
398| Name| Description|
399| -- | -- |
400| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
401| uint32_t *index | Pointer to the index of the image.|
402
403**Returns**
404
405| Type| Description|
406| -- | -- |
407| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
408
409### OH_DecodingOptions_SetIndex()
410
411```
412Image_ErrorCode OH_DecodingOptions_SetIndex(OH_DecodingOptions *options, uint32_t index)
413```
414
415**Description**
416
417Sets the index for an image.
418
419**Since**: 12
420
421
422**Parameters**
423
424| Name| Description|
425| -- | -- |
426| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
427| uint32_t index | Index of the image.|
428
429**Returns**
430
431| Type| Description|
432| -- | -- |
433| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
434
435### OH_DecodingOptions_GetRotate()
436
437```
438Image_ErrorCode OH_DecodingOptions_GetRotate(OH_DecodingOptions *options, float *rotate)
439```
440
441**Description**
442
443Obtains the rotation degree.
444
445**Since**: 12
446
447
448**Parameters**
449
450| Name| Description|
451| -- | -- |
452| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
453| float *rotate | Pointer to the angle to rotate, in degrees.|
454
455**Returns**
456
457| Type| Description|
458| -- | -- |
459| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
460
461### OH_DecodingOptions_SetRotate()
462
463```
464Image_ErrorCode OH_DecodingOptions_SetRotate(OH_DecodingOptions *options, float rotate)
465```
466
467**Description**
468
469Sets the rotation angle.
470
471**Since**: 12
472
473
474**Parameters**
475
476| Name| Description|
477| -- | -- |
478| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
479| float rotate | Angle to rotate, in degrees.|
480
481**Returns**
482
483| Type| Description|
484| -- | -- |
485| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
486
487### OH_DecodingOptions_GetDesiredSize()
488
489```
490Image_ErrorCode OH_DecodingOptions_GetDesiredSize(OH_DecodingOptions *options,Image_Size *desiredSize)
491```
492
493**Description**
494
495Obtains the desired output size.
496
497**Since**: 12
498
499
500**Parameters**
501
502| Name| Description|
503| -- | -- |
504| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
505| [Image_Size](capi-image-nativemodule-image-size.md) *desiredSize | Pointer to the desired output size.|
506
507**Returns**
508
509| Type| Description|
510| -- | -- |
511| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
512
513### OH_DecodingOptions_SetDesiredSize()
514
515```
516Image_ErrorCode OH_DecodingOptions_SetDesiredSize(OH_DecodingOptions *options,Image_Size *desiredSize)
517```
518
519**Description**
520
521Sets the desired output size.
522
523**Since**: 12
524
525
526**Parameters**
527
528| Name| Description|
529| -- | -- |
530| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
531| [Image_Size](capi-image-nativemodule-image-size.md) *desiredSize | Pointer to the desired output size.|
532
533**Returns**
534
535| Type| Description|
536| -- | -- |
537| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
538
539### OH_DecodingOptions_GetDesiredRegion()
540
541```
542Image_ErrorCode OH_DecodingOptions_GetDesiredRegion(OH_DecodingOptions *options,Image_Region *desiredRegion)
543```
544
545**Description**
546
547Obtains the region to decode.<br> Since the corresponding **SetDesiredRegion** function cannot meet the regional decoding requirements, starting from API 19, you are advised to use [OH_DecodingOptions_GetCropRegion](#oh_decodingoptions_getcropregion) instead.
548
549**Since**: 12
550
551
552**Parameters**
553
554| Name| Description|
555| -- | -- |
556| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
557| [Image_Region](capi-image-nativemodule-image-region.md) *desiredRegion | Pointer to the region to decode.|
558
559**Returns**
560
561| Type| Description|
562| -- | -- |
563| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
564
565### OH_DecodingOptions_SetDesiredRegion()
566
567```
568Image_ErrorCode OH_DecodingOptions_SetDesiredRegion(OH_DecodingOptions *options,Image_Region *desiredRegion)
569```
570
571**Description**
572
573Sets the region to decode.<br> The actual decoding will process the entire original image, without any regional decoding effect. Starting from API 19, you are advised to use [OH_DecodingOptions_SetCropRegion](#oh_decodingoptions_setcropregion) instead.
574
575**Since**: 12
576
577
578**Parameters**
579
580| Name| Description|
581| -- | -- |
582| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
583| [Image_Region](capi-image-nativemodule-image-region.md) *desiredRegion | Pointer to the region to decode.|
584
585**Returns**
586
587| Type| Description|
588| -- | -- |
589| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
590
591### OH_DecodingOptions_GetDesiredDynamicRange()
592
593```
594Image_ErrorCode OH_DecodingOptions_GetDesiredDynamicRange(OH_DecodingOptions *options,int32_t *desiredDynamicRange)
595```
596
597**Description**
598
599Obtains the desired dynamic range configured during decoding.
600
601**Since**: 12
602
603
604**Parameters**
605
606| Name| Description|
607| -- | -- |
608| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
609| int32_t *desiredDynamicRange | Pointer to the desired dynamic range. For details about the available options, see [IMAGE_DYNAMIC_RANGE](#image_dynamic_range).|
610
611**Returns**
612
613| Type| Description|
614| -- | -- |
615| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
616
617### OH_DecodingOptions_SetDesiredDynamicRange()
618
619```
620Image_ErrorCode OH_DecodingOptions_SetDesiredDynamicRange(OH_DecodingOptions *options,int32_t desiredDynamicRange)
621```
622
623**Description**
624
625Sets the desired dynamic range during decoding.
626
627**Since**: 12
628
629
630**Parameters**
631
632| Name| Description|
633| -- | -- |
634| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
635| int32_t desiredDynamicRange | Desired dynamic range. For details about the available options, see [IMAGE_DYNAMIC_RANGE](#image_dynamic_range).|
636
637**Returns**
638
639| Type| Description|
640| -- | -- |
641| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
642
643### OH_DecodingOptions_GetDesiredColorSpace()
644
645```
646Image_ErrorCode OH_DecodingOptions_GetDesiredColorSpace(OH_DecodingOptions *options, int32_t *colorSpace)
647```
648
649**Description**
650
651Obtains the color space set in the decoding options.
652
653**Since**: 20
654
655
656**Parameters**
657
658| Name| Description|
659| -- | -- |
660| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to the decoding options.|
661| int32_t *colorSpace | Pointer to the color space. For details, see [ColorSpaceName](../apis-arkgraphics2d/capi-native-color-space-manager-h.md#colorspacename).|
662
663**Returns**
664
665| Type| Description|
666| -- | -- |
667| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_SOURCE_INVALID_PARAMETER**: A parameter is incorrect. The **options** or **colorSpace** parameter is a null pointer.|
668
669### OH_DecodingOptions_SetDesiredColorSpace()
670
671```
672Image_ErrorCode OH_DecodingOptions_SetDesiredColorSpace(OH_DecodingOptions *options, int32_t colorSpace)
673```
674
675**Description**
676
677Sets the desired color space for the decoding options.
678
679**Since**: 20
680
681
682**Parameters**
683
684| Name| Description|
685| -- | -- |
686| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to the decoding options.|
687| int32_t colorSpace | Color space. For details, see [ColorSpaceName](../apis-arkgraphics2d/capi-native-color-space-manager-h.md#colorspacename).|
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_SOURCE_INVALID_PARAMETER**: A parameter is incorrect. The **options** parameter is a null pointer or the value of **colorSpace** is not supported.|
694
695### OH_DecodingOptions_SetCropAndScaleStrategy()
696
697```
698Image_ErrorCode OH_DecodingOptions_SetCropAndScaleStrategy(OH_DecodingOptions *options,int32_t cropAndScaleStrategy)
699```
700
701**Description**
702
703Sets the cropping and scaling strategy used during decoding.
704
705**Since**: 18
706
707
708**Parameters**
709
710| Name| Description|
711| -- | -- |
712| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
713| int32_t cropAndScaleStrategy | Cropping and scaling strategy that is executed when **desiredSize** and **desiredRegion** are both specified.|
714
715**Returns**
716
717| Type| Description|
718| -- | -- |
719| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: The **options** parameter is a null pointer or the value of **cropAndScaleStrategy** is not within an enumerated value defined by **Image_CropAndScaleStrategy**.|
720
721### OH_DecodingOptions_GetCropAndScaleStrategy()
722
723```
724Image_ErrorCode OH_DecodingOptions_GetCropAndScaleStrategy(OH_DecodingOptions *options,int32_t *cropAndScaleStrategy)
725```
726
727**Description**
728
729Obtains the cropping and scaling strategy used during decoding.
730
731**Since**: 18
732
733
734**Parameters**
735
736| Name| Description|
737| -- | -- |
738| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
739| int32_t *cropAndScaleStrategy | Pointer to the cropping and scaling strategy that is executed when **desiredSize** and **desiredRegion** are both specified.|
740
741**Returns**
742
743| Type| Description|
744| -- | -- |
745| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: The **options** or **cropAndScaleStrategy** parameter is a null pointer.|
746
747### OH_DecodingOptions_GetCropRegion()
748
749```
750Image_ErrorCode OH_DecodingOptions_GetCropRegion(OH_DecodingOptions *options, Image_Region *cropRegion)
751```
752
753**Description**
754
755Obtains the cropping region in the decoding options.
756
757**Since**: 19
758
759
760**Parameters**
761
762| Name| Description|
763| -- | -- |
764| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to the decoding options.|
765| [Image_Region](capi-image-nativemodule-image-region.md) *cropRegion | Pointer to the cropping region.|
766
767**Returns**
768
769| Type| Description|
770| -- | -- |
771| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_SOURCE_INVALID_PARAMETER**: The **options** or **cropRegion** parameter is a null pointer.|
772
773### OH_DecodingOptions_SetCropRegion()
774
775```
776Image_ErrorCode OH_DecodingOptions_SetCropRegion(OH_DecodingOptions *options, Image_Region *cropRegion)
777```
778
779**Description**
780
781Sets the cropping region in the decoding options.
782
783**Since**: 19
784
785
786**Parameters**
787
788| Name| Description|
789| -- | -- |
790| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to the decoding options.|
791| [Image_Region](capi-image-nativemodule-image-region.md) *cropRegion | Pointer to the cropping region.|
792
793**Returns**
794
795| Type| Description|
796| -- | -- |
797| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_SOURCE_INVALID_PARAMETER**: The **options** or **cropRegion** parameter is a null pointer.|
798
799### OH_DecodingOptions_Release()
800
801```
802Image_ErrorCode OH_DecodingOptions_Release(OH_DecodingOptions *options)
803```
804
805**Description**
806
807Releases the pointer to an OH_DecodingOptions object.
808
809**Since**: 12
810
811
812**Parameters**
813
814| Name| Description|
815| -- | -- |
816| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to an OH_DecodingOptions object.|
817
818**Returns**
819
820| Type| Description|
821| -- | -- |
822| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
823
824### OH_ImageSourceNative_CreateFromUri()
825
826```
827Image_ErrorCode OH_ImageSourceNative_CreateFromUri(char *uri, size_t uriSize, OH_ImageSourceNative **res)
828```
829
830**Description**
831
832Creates the pointer to an OH_ImageSourceNative object based on a URI.
833
834**Since**: 12
835
836
837**Parameters**
838
839| Name| Description|
840| -- | -- |
841| char *uri | Pointer to the URI of the image source. Only file URIs or Base64 URIs are accepted. Currently, only absolute paths are supported.|
842| size_t uriSize | URI length.|
843| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) **res | Double pointer to the OH_ImageSourceNative object created at the C++ local layer.|
844
845**Returns**
846
847| Type| Description|
848| -- | -- |
849| [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_BAD_SOURCE**: The decoding data source is abnormal.|
850
851### OH_ImageSourceNative_CreateFromFd()
852
853```
854Image_ErrorCode OH_ImageSourceNative_CreateFromFd(int32_t fd, OH_ImageSourceNative **res)
855```
856
857**Description**
858
859Creates the pointer to an OH_ImageSourceNative object based on a file descriptor.
860
861**Since**: 12
862
863
864**Parameters**
865
866| Name| Description|
867| -- | -- |
868| int32_t fd | File descriptor.|
869| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) **res | Double pointer to the OH_ImageSourceNative object created at the C++ local layer.|
870
871**Returns**
872
873| Type| Description|
874| -- | -- |
875| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
876
877### OH_ImageSourceNative_CreateFromData()
878
879```
880Image_ErrorCode OH_ImageSourceNative_CreateFromData(uint8_t *data, size_t dataSize, OH_ImageSourceNative **res)
881```
882
883**Description**
884
885Creates the pointer to an OH_ImageSourceNative object based on buffer data.<br> The buffer data must be undecoded. Do not pass the pixel buffer data such as RBGA and YUV. If you want to create a PixelMap based on the pixel buffer data, call [OH_PixelmapNative_CreatePixelmap](capi-pixelmap-native-h.md#oh_pixelmapnative_createpixelmap).
886
887**Since**: 12
888
889
890**Parameters**
891
892| Name| Description|
893| -- | -- |
894| uint8_t *data | Pointer to the buffer data.|
895| size_t dataSize | Size of the buffer.|
896| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) **res | Double pointer to the OH_ImageSourceNative object created at the C++ local layer.|
897
898**Returns**
899
900| Type| Description|
901| -- | -- |
902| [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_BAD_SOURCE**: The decoding data source is abnormal.|
903
904### OH_ImageSourceNative_CreateFromDataWithUserBuffer()
905
906```
907Image_ErrorCode OH_ImageSourceNative_CreateFromDataWithUserBuffer(uint8_t *data, size_t datalength,OH_ImageSourceNative **imageSource)
908```
909
910**Description**
911
912Creates an image source from data buffer. The data buffer is directly accessed by the image source object, and therefore the data buffer must remain accessible within the lifecycle of the image source object.
913
914**Since**: 20
915
916
917**Parameters**
918
919| Name| Description|
920| -- | -- |
921| uint8_t *data | Pointer to the data buffer.|
922| size_t datalength | Size of the data buffer.|
923| [OH_ImageSourceNative](capi-image-nativemodule-oh-imagesourcenative.md) **imageSource | Double pointer to the image source.|
924
925**Returns**
926
927| Type| Description|
928| -- | -- |
929| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_SOURCE_INVALID_PARAMETER**: The **data** or **imageSource** parameter is a null pointer or the **datalength** parameter is **0**.|
930
931### OH_ImageSourceNative_CreateFromRawFile()
932
933```
934Image_ErrorCode OH_ImageSourceNative_CreateFromRawFile(RawFileDescriptor *rawFile, OH_ImageSourceNative **res)
935```
936
937**Description**
938
939Creates the pointer to an OH_ImageSourceNative object by using the raw file descriptor of an image resource file.
940
941**Since**: 12
942
943
944**Parameters**
945
946| Name| Description|
947| -- | -- |
948| [RawFileDescriptor](../apis-localization-kit/capi-rawfile-rawfiledescriptor.md) *rawFile | Pointer to the file descriptor of the raw file.|
949| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) **res | Double pointer to the OH_ImageSourceNative object created at the C++ local layer.|
950
951**Returns**
952
953| Type| Description|
954| -- | -- |
955| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
956
957### OH_ImageSourceNative_CreatePixelmap()
958
959```
960Image_ErrorCode OH_ImageSourceNative_CreatePixelmap(OH_ImageSourceNative *source, OH_DecodingOptions *options,OH_PixelmapNative **pixelmap)
961```
962
963**Description**
964
965Creates the pointer to an OH_PixelmapNative object based on decoding options.
966
967**Since**: 12
968
969
970**Parameters**
971
972| Name| Description|
973| -- | -- |
974| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
975| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to the decoding options.|
976| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmap | Double pointer to the OH_PixelmapNative object created at the C++ local layer.|
977
978**Returns**
979
980| Type| Description|
981| -- | -- |
982| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
983
984### OH_ImageSourceNative_CreatePixelmapUsingAllocator()
985
986```
987Image_ErrorCode OH_ImageSourceNative_CreatePixelmapUsingAllocator(OH_ImageSourceNative *source,OH_DecodingOptions *options, IMAGE_ALLOCATOR_TYPE allocator, OH_PixelmapNative **pixelmap)
988```
989
990**Description**
991
992Creates an OH_PixelmapNative object based on decoding options and memory type, where **allocatorType** specifies the memory type of the PixelMap.<br> By default, the system selects an appropriate memory type based on the image type, image size, and platform capability. When processing the returned PixelMap object, consider the impact of stride.
993
994**Since**: 15
995
996
997**Parameters**
998
999| Name| Description|
1000| -- | -- |
1001| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1002| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to the decoding options.|
1003| [IMAGE_ALLOCATOR_TYPE](#image_allocator_type) allocator | Memory type used by the returned PixelMap.|
1004| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) **pixelmap | Double pointer to the OH_PixelmapNative object created at the C++ local layer.|
1005
1006**Returns**
1007
1008| Type| Description|
1009| -- | -- |
1010| [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_BAD_SOURCE**: The data source is abnormal.<br>         **IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE**: The MIME type is not supported.<br>         **IMAGE_SOURCE_TOO_LARGE**: The image is too large.<br>         **IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE**: The allocator type is not supported. For example, decoding HDR images using shared memory is not supported because only DMA supports HDR metadata.<br>         **IMAGE_SOURCE_UNSUPPORTED_OPTIONS**: The options are not supported. For example, an image cannot be converted into the required pixel format.<br>         **IMAGE_DECODE_FAILED**: Decoding fails.<br>         **IMAGE_SOURCE_ALLOC_FAILED**: The memory allocation fails.|
1011
1012### OH_ImageSourceNative_CreatePixelmapList()
1013
1014```
1015Image_ErrorCode OH_ImageSourceNative_CreatePixelmapList(OH_ImageSourceNative *source, OH_DecodingOptions *options,OH_PixelmapNative *resVecPixMap[], size_t size)
1016```
1017
1018**Description**
1019
1020Creates an array of OH_PixelmapNative objects based on decoding options.<br> This function decodes all frames at once. If the number of frames is high or the size of individual frames is large, it can lead to significant memory usage. In these cases, you are advised to use the **Image** component for displaying animations. The **Image** component decodes frames one by one, which uses less memory than this function.
1021
1022**Since**: 12
1023
1024
1025**Parameters**
1026
1027| Name| Description|
1028| -- | -- |
1029| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1030| [OH_DecodingOptions](capi-image-nativemodule-oh-decodingoptions.md) *options | Pointer to the decoding options.|
1031| [OH_PixelmapNative](capi-image-nativemodule-oh-pixelmapnative.md) *resVecPixMap[] | Pointer to an array of OH_PixelmapNative objects created at the C++ local layer.|
1032| size_t size | Size of the array. You can use [OH_ImageSourceNative_GetFrameCount](#oh_imagesourcenative_getframecount) to obtain the size.|
1033
1034**Returns**
1035
1036| Type| Description|
1037| -- | -- |
1038| [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_UNSUPPORTED_OPERATION**: The operation is not supported.|
1039
1040### OH_ImageSourceNative_CreatePicture()
1041
1042```
1043Image_ErrorCode OH_ImageSourceNative_CreatePicture(OH_ImageSourceNative *source, OH_DecodingOptionsForPicture *options,OH_PictureNative **picture)
1044```
1045
1046**Description**
1047
1048Creates the pointer to an OH_PictureNative object based on decoding options.
1049
1050**Since**: 13
1051
1052
1053**Parameters**
1054
1055| Name| Description|
1056| -- | -- |
1057| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1058| [OH_DecodingOptionsForPicture](capi-image-nativemodule-oh-decodingoptionsforpicture.md) *options | Pointer to the decoding options.|
1059| [OH_PictureNative](capi-image-nativemodule-oh-picturenative.md) **picture | Double pointer to the OH_PictureNative object created at the C++ local layer.|
1060
1061**Returns**
1062
1063| Type| Description|
1064| -- | -- |
1065| [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.|
1066
1067### OH_ImageSourceNative_CreatePictureAtIndex()
1068
1069```
1070Image_ErrorCode OH_ImageSourceNative_CreatePictureAtIndex(OH_ImageSourceNative *source, uint32_t index,OH_PictureNative **picture)
1071```
1072
1073**Description**
1074
1075Creates the pointer to an OH_PictureNative object at the specified index.
1076
1077**Since**: 20
1078
1079
1080**Parameters**
1081
1082| Name| Description|
1083| -- | -- |
1084| [OH_ImageSourceNative](capi-image-nativemodule-oh-imagesourcenative.md) *source | Pointer to an OH_ImageSourceNative object.|
1085| uint32_t index | Index of the image.|
1086| [OH_PictureNative](capi-image-nativemodule-oh-picturenative.md) **picture | Double pointer to the OH_PictureNative object created at the C++ local layer.|
1087
1088**Returns**
1089
1090| Type| Description|
1091| -- | -- |
1092| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_SOURCE**: The data source is abnormal.<br>         **IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE**: The MIME type is not supported.<br>         **IMAGE_SOURCE_TOO_LARGE**: The image is too large.<br>         **IMAGE_SOURCE_UNSUPPORTED_OPTIONS**: The options are not supported. For example, an invalid image ID.<br>         **IMAGE_DECODE_FAILED**: Decoding fails.|
1093
1094### OH_ImageSourceNative_GetDelayTimeList()
1095
1096```
1097Image_ErrorCode OH_ImageSourceNative_GetDelayTimeList(OH_ImageSourceNative *source, int32_t *delayTimeList, size_t size)
1098```
1099
1100**Description**
1101
1102Obtains the image delay time list.
1103
1104**Since**: 12
1105
1106
1107**Parameters**
1108
1109| Name| Description|
1110| -- | -- |
1111| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1112| int32_t *delayTimeList | Pointer to the delay time list obtained. It cannot be a null pointer.|
1113| size_t size | Size of the delay time list. You can use [OH_ImageSourceNative_GetFrameCount](#oh_imagesourcenative_getframecount) to obtain the size.|
1114
1115**Returns**
1116
1117| Type| Description|
1118| -- | -- |
1119| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1120
1121### OH_ImageSourceNative_GetImageInfo()
1122
1123```
1124Image_ErrorCode OH_ImageSourceNative_GetImageInfo(OH_ImageSourceNative *source, int32_t index,OH_ImageSource_Info *info)
1125```
1126
1127**Description**
1128
1129Obtains the information about an image with a given index.
1130
1131**Since**: 12
1132
1133
1134**Parameters**
1135
1136| Name| Description|
1137| -- | -- |
1138| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1139| int32_t index | Index of an image. For a GIF image, the value range is [0, N-1], where N indicates the number of GIF frames. For an image with only one frame, you can pass in **0**.|
1140| [OH_ImageSource_Info](capi-image-nativemodule-imagesource-info.md) *info | Pointer to the image information obtained, which is an OH_ImageSource_Info struct.|
1141
1142**Returns**
1143
1144| Type| Description|
1145| -- | -- |
1146| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1147
1148### OH_ImageSourceNative_GetImageProperty()
1149
1150```
1151Image_ErrorCode OH_ImageSourceNative_GetImageProperty(OH_ImageSourceNative *source, Image_String *key,Image_String *value)
1152```
1153
1154**Description**
1155
1156Obtains the value of an image property.
1157
1158**Since**: 12
1159
1160
1161**Parameters**
1162
1163| Name| Description|
1164| -- | -- |
1165| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1166| [Image_String](capi-image-nativemodule-image-string.md) *key | Pointer to the property key. For details, see [Image_String](capi-image-nativemodule-image-string.md). For details about the value range of **key**, see the definition of [OHOS_IMAGE_PROPERTY_XXX](capi-image-common-h.md#variables). The memory must be released after the image source is used. For details, see [OH_ImageSourceNative_Release](#oh_imagesourcenative_release).|
1167| [Image_String](capi-image-nativemodule-image-string.md) *value | Pointer to the value obtained. 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.|
1168
1169**Returns**
1170
1171| Type| Description|
1172| -- | -- |
1173| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1174
1175### OH_ImageSourceNative_GetImagePropertyWithNull()
1176
1177```
1178Image_ErrorCode OH_ImageSourceNative_GetImagePropertyWithNull(OH_ImageSourceNative *source, Image_String *key,Image_String *value)
1179```
1180
1181**Description**
1182
1183Obtains the value of an image property. The output **value.data** is terminated with a string terminator.
1184
1185**Since**: 19
1186
1187
1188**Parameters**
1189
1190| Name| Description|
1191| -- | -- |
1192| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1193| [Image_String](capi-image-nativemodule-image-string.md) *key | Pointer to the property key.|
1194| [Image_String](capi-image-nativemodule-image-string.md) *value | Pointer to the value obtained.|
1195
1196**Returns**
1197
1198| Type| Description|
1199| -- | -- |
1200| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_SOURCE_INVALID_PARAMETER**: The **source**, **key**, or **value** parameter is a null pointer.|
1201
1202### OH_ImageSourceNative_ModifyImageProperty()
1203
1204```
1205Image_ErrorCode OH_ImageSourceNative_ModifyImageProperty(OH_ImageSourceNative *source, Image_String *key,Image_String *value)
1206```
1207
1208**Description**
1209
1210Modifies the value of an image property.
1211
1212**Since**: 12
1213
1214
1215**Parameters**
1216
1217| Name| Description|
1218| -- | -- |
1219| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1220| [Image_String](capi-image-nativemodule-image-string.md) *key | Pointer to the property key. For details, see [Image_String](capi-image-nativemodule-image-string.md). **key** is an EXIF constant. The memory must be released after the image source is used. For details, see [OH_ImageSourceNative_Release](#oh_imagesourcenative_release).|
1221| [Image_String](capi-image-nativemodule-image-string.md) *value | Pointer to the new value.|
1222
1223**Returns**
1224
1225| Type| Description|
1226| -- | -- |
1227| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1228
1229### OH_ImageSourceNative_GetFrameCount()
1230
1231```
1232Image_ErrorCode OH_ImageSourceNative_GetFrameCount(OH_ImageSourceNative *source, uint32_t *frameCount)
1233```
1234
1235**Description**
1236
1237Obtains the number of image frames.
1238
1239**Since**: 12
1240
1241
1242**Parameters**
1243
1244| Name| Description|
1245| -- | -- |
1246| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1247| uint32_t *frameCount | Pointer to the number of frames obtained.|
1248
1249**Returns**
1250
1251| Type| Description|
1252| -- | -- |
1253| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1254
1255### OH_ImageSourceNative_GetSupportedFormats()
1256
1257```
1258Image_ErrorCode OH_ImageSourceNative_GetSupportedFormats(Image_MimeType **supportedFormats, size_t *length)
1259```
1260
1261**Description**
1262
1263Obtains the supported image formats that can be decoded.
1264
1265**Since**: 20
1266
1267
1268**Parameters**
1269
1270| Name| Description|
1271| -- | -- |
1272| [Image_MimeType](capi-image-nativemodule-image-string.md) **supportedFormats | Double pointer to the supported image formats.|
1273| size_t *length | Pointer to the size of the array.|
1274
1275**Returns**
1276
1277| Type| Description|
1278| -- | -- |
1279| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_SOURCE_INVALID_PARAMETER**: The **supportedFormats** or **length** parameter is a null pointer.|
1280
1281### OH_ImageSourceNative_Release()
1282
1283```
1284Image_ErrorCode OH_ImageSourceNative_Release(OH_ImageSourceNative *source)
1285```
1286
1287**Description**
1288
1289Releases the pointer to an OH_ImageSourceNative object.
1290
1291**Since**: 12
1292
1293
1294**Parameters**
1295
1296| Name| Description|
1297| -- | -- |
1298| [OH_ImageSourceNative](capi-image-imagesourcenative-.md) *source | Pointer to an OH_ImageSourceNative object.|
1299
1300**Returns**
1301
1302| Type| Description|
1303| -- | -- |
1304| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1305
1306### OH_DecodingOptionsForPicture_Create()
1307
1308```
1309Image_ErrorCode OH_DecodingOptionsForPicture_Create(OH_DecodingOptionsForPicture **options)
1310```
1311
1312**Description**
1313
1314Creates the pointer to an OH_DecodingOptionsForPicture object.
1315
1316**Since**: 13
1317
1318
1319**Parameters**
1320
1321| Name| Description|
1322| -- | -- |
1323| [OH_DecodingOptionsForPicture](capi-image-nativemodule-oh-decodingoptionsforpicture.md) **options | Double pointer to the OH_DecodingOptionsForPicture object created.|
1324
1325**Returns**
1326
1327| Type| Description|
1328| -- | -- |
1329| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1330
1331### OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures()
1332
1333```
1334Image_ErrorCode OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options,Image_AuxiliaryPictureType **desiredAuxiliaryPictures, size_t *length)
1335```
1336
1337**Description**
1338
1339Obtains desired auxiliary pictures in the decoding options (auxiliary pictures contained in **picture** expected to be decoded.)
1340
1341**Since**: 13
1342
1343
1344**Parameters**
1345
1346| Name| Description|
1347| -- | -- |
1348| [OH_DecodingOptionsForPicture](capi-image-nativemodule-oh-decodingoptionsforpicture.md) *options | Pointer to an OH_DecodingOptionsForPicture object.|
1349| [Image_AuxiliaryPictureType](capi-picture-native-h.md#image_auxiliarypicturetype) **desiredAuxiliaryPictures | Double pointer to the desired auxiliary pictures.|
1350| size_t *length | Length of the desired auxiliary pictures.|
1351
1352**Returns**
1353
1354| Type| Description|
1355| -- | -- |
1356| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1357
1358### OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures()
1359
1360```
1361Image_ErrorCode OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options,Image_AuxiliaryPictureType *desiredAuxiliaryPictures, size_t length)
1362```
1363
1364**Description**
1365
1366Sets desired auxiliary pictures in the decoding options.
1367
1368**Since**: 13
1369
1370
1371**Parameters**
1372
1373| Name| Description|
1374| -- | -- |
1375| [OH_DecodingOptionsForPicture](capi-image-nativemodule-oh-decodingoptionsforpicture.md) *options | Pointer to an OH_DecodingOptionsForPicture object.|
1376| [Image_AuxiliaryPictureType](capi-picture-native-h.md#image_auxiliarypicturetype) *desiredAuxiliaryPictures | Pointer to the desired auxiliary pictures.|
1377| size_t length | Length of the desired auxiliary pictures.|
1378
1379**Returns**
1380
1381| Type| Description|
1382| -- | -- |
1383| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1384
1385### OH_DecodingOptionsForPicture_Release()
1386
1387```
1388Image_ErrorCode OH_DecodingOptionsForPicture_Release(OH_DecodingOptionsForPicture *options)
1389```
1390
1391**Description**
1392
1393Releases the pointer to an OH_DecodingOptionsForPicture object.
1394
1395**Since**: 13
1396
1397
1398**Parameters**
1399
1400| Name| Description|
1401| -- | -- |
1402| [OH_DecodingOptionsForPicture](capi-image-nativemodule-oh-decodingoptionsforpicture.md) *options | Pointer to an OH_DecodingOptionsForPicture object.|
1403
1404**Returns**
1405
1406| Type| Description|
1407| -- | -- |
1408| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>         **IMAGE_BAD_PARAMETER**: A parameter is incorrect.|
1409<!--no_check-->