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