1# ImageProcessing
2
3
4## Overview
5
6The ImageProcessing module provides APIs for image processing, including Color Space Conversion (CSC) and metadata generation.
7
8<!--RP1--><!--RP1End-->
9
10**Since**: 13
11
12
13## Summary
14
15
16### Files
17
18| Name| Description|
19| -------- | -------- |
20| [image_processing.h](image__processing_8h.md) | Declares the image processing functions.|
21| [image_processing_types.h](image__processing__types_8h.md) | Declares the image processing types.|
22
23
24### Structs
25
26| Name| Description|
27| -------- | -------- |
28| struct  [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) | Describes the color space information, which is used in CSC capability query.|
29
30
31### Types
32
33| Name| Description|
34| -------- | -------- |
35| typedef struct [OH_ImageProcessing](#oh_imageprocessing) [OH_ImageProcessing](#oh_imageprocessing) | Provides the declaration of the **OH_ImageProcessing** struct.|
36| typedef struct [OH_PixelmapNative](#oh_pixelmapnative) [OH_PixelmapNative](#oh_pixelmapnative) | Provides the declaration of the **OH_PixelmapNative** struct.|
37| typedef struct [OH_AVFormat](#oh_avformat) [OH_AVFormat](#oh_avformat) | Provides the declaration of the **OH_AVFormat** struct.|
38| typedef struct [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) [ImageProcessing_ColorSpaceInfo](#imageprocessing_colorspaceinfo) | Defines a struct for the color space information, which is used in CSC capability query.|
39| typedef enum [ImageDetailEnhancer_QualityLevel](#imagedetailenhancer_qualitylevel-1) [ImageDetailEnhancer_QualityLevel](#imagedetailenhancer_qualitylevel) | Defines an enum for the quality levels, which are used for detail enhancement.|
40| typedef enum [ImageProcessing_ErrorCode](#imageprocessing_errorcode-1) [ImageProcessing_ErrorCode](#imageprocessing_errorcode) | Defines an enum for the error codes used in image processing.|
41
42
43### Enums
44
45| Name| Description|
46| -------- | -------- |
47| [ImageDetailEnhancer_QualityLevel](#imagedetailenhancer_qualitylevel-1) { <br>IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_NONE,<br>IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_LOW,<br>IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_MEDIUM,<br>IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_HIGH } | Enumerates the quality levels, which are used for detail enhancement.|
48| [ImageProcessing_ErrorCode](#imageprocessing_errorcode-1) {<br>IMAGE_PROCESSING_SUCCESS,<br>IMAGE_PROCESSING_ERROR_INVALID_PARAMETER = 401,<br>IMAGE_PROCESSING_ERROR_UNKNOWN = 29200001,<br>IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED,<br>IMAGE_PROCESSING_ERROR_CREATE_FAILED,<br>IMAGE_PROCESSING_ERROR_PROCESS_FAILED,<br>IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING,<br>IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED,<br>IMAGE_PROCESSING_ERROR_NO_MEMORY,<br>IMAGE_PROCESSING_ERROR_INVALID_INSTANCE,<br>IMAGE_PROCESSING_ERROR_INVALID_VALUE<br>} | Enumerates the error codes used in image processing.|
49
50
51### Functions
52
53| Name| Description|
54| -------- | -------- |
55| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_InitializeEnvironment](#oh_imageprocessing_initializeenvironment) (void) | Initializes the global environment of the image processing module.|
56| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_DeinitializeEnvironment](#oh_imageprocessing_deinitializeenvironment) (void) | Deinitializes the global environment of the image processing module.|
57| bool [OH_ImageProcessing_IsColorSpaceConversionSupported](#oh_imageprocessing_iscolorspaceconversionsupported) (const [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) \*sourceImageInfo, const [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) \*destinationImageInfo) | Checks whether CSC is supported for an image.|
58| bool [OH_ImageProcessing_IsCompositionSupported](#oh_imageprocessing_iscompositionsupported) (const [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) \*sourceImageInfo, const [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) \*sourceGainmapInfo, const [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) \*destinationImageInfo) | Checks whether a dual-layer HDR image can be converted into a single-layer HDR image.|
59| bool [OH_ImageProcessing_IsDecompositionSupported](#oh_imageprocessing_isdecompositionsupported) (const [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) \*sourceImageInfo, const [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) \*destinationImageInfo, const [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) \*destinationGainmapInfo) | Checks whether a single-layer HDR image can be converted into a dual-layer HDR image.|
60| bool [OH_ImageProcessing_IsMetadataGenerationSupported](#oh_imageprocessing_ismetadatagenerationsupported) (const [ImageProcessing_ColorSpaceInfo](_image_processing___color_space_info.md) \*sourceImageInfo) | Checks whether metadata generation is supported for an image.|
61| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_Create](#oh_imageprocessing_create) ([OH_ImageProcessing](#oh_imageprocessing) \*\*imageProcessor, int32_t type) | Creates an image processing instance.|
62| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_Destroy](#oh_imageprocessing_destroy) ([OH_ImageProcessing](#oh_imageprocessing) \*imageProcessor) | Destroys an image processing instance.|
63| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_SetParameter](#oh_imageprocessing_setparameter) ([OH_ImageProcessing](#oh_imageprocessing) \*imageProcessor, const [OH_AVFormat](#oh_avformat) \*parameter) | Sets a parameter for the image processing module.|
64| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_GetParameter](#oh_imageprocessing_getparameter) ([OH_ImageProcessing](#oh_imageprocessing) \*imageProcessor, [OH_AVFormat](#oh_avformat) \*parameter) | Obtains a parameter of the image processing module.|
65| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_ConvertColorSpace](#oh_imageprocessing_convertcolorspace) ([OH_ImageProcessing](#oh_imageprocessing) \*imageProcessor, [OH_PixelmapNative](#oh_pixelmapnative) \*sourceImage, [OH_PixelmapNative](#oh_pixelmapnative) \*destinationImage) | Converts the color space for a single-layer image.|
66| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_Compose](#oh_imageprocessing_compose) ([OH_ImageProcessing](#oh_imageprocessing) \*imageProcessor, [OH_PixelmapNative](#oh_pixelmapnative) \*sourceImage, [OH_PixelmapNative](#oh_pixelmapnative) \*sourceGainmap, [OH_PixelmapNative](#oh_pixelmapnative) \*destinationImage) | Converts a dual-layer HDR image into a single-layer HDR image.|
67| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_Decompose](#oh_imageprocessing_decompose) ([OH_ImageProcessing](#oh_imageprocessing) \*imageProcessor, [OH_PixelmapNative](#oh_pixelmapnative) \*sourceImage, [OH_PixelmapNative](#oh_pixelmapnative) \*destinationImage, [OH_PixelmapNative](#oh_pixelmapnative) \*destinationGainmap) | Converts a single-layer HDR image into a double-layer HDR image.|
68| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_GenerateMetadata](#oh_imageprocessing_generatemetadata) ([OH_ImageProcessing](#oh_imageprocessing) \*imageProcessor, [OH_PixelmapNative](#oh_pixelmapnative) \*sourceImage) | Generates metadata for an HDR image.|
69| [ImageProcessing_ErrorCode](#imageprocessing_errorcode) [OH_ImageProcessing_EnhanceDetail](#oh_imageprocessing_enhancedetail) ([OH_ImageProcessing](#oh_imageprocessing) \*imageProcessor, [OH_PixelmapNative](#oh_pixelmapnative) \*sourceImage, [OH_PixelmapNative](#oh_pixelmapnative) \*destinationImage) | Enhances the image definition and details.|
70
71
72### Variables
73
74| Name| Description|
75| -------- | -------- |
76| const int32_t [IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION](#image_processing_type_color_space_conversion) | Used to create an image processing instance for CSC.|
77| const int32_t [IMAGE_PROCESSING_TYPE_COMPOSITION](#image_processing_type_composition) | Used to create an image processing instance for converting a dual-layer HDR image into a single-layer HDR image.|
78| const int32_t [IMAGE_PROCESSING_TYPE_DECOMPOSITION](#image_processing_type_decomposition) | Used to create an image processing instance for converting a single-layer HDR image into a dual-layer HDR image.|
79| const int32_t [IMAGE_PROCESSING_TYPE_METADATA_GENERATION](#image_processing_type_metadata_generation) | Used to create an image processing instance for metadata generation.|
80| const int32_t [IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER](#image_processing_type_detail_enhancer) | Used to create an image processing instance for detail enhancement.|
81| const char \* [IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL](#image_detail_enhancer_parameter_key_quality_level) | Used to set the quality level for image detail enhancement.|
82
83
84## Type Description
85
86
87### ImageDetailEnhancer_QualityLevel
88
89```
90typedef enum ImageDetailEnhancer_QualityLevel ImageDetailEnhancer_QualityLevel
91```
92
93**Description**
94
95Defines an enum for the quality levels, which are used for detail enhancement.
96
97Corresponding key: [IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL](#image_detail_enhancer_parameter_key_quality_level)
98
99**Since**: 13
100
101**See**
102
103[OH_ImageProcessing_SetParameter](#oh_imageprocessing_setparameter)
104
105[OH_ImageProcessing_GetParameter](#oh_imageprocessing_getparameter)
106
107
108### ImageProcessing_ColorSpaceInfo
109
110```
111typedef struct ImageProcessing_ColorSpaceInfo ImageProcessing_ColorSpaceInfo
112```
113
114**Description**
115
116Defines a struct for the color space information, which is used in CSC capability query.
117
118**Since**: 13
119
120**See**
121
122[OH_ImageProcessing_IsColorSpaceConversionSupported](#oh_imageprocessing_iscolorspaceconversionsupported)
123
124[OH_ImageProcessing_IsCompositionSupported](#oh_imageprocessing_iscompositionsupported)
125
126[OH_ImageProcessing_IsDecompositionSupported](#oh_imageprocessing_isdecompositionsupported)
127
128
129### ImageProcessing_ErrorCode
130
131```
132typedef enum ImageProcessing_ErrorCode ImageProcessing_ErrorCode
133```
134
135**Description**
136
137Defines an enum for the error codes used in image processing.
138
139**Since**: 13
140
141
142### OH_AVFormat
143
144```
145typedef struct OH_AVFormat OH_AVFormat
146```
147
148**Description**
149
150Provides the declaration of the **OH_AVFormat** struct.
151
152**Since**: 13
153
154
155### OH_ImageProcessing
156
157```
158typedef struct OH_ImageProcessing OH_ImageProcessing
159```
160
161**Description**
162
163Provides the declaration of the **OH_ImageProcessing** struct.
164
165Define a null pointer to **OH_ImageProcessing**. Before [OH_ImageProcessing_Create](#oh_imageprocessing_create) is called to create an image processing instance, the pointer must be null. You can create different image processing instances with different processing types.
166
167**Since**: 13
168
169
170### OH_PixelmapNative
171
172```
173typedef struct OH_PixelmapNative OH_PixelmapNative
174```
175
176**Description**
177
178Provides the declaration of the **OH_PixelmapNative** struct.
179
180**Since**: 13
181
182
183## Enum Description
184
185
186### ImageDetailEnhancer_QualityLevel
187
188```
189enum ImageDetailEnhancer_QualityLevel
190```
191
192**Description**
193
194Enumerates the quality levels, which are used for detail enhancement.
195
196Corresponding key: [IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL](#image_detail_enhancer_parameter_key_quality_level)
197
198**Since**: 13
199
200**See**
201
202[OH_ImageProcessing_SetParameter](#oh_imageprocessing_setparameter)
203
204[OH_ImageProcessing_GetParameter](#oh_imageprocessing_getparameter)
205
206| Value| Description|
207| -------- | -------- |
208| IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_NONE | No detail enhancement.|
209| IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_LOW | Low-quality detail enhancement, which features fast speed. This is the default value.|
210| IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_MEDIUM | Medium-quality detail enhancement, which features moderate speed.|
211| IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_HIGH | High-quality detail enhancement, which features slow speed.|
212
213
214### ImageProcessing_ErrorCode
215
216```
217enum ImageProcessing_ErrorCode
218```
219
220**Description**
221
222Enumerates the error codes used in image processing.
223
224**Since**: 13
225
226| Value| Description|
227| -------- | -------- |
228| IMAGE_PROCESSING_SUCCESS | The processing is successful.|
229| IMAGE_PROCESSING_ERROR_INVALID_PARAMETER | An input parameter is invalid.<br>This error code is returned in the following cases:<br>1 - The input or output buffer is either invalid or empty.<br>2 - The provided parameter is invalid or missing.<br>3 - The type is invalid. For example, the type passed in the creation function does not exist.|
230| IMAGE_PROCESSING_ERROR_UNKNOWN | An unknown error occurs. For example, the GPU computing or memcpy fails.|
231| IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED | The global environment, for example, the GPU environment, fails to be initialized.|
232| IMAGE_PROCESSING_ERROR_CREATE_FAILED | Creating the image processing instance fails. For example, the total number of instances exceeds the upper limit.|
233| IMAGE_PROCESSING_ERROR_PROCESS_FAILED | The processing fails. For example, the processing times out.|
234| IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING | The processing type is not supported. You can call OH_ImageProcessing_Is*XXX*Supported to check whether a specific processing type is supported.|
235| IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED | The operation is not allowed. For example, the function is called in an incorrect running state.|
236| IMAGE_PROCESSING_ERROR_NO_MEMORY | Insufficient memory.|
237| IMAGE_PROCESSING_ERROR_INVALID_INSTANCE | The image processing instance is invalid, for example, a null instance.|
238| IMAGE_PROCESSING_ERROR_INVALID_VALUE | The input value is invalid.<br>This error code is returned in the following cases:<br>1 - The input or output image buffer is invalid. For example, the width (height) of the image buffer is too large or the color space is incorrect.<br>2 - The parameter is invalid. For example, the parameter does not contain valid information, such as invalid quality level for detail enhancement.|
239
240
241## Function Description
242
243
244### OH_ImageProcessing_Compose()
245
246```
247ImageProcessing_ErrorCode OH_ImageProcessing_Compose(OH_ImageProcessing* imageProcessor,OH_PixelmapNative* sourceImage, OH_PixelmapNative* sourceGainmap, OH_PixelmapNative* destinationImage)
248```
249
250**Description**
251
252Converts a dual-layer HDR image into a single-layer HDR image.
253
254This function is used to generate an output image based on an input image and input gain map.
255
256**Since**: 13
257
258**Parameters**
259
260| Name| Description|
261| -------- | -------- |
262| imageProcessor | Pointer to an image processing instance, which is created by [IMAGE_PROCESSING_TYPE_COMPOSITION](#image_processing_type_composition).|
263| sourceImage | Pointer to the input image.|
264| sourceGainmap | Pointer to the input gain map.|
265| destinationImage | Pointer to the output image.|
266
267**Returns**
268
269- Returns **IMAGE_PROCESSING_SUCCESS** if image processing is successful.
270- Returns **IMAGE_PROCESSING_ERROR_INVALID_INSTANCE** if the instance is null or is not an image processing instance.
271- Returns **IMAGE_PROCESSING_ERROR_INVALID_PARAMETER** if the image is empty.
272- Returns **IMAGE_PROCESSING_ERROR_INVALID_VALUE** if an image property is invalid, for example, unsupported color space.
273- Returns **IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING** if image processing is not supported.
274- Returns **IMAGE_PROCESSING_ERROR_PROCESS_FAILED** if an error occurs during image processing.
275- Returns **IMAGE_PROCESSING_ERROR_NO_MEMORY** if memory allocation fails.
276
277
278### OH_ImageProcessing_ConvertColorSpace()
279
280```
281ImageProcessing_ErrorCode OH_ImageProcessing_ConvertColorSpace(OH_ImageProcessing* imageProcessor, OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage)
282```
283
284**Description**
285
286Converts the color space for a single-layer image.
287
288This function enables CSC from HDR images to SDR images, CSC from SDR images to HDR images, CSC from SDR images to SDR images, and CSC from HDR images to SDR images.
289
290**Since**: 13
291
292**Parameters**
293
294| Name| Description|
295| -------- | -------- |
296| imageProcessor | Pointer to an image processing instance, which is created by [IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION](#image_processing_type_color_space_conversion).|
297| sourceImage | Pointer to the input image.|
298| destinationImage | Pointer to the output image.|
299
300**Returns**
301
302- Returns **IMAGE_PROCESSING_SUCCESS** if image processing is successful.
303- Returns **IMAGE_PROCESSING_ERROR_INVALID_INSTANCE** if the instance is null or is not an image processing instance.
304- Returns **IMAGE_PROCESSING_ERROR_INVALID_PARAMETER** if the image is empty.
305- Returns **IMAGE_PROCESSING_ERROR_INVALID_VALUE** if an image property is invalid, for example, unsupported color space.
306- Returns **IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING** if image processing is not supported.
307- Returns **IMAGE_PROCESSING_ERROR_PROCESS_FAILED** if an error occurs during image processing.
308- Returns **IMAGE_PROCESSING_ERROR_NO_MEMORY** if memory allocation fails.
309
310
311### OH_ImageProcessing_Create()
312
313```
314ImageProcessing_ErrorCode OH_ImageProcessing_Create(OH_ImageProcessing** imageProcessor, int32_t type)
315```
316
317**Description**
318
319Creates an image processing instance.
320
321**Since**: 13
322
323**Parameters**
324
325| Name| Description|
326| -------- | -------- |
327| imageProcessor |  Double pointer to the image processing instance created. The pointer **\*imageProcessor** points to a new image processing object and must be a null pointer before being passed.|
328| type | Image processing type. The processing type cannot be changed after the instance is created.|
329
330**Returns**
331
332- Returns **IMAGE_PROCESSING_SUCCESS** if the instance is created successfully.
333- Returns **IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING** if the specified image processing type is not supported, for example, if metadata generation is not supported.
334- Returns **IMAGE_PROCESSING_ERROR_CREATE_FAILED** if the instance fails to be created.
335- Returns **IMAGE_PROCESSING_ERROR_INVALID_INSTANCE** if the instance is null or the pointer to the instance is null.
336- Returns **IMAGE_PROCESSING_ERROR_INVALID_PARAMETER** if the specified image processing type is invalid.
337
338
339### OH_ImageProcessing_Decompose()
340
341```
342ImageProcessing_ErrorCode OH_ImageProcessing_Decompose(OH_ImageProcessing* imageProcessor, OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage, OH_PixelmapNative* destinationGainmap)
343```
344
345**Description**
346
347Converts a single-layer HDR image into a double-layer HDR image.
348
349This function is used to generate an output image and output gain map based on an input image.
350
351**Since**: 13
352
353**Parameters**
354
355| Name| Description|
356| -------- | -------- |
357| imageProcessor | Pointer to an image processing instance, which is created by [IMAGE_PROCESSING_TYPE_DECOMPOSITION](#image_processing_type_decomposition).|
358| sourceImage | Pointer to the input image.|
359| destinationImage | Pointer to the output image.|
360| destinationGainmap | Pointer to the output gain map.|
361
362**Returns**
363
364- Returns **IMAGE_PROCESSING_SUCCESS** if image processing is successful.
365- Returns **IMAGE_PROCESSING_ERROR_INVALID_INSTANCE** if the instance is null or is not an image processing instance.
366- Returns **IMAGE_PROCESSING_ERROR_INVALID_PARAMETER** if the image is empty.
367- Returns **IMAGE_PROCESSING_ERROR_INVALID_VALUE** if an image property is invalid, for example, unsupported color space.
368- Returns **IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING** if image processing is not supported.
369- Returns **IMAGE_PROCESSING_ERROR_PROCESS_FAILED** if an error occurs during image processing.
370- Returns **IMAGE_PROCESSING_ERROR_NO_MEMORY** if memory allocation fails.
371
372
373### OH_ImageProcessing_DeinitializeEnvironment()
374
375```
376ImageProcessing_ErrorCode OH_ImageProcessing_DeinitializeEnvironment(void)
377```
378
379**Description**
380
381Deinitializes the global environment of the image processing module.
382
383This function must be called after [OH_ImageProcessing_InitializeEnvironment](#oh_imageprocessing_initializeenvironment) is called. Generally, this function is called when the main process is about to exit. Do not call this function when an image processing instance exists or when [OH_ImageProcessing_InitializeEnvironment](#oh_imageprocessing_initializeenvironment) is not called.
384
385**Since**: 13
386
387**Returns**
388
389- Returns **IMAGE_PROCESSING_SUCCESS** if deinitialization is successful.
390- Returns **IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED** if the image processing instance is not destroyed or [OH_ImageProcessing_InitializeEnvironment](#oh_imageprocessing_initializeenvironment) is not called.
391
392
393### OH_ImageProcessing_Destroy()
394
395```
396ImageProcessing_ErrorCode OH_ImageProcessing_Destroy(OH_ImageProcessing* imageProcessor)
397```
398
399**Description**
400
401Destroys an image processing instance.
402
403**Since**: 13
404
405**Parameters**
406
407| Name| Description|
408| -------- | -------- |
409| imageProcessor | Pointer to an image processing instance, You are advised to set the pointer to a null pointer after the instance is destroyed.|
410
411**Returns**
412
413- Returns **IMAGE_PROCESSING_SUCCESS** if the instance is destroyed.
414- Returns **IMAGE_PROCESSING_ERROR_INVALID_INSTANCE** if the instance is null or is not an image processing instance.
415
416
417### OH_ImageProcessing_EnhanceDetail()
418
419```
420ImageProcessing_ErrorCode OH_ImageProcessing_EnhanceDetail(OH_ImageProcessing* imageProcessor, OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage)
421```
422
423**Description**
424
425Enhances the image definition and details.
426
427This function performs necessary scaling operations on the source image based on the preset sizes of the input and output images to generate the target image. It uses multiple scaling methods to balance performance and image quality.
428
429**Since**: 13
430
431**Parameters**
432
433| Name| Description|
434| -------- | -------- |
435| imageProcessor | Pointer to an image processing instance, which is created by [IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER](#image_processing_type_detail_enhancer).|
436| sourceImage | Pointer to the input image.|
437| destinationImage | Pointer to the output image.|
438
439**Returns**
440
441- Returns **IMAGE_PROCESSING_SUCCESS** if image processing is successful.
442- Returns **IMAGE_PROCESSING_ERROR_INVALID_INSTANCE** if the instance is null or is not an image processing instance.
443- Returns **IMAGE_PROCESSING_ERROR_INVALID_PARAMETER** if the image is empty.
444- Returns **IMAGE_PROCESSING_ERROR_INVALID_VALUE** if an image property is invalid, for example, unsupported color space.
445- Returns **IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING** if image processing is not supported.
446- Returns **IMAGE_PROCESSING_ERROR_PROCESS_FAILED** if an error occurs during image processing.
447- Returns **IMAGE_PROCESSING_ERROR_NO_MEMORY** if memory allocation fails.
448
449
450### OH_ImageProcessing_GenerateMetadata()
451
452```
453ImageProcessing_ErrorCode OH_ImageProcessing_GenerateMetadata(OH_ImageProcessing* imageProcessor, OH_PixelmapNative* sourceImage)
454```
455
456**Description**
457
458Generates metadata for an HDR image.
459
460**Since**: 13
461
462**Parameters**
463
464| Name| Description|
465| -------- | -------- |
466| imageProcessor | Pointer to an image processing instance, which is created by [IMAGE_PROCESSING_TYPE_METADATA_GENERATION](#image_processing_type_metadata_generation).|
467| sourceImage | Pointer to the input image.|
468
469**Returns**
470
471- Returns **IMAGE_PROCESSING_SUCCESS** if image processing is successful.
472- Returns **IMAGE_PROCESSING_ERROR_INVALID_INSTANCE** if the instance is null or is not an image processing instance.
473- Returns **IMAGE_PROCESSING_ERROR_INVALID_PARAMETER** if the image is empty.
474- Returns **IMAGE_PROCESSING_ERROR_INVALID_VALUE** if an image property is invalid, for example, unsupported color space.
475- Returns **IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING** if image processing is not supported.
476- Returns **IMAGE_PROCESSING_ERROR_PROCESS_FAILED** if an error occurs during image processing.
477- Returns **IMAGE_PROCESSING_ERROR_NO_MEMORY** if memory allocation fails.
478
479
480### OH_ImageProcessing_GetParameter()
481
482```
483ImageProcessing_ErrorCode OH_ImageProcessing_GetParameter(OH_ImageProcessing* imageProcessor, OH_AVFormat* parameter)
484```
485
486**Description**
487
488Obtains a parameter of the image processing module.
489
490This function obtains the parameter by key.
491
492**Since**: 13
493
494**Parameters**
495
496| Name| Description|
497| -------- | -------- |
498| imageProcessor | Pointer to an image processing instance.|
499| parameter | Pointer to the parameter used by the image processing instance.|
500
501**Returns**
502
503- Returns **IMAGE_PROCESSING_SUCCESS** if the parameters fail to be obtained.
504- Returns **IMAGE_PROCESSING_ERROR_INVALID_INSTANCE** if the instance is null or is not an image processing instance.
505- Returns **IMAGE_PROCESSING_ERROR_INVALID_PARAMETER** if **parameter** is empty.
506
507
508### OH_ImageProcessing_InitializeEnvironment()
509
510```
511ImageProcessing_ErrorCode OH_ImageProcessing_InitializeEnvironment(void)
512```
513
514**Description**
515
516Initializes the global environment of the image processing module.
517
518This function is optional. Generally, this function is called when the main process is started. It is used to initialize the global environment of the image processing module and reduce the time consumed by [OH_ImageProcessing_Create](#oh_imageprocessing_create). It must be used in pair with [OH_ImageProcessing_DeinitializeEnvironment](#oh_imageprocessing_deinitializeenvironment), which is used to deinitialize the global environment. This function can be used to check whether the GPU works properly.
519
520**Since**: 13
521
522**Returns**
523
524Returns **IMAGE_PROCESSING_SUCCESS** if the initialization is successful; returns **IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED** otherwise.
525
526
527### OH_ImageProcessing_IsColorSpaceConversionSupported()
528
529```
530bool OH_ImageProcessing_IsColorSpaceConversionSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo, const ImageProcessing_ColorSpaceInfo* destinationImageInfo)
531```
532
533**Description**
534
535Checks whether CSC is supported for an image.
536
537**Since**: 13
538
539**Parameters**
540
541| Name| Description|
542| -------- | -------- |
543| sourceImageInfo | Pointer to the color space information of the input image.|
544| destinationImageInfo | Pointer to the color space information of the output image.|
545
546**Returns**
547
548Returns **true** if CSC is supported; returns **false** otherwise.
549
550
551### OH_ImageProcessing_IsCompositionSupported()
552
553```
554bool OH_ImageProcessing_IsCompositionSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo, const ImageProcessing_ColorSpaceInfo* sourceGainmapInfo, const ImageProcessing_ColorSpaceInfo* destinationImageInfo)
555```
556
557**Description**
558
559Checks whether a dual-layer HDR image can be converted into a single-layer HDR image.
560
561**Since**: 13
562
563**Parameters**
564
565| Name| Description|
566| -------- | -------- |
567| sourceImageInfo | Pointer to the color space information of the input image.|
568| sourceGainmapInfo | Pointer to the color space information of the input gain map.|
569| destinationImageInfo | Pointer to the color space information of the output image.|
570
571**Returns**
572
573Returns **true** if such a conversion is supported; returns **false** otherwise.
574
575
576### OH_ImageProcessing_IsDecompositionSupported()
577
578```
579bool OH_ImageProcessing_IsDecompositionSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo, const ImageProcessing_ColorSpaceInfo* destinationImageInfo, const ImageProcessing_ColorSpaceInfo* destinationGainmapInfo)
580```
581
582**Description**
583
584Checks whether a single-layer HDR image can be converted into a dual-layer HDR image.
585
586**Since**: 13
587
588**Parameters**
589
590| Name| Description|
591| -------- | -------- |
592| sourceImageInfo | Pointer to the color space information of the input image.|
593| destinationImageInfo | Pointer to the color space information of the output image.|
594| destinationGainmapInfo | Pointer to the color space information of the output gain map.|
595
596**Returns**
597
598Returns **true** if such a conversion is supported; returns **false** otherwise.
599
600
601### OH_ImageProcessing_IsMetadataGenerationSupported()
602
603```
604bool OH_ImageProcessing_IsMetadataGenerationSupported(const ImageProcessing_ColorSpaceInfo* sourceImageInfo)
605```
606
607**Description**
608
609Checks whether metadata generation is supported for an image.
610
611**Since**: 13
612
613**Parameters**
614
615| Name| Description|
616| -------- | -------- |
617| sourceImageInfo | Pointer to the color space information of the input image.|
618
619**Returns**
620
621Returns **true** if metadata generation is supported; returns **false** otherwise.
622
623
624### OH_ImageProcessing_SetParameter()
625
626```
627ImageProcessing_ErrorCode OH_ImageProcessing_SetParameter(OH_ImageProcessing* imageProcessor, const OH_AVFormat* parameter)
628```
629
630**Description**
631
632Sets a parameter for the image processing module.
633
634This function sets the parameter by key.
635
636**Since**: 13
637
638**Parameters**
639
640| Name| Description|
641| -------- | -------- |
642| imageProcessor | Pointer to an image processing instance.|
643| parameter | Pointer to the parameter.|
644
645**Returns**
646
647- Returns **IMAGE_PROCESSING_SUCCESS** if the parameter is set successfully.
648- Returns **IMAGE_PROCESSING_ERROR_INVALID_INSTANCE** if the instance is null or is not an image processing instance.
649- Returns **IMAGE_PROCESSING_ERROR_INVALID_PARAMETER** if **parameter** is empty.
650- Returns **IMAGE_PROCESSING_ERROR_INVALID_VALUE** if **parameter** is invalid, for example, if **parameter** contains an unsupported parameter key or value.
651- Returns **IMAGE_PROCESSING_ERROR_NO_MEMORY** if memory allocation fails.
652
653
654## Variable Description
655
656
657### IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL
658
659```
660const char* IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL
661```
662
663**Description**
664
665Used to set the quality level for image detail enhancement.
666
667Use [ImageDetailEnhancer_QualityLevel](#imagedetailenhancer_qualitylevel) to obtain the quality level. Use [OH_ImageProcessing_SetParameter](#oh_imageprocessing_setparameter) to set the quality level. Use [OH_ImageProcessing_GetParameter](#oh_imageprocessing_getparameter) to obtain the quality level in use.
668
669**Since**: 13
670
671**See**
672
673[OH_VideoProcessing_SetParameter](../apis-media-kit/_video_processing.md#oh_videoprocessing_setparameter)
674
675[OH_VideoProcessing_GetParameter](../apis-media-kit/_video_processing.md#oh_videoprocessing_getparameter)
676
677
678### IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION
679
680```
681const int32_t IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION
682```
683
684**Description**
685
686Used to create an image processing instance for CSC.
687
688CSC includes conversion from single-layer HDR images to SDR images, conversion between SDR images, and conversion from SDR images to single-layer HDR images. Some capabilities are supported by vendors. Use **OH_ImageProcessing_IsColorSpaceConversionSuported** to check whether a conversion can be performed between single-layer images.
689
690**Since**: 13
691
692**See**
693
694[OH_ImageProcessing_Create](#oh_imageprocessing_create)
695
696
697### IMAGE_PROCESSING_TYPE_COMPOSITION
698
699```
700const int32_t IMAGE_PROCESSING_TYPE_COMPOSITION
701```
702
703**Description**
704
705Used to create an image processing instance for converting a dual-layer HDR image into a single-layer HDR image.
706
707The instance provides the capability of converting dual-layer HDR images into single-layer HDR images. Some capabilities are supported by vendors. Use [OH_ImageProcessing_IsCompositionSupported](#oh_imageprocessing_iscompositionsupported) to check whether the conversion from a dual-layer HDR image into a single-layer HDR image is supported.
708
709**Since**: 13
710
711**See**
712
713[OH_ImageProcessing_Create](#oh_imageprocessing_create)
714
715
716### IMAGE_PROCESSING_TYPE_DECOMPOSITION
717
718```
719const int32_t IMAGE_PROCESSING_TYPE_DECOMPOSITION
720```
721
722**Description**
723
724Used to create an image processing instance for converting a single-layer HDR image into a dual-layer HDR image.
725
726The instance provides the capability of converting single-layer HDR images into dual-layer HDR images. Some capabilities are supported by vendors. Use [OH_ImageProcessing_IsDecompositionSupported](#oh_imageprocessing_isdecompositionsupported) to check whether the conversion from a single-layer HDR image into a dual-layer HDR image is supported.
727
728**Since**: 13
729
730**See**
731
732[OH_ImageProcessing_Create](#oh_imageprocessing_create)
733
734
735### IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER
736
737```
738const int32_t IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER
739```
740
741**Description**
742
743Used to create an image processing instance for detail enhancement.
744
745This variable scales or resizes the image based on the specified image quality, or only enhances the image details to render the image without changing the resolution.
746
747**Since**: 13
748
749**See**
750
751[OH_ImageProcessing_Create](#oh_imageprocessing_create)
752
753
754### IMAGE_PROCESSING_TYPE_METADATA_GENERATION
755
756```
757const int32_t IMAGE_PROCESSING_TYPE_METADATA_GENERATION
758```
759
760**Description**
761
762Used to create an image processing instance for metadata generation.
763
764This variable generates the HDR Vivid metadata of a single-layer HDR image. Some capabilities are supported by vendors. If the capability is not supported, [OH_ImageProcessing_Create](#oh_imageprocessing_create) returns **IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING**.
765
766**Since**: 13
767
768**See**
769
770[OH_ImageProcessing_Create](#oh_imageprocessing_create)
771