1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup ImageSourceNative 18 * @{ 19 * 20 * @brief Provides APIs for access to the image interface. 21 * 22 * @since 12 23 */ 24 25 /** 26 * @file image_source_native.h 27 * 28 * @brief Declares APIs for decoding an image source into a pixel map. 29 * 30 * @library libimage_source.so 31 * @kit ImageKit 32 * @syscap SystemCapability.Multimedia.Image.ImageSource 33 * @since 12 34 */ 35 36 #ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_IMAGE_SOURCE_NATIVE_H_ 37 #define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_IMAGE_SOURCE_NATIVE_H_ 38 #include "image_common.h" 39 40 #include "pixelmap_native.h" 41 #include "picture_native.h" 42 #include "rawfile/raw_file.h" 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /** 49 * @brief Defines an image source object for the image interface. 50 * 51 * @since 12 52 */ 53 struct OH_ImageSourceNative; 54 typedef struct OH_ImageSourceNative OH_ImageSourceNative; 55 56 /** 57 * @brief Defines image source infomation 58 * {@link OH_ImageSourceInfo_Create}. 59 * 60 * @since 12 61 */ 62 struct OH_ImageSource_Info; 63 typedef struct OH_ImageSource_Info OH_ImageSource_Info; 64 65 /** 66 * @brief Defines decoding options for picture 67 * {@link OH_DecodingOptionsForPicture_Create}. 68 * 69 * @since 13 70 */ 71 struct OH_DecodingOptionsForPicture; 72 73 /** 74 * @brief Defines decoding options for picture 75 * {@link OH_DecodingOptionsForPicture_Create}. 76 * 77 * @since 13 78 */ 79 typedef struct OH_DecodingOptionsForPicture OH_DecodingOptionsForPicture; 80 81 /** 82 * @brief Enumerates decoding dynamic range.. 83 * 84 * @since 12 85 */ 86 typedef enum { 87 /* 88 * Dynamic range depends on the image. 89 */ 90 IMAGE_DYNAMIC_RANGE_AUTO = 0, 91 /* 92 * Standard dynamic range. 93 */ 94 IMAGE_DYNAMIC_RANGE_SDR = 1, 95 /* 96 * High dynamic range. 97 */ 98 IMAGE_DYNAMIC_RANGE_HDR = 2, 99 } IMAGE_DYNAMIC_RANGE; 100 101 /** 102 * @brief Type of allocator used to allocate memory of a PixelMap.. 103 * 104 * @since 15 105 */ 106 typedef enum { 107 /* 108 * The system determines which memory to use to create the PixelMap. 109 */ 110 IMAGE_ALLOCATOR_TYPE_AUTO = 0, 111 /* 112 * Use DMA buffer to create the PixelMap. 113 */ 114 IMAGE_ALLOCATOR_TYPE_DMA = 1, 115 /* 116 * Use share memory to create the PixelMap. 117 */ 118 IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY = 2, 119 } IMAGE_ALLOCATOR_TYPE; 120 121 /** 122 * @brief The strategy for executing the two operations when both desiredSize and desiredRegion 123 * are specified. 124 * 125 * @since 18 126 */ 127 typedef enum { 128 /** 129 * Scale first, then crop. 130 */ 131 IMAGE_CROP_AND_SCALE_STRATEGY_SCALE_FIRST = 1, 132 133 /** 134 * Crop first, then scale. 135 */ 136 IMAGE_CROP_AND_SCALE_STRATEGY_CROP_FIRST = 2, 137 } Image_CropAndScaleStrategy; 138 139 /** 140 * @brief Create a pointer for OH_ImageSource_Info struct. 141 * 142 * @param info The OH_ImageSource_Info pointer will be operated. 143 * @return Returns {@link Image_ErrorCode} 144 * @since 12 145 */ 146 Image_ErrorCode OH_ImageSourceInfo_Create(OH_ImageSource_Info **info); 147 148 /** 149 * @brief Get width number for OH_ImageSource_Info struct. 150 * 151 * @param info The OH_ImageSource_Info pointer will be operated. 152 * @param width the number of image width. 153 * @return Returns {@link Image_ErrorCode} 154 * @since 12 155 */ 156 Image_ErrorCode OH_ImageSourceInfo_GetWidth(OH_ImageSource_Info *info, uint32_t *width); 157 158 /** 159 * @brief Get height number for OH_ImageSource_Info struct. 160 * 161 * @param info The OH_ImageSource_Info pointer will be operated. 162 * @param height the number of image height. 163 * @return Returns {@link Image_ErrorCode} 164 * @since 12 165 */ 166 Image_ErrorCode OH_ImageSourceInfo_GetHeight(OH_ImageSource_Info *info, uint32_t *height); 167 168 /** 169 * @brief Get isHdr for OH_ImageSource_Info struct. 170 * 171 * @param info The OH_ImageSource_Info pointer will be operated. Pointer connot be null. 172 * @param isHdr Whether the image has a high dynamic range. 173 * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - The operation is successful. 174 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - Parameter error.Possible causes:Parameter verification failed. 175 * @since 12 176 */ 177 Image_ErrorCode OH_ImageSourceInfo_GetDynamicRange(OH_ImageSource_Info *info, bool *isHdr); 178 179 /** 180 * @brief Obtains the MIME type of an image source. 181 * 182 * @param info Pointer to the OH_ImageSource_Info struct. 183 * @param mimeType Pointer to the MIME type of the image source. 184 * @return Returns one of the following result codes: 185 * {@link IMAGE_SUCCESS}: The execution is successful. 186 * {@link IMAGE_SOURCE_INVALID_PARAMETER}: info or mimeType is a null pointer. 187 * @since 20 188 */ 189 Image_ErrorCode OH_ImageSourceInfo_GetMimeType(OH_ImageSource_Info *info, Image_MimeType *mimeType); 190 191 /** 192 * @brief delete OH_ImageSource_Info pointer. 193 * 194 * @param info The OH_ImageSource_Info pointer will be operated. 195 * @return Returns {@link Image_ErrorCode} 196 * @since 12 197 */ 198 Image_ErrorCode OH_ImageSourceInfo_Release(OH_ImageSource_Info *info); 199 200 /** 201 * @brief Defines the options for decoding the image source. 202 * It is used in {@link OH_ImageSourceNative_CreatePixelmap}. 203 * 204 * @since 12 205 */ 206 struct OH_DecodingOptions; 207 typedef struct OH_DecodingOptions OH_DecodingOptions; 208 209 /** 210 * @brief Create a pointer for OH_DecodingOptions struct. 211 * 212 * @param options The OH_DecodingOptions pointer will be operated. 213 * @return Returns {@link Image_ErrorCode} 214 * @since 12 215 */ 216 Image_ErrorCode OH_DecodingOptions_Create(OH_DecodingOptions **options); 217 218 /** 219 * @brief Get pixelFormat number for OH_DecodingOptions struct. 220 * 221 * @param options The OH_DecodingOptions pointer will be operated. 222 * @param pixelFormat the number of image pixelFormat. 223 * @return Returns {@link Image_ErrorCode} 224 * @since 12 225 */ 226 Image_ErrorCode OH_DecodingOptions_GetPixelFormat(OH_DecodingOptions *options, 227 int32_t *pixelFormat); 228 229 /** 230 * @brief Set pixelFormat number for OH_DecodingOptions struct. 231 * 232 * @param options The OH_DecodingOptions pointer will be operated. 233 * @param pixelFormat the number of image pixelFormat. 234 * @return Returns {@link Image_ErrorCode} 235 * @since 12 236 */ 237 Image_ErrorCode OH_DecodingOptions_SetPixelFormat(OH_DecodingOptions *options, 238 int32_t pixelFormat); 239 240 /** 241 * @brief Get index number for OH_DecodingOptions struct. 242 * 243 * @param options The OH_DecodingOptions pointer will be operated. 244 * @param index the number of image index. 245 * @return Returns {@link Image_ErrorCode} 246 * @since 12 247 */ 248 Image_ErrorCode OH_DecodingOptions_GetIndex(OH_DecodingOptions *options, uint32_t *index); 249 250 /** 251 * @brief Set index number for OH_DecodingOptions struct. 252 * 253 * @param options The OH_DecodingOptions pointer will be operated. 254 * @param index the number of image index. 255 * @return Returns {@link Image_ErrorCode} 256 * @since 12 257 */ 258 Image_ErrorCode OH_DecodingOptions_SetIndex(OH_DecodingOptions *options, uint32_t index); 259 260 /** 261 * @brief Get rotate number for OH_DecodingOptions struct. 262 * 263 * @param options The OH_DecodingOptions pointer will be operated. 264 * @param rotate the number of image rotate. 265 * @return Returns {@link Image_ErrorCode} 266 * @since 12 267 */ 268 Image_ErrorCode OH_DecodingOptions_GetRotate(OH_DecodingOptions *options, float *rotate); 269 270 /** 271 * @brief Set rotate number for OH_DecodingOptions struct. 272 * 273 * @param options The OH_DecodingOptions pointer will be operated. 274 * @param rotate the number of image rotate. 275 * @return Returns {@link Image_ErrorCode} 276 * @since 12 277 */ 278 Image_ErrorCode OH_DecodingOptions_SetRotate(OH_DecodingOptions *options, float rotate); 279 280 /** 281 * @brief Get desiredSize number for OH_DecodingOptions struct. 282 * 283 * @param options The OH_DecodingOptions pointer will be operated. 284 * @param desiredSize the number of image desiredSize. 285 * @return Returns {@link Image_ErrorCode} 286 * @since 12 287 */ 288 Image_ErrorCode OH_DecodingOptions_GetDesiredSize(OH_DecodingOptions *options, 289 Image_Size *desiredSize); 290 291 /** 292 * @brief Set desiredSize number for OH_DecodingOptions struct. 293 * 294 * @param options The OH_DecodingOptions pointer will be operated. 295 * @param desiredSize the number of image desiredSize. 296 * @return Returns {@link Image_ErrorCode} 297 * @since 12 298 */ 299 Image_ErrorCode OH_DecodingOptions_SetDesiredSize(OH_DecodingOptions *options, 300 Image_Size *desiredSize); 301 302 /** 303 * @brief Set desiredRegion number for OH_DecodingOptions struct. 304 * 305 * @param options The OH_DecodingOptions pointer will be operated. 306 * @param desiredRegion the number of image desiredRegion. 307 * @return Returns {@link Image_ErrorCode} 308 * @since 12 309 */ 310 Image_ErrorCode OH_DecodingOptions_GetDesiredRegion(OH_DecodingOptions *options, 311 Image_Region *desiredRegion); 312 313 /** 314 * @brief Set desiredRegion number for OH_DecodingOptions struct. 315 * 316 * @param options The OH_DecodingOptions pointer will be operated. 317 * @param desiredRegion the number of image desiredRegion. 318 * @return Returns {@link Image_ErrorCode} 319 * @since 12 320 */ 321 Image_ErrorCode OH_DecodingOptions_SetDesiredRegion(OH_DecodingOptions *options, 322 Image_Region *desiredRegion); 323 324 /** 325 * @brief Set desiredDynamicRange number for OH_DecodingOptions struct. 326 * 327 * @param options The OH_DecodingOptions pointer will be operated. Pointer connot be null. 328 * @param desiredDynamicRange the number of desired dynamic range {@link IMAGE_DYNAMIC_RANGE}. Pointer connot be null. 329 * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - The operation is successful. 330 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - Parameter error.Possible causes:Parameter verification failed. 331 * @since 12 332 */ 333 Image_ErrorCode OH_DecodingOptions_GetDesiredDynamicRange(OH_DecodingOptions *options, 334 int32_t *desiredDynamicRange); 335 336 /** 337 * @brief Sets a cropping and scaling strategy for decoding options. 338 * 339 * @param options Pointer to the decoding options. 340 * @param cropAndScaleStrategy Strategy for executing the cropping and scaling operations when both desiredSize and 341 * desiredRegion are specified. 342 * @return Returns one of the following result codes: 343 * {@link IMAGE_SUCCESS}: The execution is successful. 344 * {@link IMAGE_BAD_PARAMETER}: options is a null pointer or cropAndScaleStrategy is not in the range of 345 * Image_CropAndScaleStrategy. 346 * @since 18 347 */ 348 Image_ErrorCode OH_DecodingOptions_SetCropAndScaleStrategy(OH_DecodingOptions *options, 349 int32_t cropAndScaleStrategy); 350 351 /** 352 * @brief Obtains the cropping and scaling strategy of decoding options. 353 * 354 * @param options Pointer to the decoding options. 355 * @param cropAndScaleStrategy Pointer to the strategy for executing the cropping and scaling operations when both 356 * desiredSize and desiredRegion are specified. 357 * @return Returns one of the following result codes: 358 * {@link IMAGE_SUCCESS}: The execution is successful. 359 * {@link IMAGE_BAD_PARAMETER}: options or cropAndScaleStrategy is a null pointer. 360 * @since 18 361 */ 362 Image_ErrorCode OH_DecodingOptions_GetCropAndScaleStrategy(OH_DecodingOptions *options, 363 int32_t *cropAndScaleStrategy); 364 365 /** 366 * @brief Set desiredDynamicRange number for OH_DecodingOptions struct. 367 * 368 * @param options The OH_DecodingOptions pointer will be operated. Pointer connot be null. 369 * @param desiredDynamicRange the number of desired dynamic range {@link IMAGE_DYNAMIC_RANGE}. 370 * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - The operation is successful. 371 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - Parameter error.Possible causes:Parameter verification failed. 372 * @since 12 373 */ 374 Image_ErrorCode OH_DecodingOptions_SetDesiredDynamicRange(OH_DecodingOptions *options, 375 int32_t desiredDynamicRange); 376 377 /** 378 * @brief Sets the crop region for the decoding options. 379 * 380 * @param options Pointer to the decoding options. 381 * @param cropRegion The target region will be cropped from the image. 382 * @return Returns one of the following result codes: 383 * {@link IMAGE_SUCCESS} if the execution is successful. 384 * {@link IMAGE_SOURCE_INVALID_PARAMETER} if options or cropRegion is null pointer. 385 * @since 19 386 */ 387 Image_ErrorCode OH_DecodingOptions_SetCropRegion(OH_DecodingOptions *options, Image_Region *cropRegion); 388 389 /** 390 * @brief Gets the crop region for the decoding options. 391 * 392 * @param options Pointer to the decoding options. 393 * @param cropRegion The target region will be cropped from the image. 394 * @return Returns one of the following result codes: 395 * {@link IMAGE_SUCCESS} if the execution is successful. 396 * {@link IMAGE_SOURCE_INVALID_PARAMETER} if options or cropRegion is null pointer. 397 * @since 19 398 */ 399 Image_ErrorCode OH_DecodingOptions_GetCropRegion(OH_DecodingOptions *options, Image_Region *cropRegion); 400 401 /** 402 * @brief Obtains the color space set in the decoding options. 403 * 404 * @param options Pointer to the decoding options. 405 * @param colorSpace Pointer to the color space, {@link ColorSpaceName}. 406 * @return Returns one of the following result codes: 407 * {@link IMAGE_SUCCESS}: if the execution is successful. 408 * {@link IMAGE_SOURCE_INVALID_PARAMETER}: if options or colorSpace is null pointer. 409 * @since 20 410 */ 411 Image_ErrorCode OH_DecodingOptions_GetDesiredColorSpace(OH_DecodingOptions *options, int32_t *colorSpace); 412 413 /** 414 * @brief Sets desired color space for decoding options. 415 * 416 * @param options Pointer to the decoding options. 417 * @param colorSpace Desired color space, {@link ColorSpaceName}. 418 * @return Returns one of the following result codes: 419 * {@link IMAGE_SUCCESS}: if the execution is successful. 420 * {@link IMAGE_SOURCE_INVALID_PARAMETER}: if options is a null pointer or colorSpace is not supported. 421 * @since 20 422 */ 423 Image_ErrorCode OH_DecodingOptions_SetDesiredColorSpace(OH_DecodingOptions *options, int32_t colorSpace); 424 425 /** 426 * @brief delete OH_DecodingOptions pointer. 427 * 428 * @param options The OH_DecodingOptions pointer will be operated. 429 * @return Returns {@link Image_ErrorCode} 430 * @since 12 431 */ 432 Image_ErrorCode OH_DecodingOptions_Release(OH_DecodingOptions *options); 433 434 /** 435 * @brief Creates an ImageSource pointer. 436 * 437 * @param uri Indicates a pointer to the image source URI. Only a file URI or Base64 URI is accepted. 438 * @param uriSize Indicates the length of the image source URI. 439 * @param res Indicates a pointer to the <b>ImageSource</b> object created at the C++ native layer. 440 * @return Returns {@link Image_ErrorCode} 441 * @since 12 442 */ 443 Image_ErrorCode OH_ImageSourceNative_CreateFromUri(char *uri, size_t uriSize, OH_ImageSourceNative **res); 444 445 /** 446 * @brief Creates an void pointer 447 * 448 * @param fd Indicates the image source file descriptor. 449 * @param res Indicates a void pointer to the <b>ImageSource</b> object created at the C++ native layer. 450 * @return Returns {@link Image_ErrorCode} 451 * @since 12 452 */ 453 Image_ErrorCode OH_ImageSourceNative_CreateFromFd(int32_t fd, OH_ImageSourceNative **res); 454 455 /** 456 * @brief Creates an void pointer 457 * 458 * @param data Indicates a pointer to the image source data. Only a formatted packet data or Base64 data is accepted. 459 * @param dataSize Indicates the size of the image source data. 460 * @param res Indicates a void pointer to the <b>ImageSource</b> object created at the C++ native layer. 461 * @return Returns {@link Image_ErrorCode} 462 * @since 12 463 */ 464 Image_ErrorCode OH_ImageSourceNative_CreateFromData(uint8_t *data, size_t dataSize, OH_ImageSourceNative **res); 465 466 /** 467 * @brief Create an image source from data buffer. The data buffer is directly accessed by the image source 468 * object, and therefore the data buffer must remain accessible within the lifecycle of the image source object. 469 * 470 * @param data Pointer to the data buffer. 471 * @param datalength Length of the data buffer. 472 * @param imageSource Double pointer to the image source. 473 * @return Result code. 474 * {@link IMAGE_SUCCESS} if the execution is successful. 475 * {@link IMAGE_SOURCE_INVALID_PARAMETER} if data or imageSource is a null pointer or if datalength is 0. 476 * @since 20 477 */ 478 Image_ErrorCode OH_ImageSourceNative_CreateFromDataWithUserBuffer(uint8_t *data, size_t datalength, 479 OH_ImageSourceNative **imageSource); 480 481 /** 482 * @brief Creates an void pointer 483 * 484 * @param rawFile Indicates the raw file's file descriptor. 485 * @param res Indicates a void pointer to the <b>ImageSource</b> object created at the C++ native layer. 486 * @return Returns {@link Image_ErrorCode} 487 * @since 12 488 */ 489 Image_ErrorCode OH_ImageSourceNative_CreateFromRawFile(RawFileDescriptor *rawFile, OH_ImageSourceNative **res); 490 491 /** 492 * @brief Decodes an void pointer 493 * based on the specified {@link OH_DecodingOptions} struct. 494 * 495 * @param source Indicates a void pointer(from ImageSource pointer convert). 496 * @param options Indicates a pointer to the options for decoding the image source. 497 * For details, see {@link OH_DecodingOptions}. 498 * @param pixelmap Indicates a void pointer to the <b>Pixelmap</b> object obtained at the C++ native layer. 499 * @return Returns {@link Image_ErrorCode} 500 * @since 12 501 */ 502 Image_ErrorCode OH_ImageSourceNative_CreatePixelmap(OH_ImageSourceNative *source, OH_DecodingOptions *options, 503 OH_PixelmapNative **pixelmap); 504 505 /** 506 * @brief Creates a PixelMap based on decoding parameters {@link OH_DecodingOptions}, the memory type used by the 507 * PixelMap can be specified by allocatorType {@link IMAGE_ALLOCATOR_TYPE}. By default, the system selects the memory 508 * type based on the image type, image size, platform capability, etc. When processing the PixelMap returned by this 509 * interface, please always consider the impact of stride. 510 * 511 * @param source Image Source. 512 * @param options Decoding parameters, such as the size, pixel format, and color space of the pixelMap. 513 * For details, see {@link OH_DecodingOptions}. 514 * @param allocator Indicate which memory type will be used by the returned PixelMap. 515 * @param pixelmap Decoded <b>Pixelmap</b> object. 516 * @return Error code. 517 * {@link IMAGE_SUCCESS} if the execution is successful. 518 * {@link IMAGE_BAD_PARAMETER} source is nullptr, or picture is nullptr. 519 * {@link IMAGE_BAD_SOURCE} data source exception. 520 * {@link IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE} unsupported mime type. 521 * {@link IMAGE_SOURCE_TOO_LARGE} image to large. 522 * {@link IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE} unsupported allocator type, 523 * e.g., use share memory to decode a HDR image as only DMA supported hdr metadata. 524 * {@link IMAGE_SOURCE_UNSUPPORTED_OPTIONS} unsupported options, 525 * e.g, cannot convert image into desired pixel format. 526 * {@link IMAGE_DECODE_FAILED} decode failed. 527 * {@link IMAGE_SOURCE_ALLOC_FAILED} memory allocation failed. 528 * @since 15 529 */ 530 Image_ErrorCode OH_ImageSourceNative_CreatePixelmapUsingAllocator(OH_ImageSourceNative *source, 531 OH_DecodingOptions *options, IMAGE_ALLOCATOR_TYPE allocator, OH_PixelmapNative **pixelmap); 532 533 534 /** 535 * @brief Decodes an void pointer 536 * the <b>Pixelmap</b> objects at the C++ native layer 537 * based on the specified {@link OH_DecodingOptions} struct. 538 * 539 * @param source Indicates a void pointer(from ImageSource pointer convert). 540 * @param options Indicates a pointer to the options for decoding the image source. 541 * For details, see {@link OH_DecodingOptions}. 542 * @param resVecPixMap Indicates a pointer array to the <b>Pixelmap</b> objects obtained at the C++ native layer. 543 * It cannot be a null pointer. 544 * @param size Indicates a size of resVecPixMap. User can get size from {@link OH_ImageSourceNative_GetFrameCount}. 545 * @return Returns {@link Image_ErrorCode} 546 * @since 12 547 */ 548 Image_ErrorCode OH_ImageSourceNative_CreatePixelmapList(OH_ImageSourceNative *source, OH_DecodingOptions *options, 549 OH_PixelmapNative *resVecPixMap[], size_t size); 550 551 /** 552 * @brief Create Picture pointer from ImageSource 553 * based on the specified {@link OH_DecodingOptionsForPicture} struct. 554 * 555 * @param source Indicates a void pointer(from ImageSource pointer convert). 556 * @param options Indicates a pointer to the options for decoding the image source. 557 * For details, see {@link OH_DecodingOptionsForPicture}. 558 * @param picture Indicates a void pointer to the <b>Picture</b> object obtained at the C++ native layer. 559 * @return Image functions result code. 560 * {@link IMAGE_SUCCESS} if the execution is successful. 561 * {@link IMAGE_BAD_PARAMETER} source is nullptr, or picture is nullptr. 562 * {@link IMAGE_DECODE_FAILED} decode failed. 563 * @since 13 564 */ 565 Image_ErrorCode OH_ImageSourceNative_CreatePicture(OH_ImageSourceNative *source, OH_DecodingOptionsForPicture *options, 566 OH_PictureNative **picture); 567 568 /** 569 * @brief Decodes an image at the specified index into a Picture object. 570 * 571 * @param source Pointer to the image source. 572 * @param index Image index. 573 * @param picture Double pointer to the Picture object obtained after decoding. 574 * @return Returns one of the following result codes: 575 * {@link IMAGE_SUCCESS} if the execution is successful. 576 * {@link IMAGE_BAD_SOURCE} if the data source is abnormal. 577 * {@link IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE} if the image format is unsupported. 578 * {@link IMAGE_SOURCE_TOO_LARGE} if the image is too large. 579 * {@link IMAGE_SOURCE_UNSUPPORTED_OPTIONS} if the operation is not supported, for example, invalid index. 580 * {@link IMAGE_DECODE_FAILED} if decoding failed. 581 * @since 20 582 */ 583 Image_ErrorCode OH_ImageSourceNative_CreatePictureAtIndex(OH_ImageSourceNative *source, uint32_t index, 584 OH_PictureNative **picture); 585 586 /** 587 * @brief Obtains the delay time list from some <b>ImageSource</b> objects (such as GIF image sources). 588 * 589 * @param source Indicates a void pointer(from ImageSource pointer convert). 590 * @param delayTimeList Indicates a pointer to the delay time list obtained. It cannot be a null pointer. 591 * @param size Indicates a size of delayTimeList. User can get size from {@link OH_ImageSourceNative_GetFrameCount}. 592 * @return Returns {@link Image_ErrorCode} 593 * @since 12 594 */ 595 Image_ErrorCode OH_ImageSourceNative_GetDelayTimeList(OH_ImageSourceNative *source, int32_t *delayTimeList, size_t size); 596 597 /** 598 * @brief Obtains image source information from an <b>ImageSource</b> object by index. 599 * 600 * @param source Indicates a void pointer(from ImageSource pointer convert). 601 * @param index Indicates the index of the frame. 602 * @param info Indicates a pointer to the image source information obtained. 603 * For details, see {@link OH_ImageSource_Info}. 604 * @return Returns {@link Image_ErrorCode} 605 * @since 12 606 */ 607 Image_ErrorCode OH_ImageSourceNative_GetImageInfo(OH_ImageSourceNative *source, int32_t index, 608 OH_ImageSource_Info *info); 609 610 /** 611 * @brief Obtains the value of an image property from an <b>ImageSource</b> object. 612 * 613 * @param source Indicates a void pointer(from ImageSource pointer convert). 614 * @param key Indicates a pointer to the property. For details, see {@link Image_String}., key is an exif constant. 615 * Release after use ImageSource, see {@link OH_ImageSourceNative_Release}. 616 * @param value Indicates a pointer to the value obtained.The user can pass in a null pointer and zero size, 617 * we will allocate memory, but user must free memory after use. 618 * @return Returns {@link Image_ErrorCode} 619 * @since 12 620 */ 621 Image_ErrorCode OH_ImageSourceNative_GetImageProperty(OH_ImageSourceNative *source, Image_String *key, 622 Image_String *value); 623 624 /** 625 * @brief Obtains the value of an image property from an <b>ImageSource</b> object. The output value.data is null-terminated. 626 * 627 * @param source Pointer to ImageSource. 628 * @param key Pointer to the property key. 629 * @param value Pointer to the property value. Output Parameter. 630 * @return Returns One of the following result codes: 631 * {@link IMAGE_SUCCESS} if the execution is successful. 632 * {@link IMAGE_SOURCE_INVALID_PARAMETER} if source, key or value is nullptr. 633 * @since 19 634 */ 635 Image_ErrorCode OH_ImageSourceNative_GetImagePropertyWithNull(OH_ImageSourceNative *source, Image_String *key, 636 Image_String *value); 637 638 /** 639 * @brief Modifies the value of an image property of an <b>ImageSource</b> object. 640 * @param source Indicates a void pointer(from ImageSource pointer convert). 641 * @param key Indicates a pointer to the property. For details, see {@link Image_String}., key is an exif constant. 642 * Release after use ImageSource, see {@link OH_ImageSourceNative_Release}. 643 * @param value Indicates a pointer to the new value of the property. 644 * @return Returns {@link Image_ErrorCode} 645 * @since 12 646 */ 647 Image_ErrorCode OH_ImageSourceNative_ModifyImageProperty(OH_ImageSourceNative *source, Image_String *key, 648 Image_String *value); 649 650 /** 651 * @brief Obtains the number of frames from an <b>ImageSource</b> object. 652 * 653 * @param source Indicates a pointer to the {@link OH_ImageSource} object at the C++ native layer. 654 * @param frameCount The number of image frameCount. 655 * @return Returns {@link Image_ErrorCode} 656 * @since 12 657 */ 658 Image_ErrorCode OH_ImageSourceNative_GetFrameCount(OH_ImageSourceNative *source, uint32_t *frameCount); 659 660 /** 661 * @brief Releases an <b>ImageSourc</b> object. 662 * 663 * @param source Indicates a ImageSource pointer. 664 * @return Returns {@link Image_ErrorCode} 665 * @since 12 666 */ 667 Image_ErrorCode OH_ImageSourceNative_Release(OH_ImageSourceNative *source); 668 669 /** 670 * @brief Create a pointer for OH_DecodingOptionsForPicture struct. 671 * 672 * @param options The OH_DecodingOptionsForPicture pointer will be operated. 673 * @return Image functions result code. 674 * {@link IMAGE_SUCCESS} if the execution is successful. 675 * {@link IMAGE_BAD_PARAMETER} options is nullptr. 676 * @since 13 677 */ 678 Image_ErrorCode OH_DecodingOptionsForPicture_Create(OH_DecodingOptionsForPicture **options); 679 680 /** 681 * @brief Obtains the desired auxiliary pictures of decoding options. 682 * 683 * @param options The OH_DecodingOptionsForPicture pointer will be operated. 684 * @param desiredAuxiliaryPictures The desired auxiliary pictures in DecodingOptionsForPicture. 685 * @param length The length of desired auxiliary pictures. 686 * @return Image functions result code. 687 * {@link IMAGE_SUCCESS} if the execution is successful. 688 * {@link IMAGE_BAD_PARAMETER} options is nullptr, desiredAuxiliaryPictures is nullptr, 689 * or length is invalid. 690 * @since 13 691 */ 692 Image_ErrorCode OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options, 693 Image_AuxiliaryPictureType **desiredAuxiliaryPictures, size_t *length); 694 695 /** 696 * @brief Set decoding options desired auxiliary pictures. 697 * 698 * @param options The OH_DecodingOptionsForPicture pointer will be operated. 699 * @param desiredAuxiliaryPictures The desired auxiliary pictures will be set. 700 * @param length The length of desired auxiliary pictures. 701 * @return Image functions result code. 702 * {@link IMAGE_SUCCESS} if the execution is successful. 703 * {@link IMAGE_BAD_PARAMETER} options is nullptr, desiredAuxiliaryPictures is nullptr, 704 * or length is invalid. 705 * @since 13 706 */ 707 Image_ErrorCode OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options, 708 Image_AuxiliaryPictureType *desiredAuxiliaryPictures, size_t length); 709 710 /** 711 * @brief Releases an <b>DecodingOptionsForPicture</b> object. 712 * 713 * @param options Indicates a DecodingOptionsForPicture pointer. 714 * @return Image functions result code. 715 * {@link IMAGE_SUCCESS} if the execution is successful. 716 * {@link IMAGE_BAD_PARAMETER} options is nullptr. 717 * @since 13 718 */ 719 Image_ErrorCode OH_DecodingOptionsForPicture_Release(OH_DecodingOptionsForPicture *options); 720 721 /** 722 * @brief Obtains the supported image formats that can be decoded. 723 * 724 * @param supportedFormats Double pointer to an array of the supported image formats. 725 * @param length Pointer to the length of the array. 726 * @return One of the following result codes: 727 * {@link IMAGE_SUCCESS} if the execution is successful. 728 * {@link IMAGE_SOURCE_INVALID_PARAMETER} if <b>supportedFormats</b> or <b>length</b> is empty. 729 * @since 20 730 */ 731 Image_ErrorCode OH_ImageSourceNative_GetSupportedFormats(Image_MimeType **supportedFormats, size_t *length); 732 #ifdef __cplusplus 733 }; 734 #endif 735 /** @} */ 736 #endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_IMAGE_SOURCE_NATIVE_H_