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 image 18 * @{ 19 * 20 * @brief Provides APIs for obtaining pixel map data and information. 21 * 22 * @Syscap SystemCapability.Multimedia.Image.Core 23 * @since 12 24 */ 25 26 /** 27 * @file pixelmap_native.h 28 * 29 * @brief Declares the APIs that can access a pixel map. 30 * 31 * @library libpixelmap.so 32 * @Syscap SystemCapability.Multimedia.Image.Core 33 * @since 12 34 */ 35 36 #ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXELMAP_NATIVE_H 37 #define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXELMAP_NATIVE_H 38 #include "image_common.h" 39 #include "napi/native_api.h" 40 #include "napi/native_node_api.h" 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /** 47 * @brief Define a Pixelmap struct type, used for pixelmap pointer controls. 48 * 49 * @since 12 50 */ 51 struct OH_PixelmapNative; 52 typedef struct OH_PixelmapNative OH_PixelmapNative; 53 54 /** 55 * @brief Define a native buffer type, used for retrieving a native buffer. 56 * 57 * @since 12 58 */ 59 struct OH_NativeBuffer; 60 typedef struct OH_NativeBuffer OH_NativeBuffer; 61 62 /** 63 * @brief Define a native ColorSpaceManager type, used for retrieving a native ColorSpaceManager. 64 * 65 * @since 13 66 */ 67 typedef struct OH_NativeColorSpaceManager OH_NativeColorSpaceManager; 68 69 /** 70 * @brief Define a pixelmap alpha type. 71 * 72 * @since 12 73 */ 74 typedef enum { 75 /* 76 * Unknown format 77 */ 78 PIXELMAP_ALPHA_TYPE_UNKNOWN = 0, 79 /* 80 * Opaque format 81 */ 82 PIXELMAP_ALPHA_TYPE_OPAQUE = 1, 83 /* 84 * Premultiplied format 85 */ 86 PIXELMAP_ALPHA_TYPE_PREMULTIPLIED = 2, 87 /* 88 * UnPremultiplied format 89 */ 90 PIXELMAP_ALPHA_TYPE_UNPREMULTIPLIED = 3, 91 }PIXELMAP_ALPHA_TYPE; 92 93 typedef enum { 94 /* 95 * Unknown format 96 */ 97 PIXEL_FORMAT_UNKNOWN = 0, 98 /* 99 * RGB_565 format 100 */ 101 PIXEL_FORMAT_RGB_565 = 2, 102 /* 103 * RGBA_8888 format 104 */ 105 PIXEL_FORMAT_RGBA_8888 = 3, 106 /* 107 * BGRA_8888 format 108 */ 109 PIXEL_FORMAT_BGRA_8888 = 4, 110 /* 111 * RGB_888 format 112 */ 113 PIXEL_FORMAT_RGB_888 = 5, 114 /* 115 * ALPHA_8 format 116 */ 117 PIXEL_FORMAT_ALPHA_8 = 6, 118 /* 119 * RGBA_F16 format 120 */ 121 PIXEL_FORMAT_RGBA_F16 = 7, 122 /* 123 * NV21 format 124 */ 125 PIXEL_FORMAT_NV21 = 8, 126 /* 127 * NV12 format 128 */ 129 PIXEL_FORMAT_NV12 = 9, 130 /* 131 * RGBA_1010102 format 132 */ 133 PIXEL_FORMAT_RGBA_1010102 = 10, 134 /* 135 * YCBCR_P010 format 136 */ 137 PIXEL_FORMAT_YCBCR_P010 = 11, 138 /* 139 * YCRCB_P010 format 140 */ 141 PIXEL_FORMAT_YCRCB_P010 = 12, 142 } PIXEL_FORMAT; 143 144 typedef enum { 145 IMAGE_FORMAT_UNKNOWN, 146 IMAGE_FORMAT_YUV_TYPE, 147 IMAGE_FORMAT_RGB_TYPE 148 } IMAGE_FORMAT; 149 150 /** 151 * @brief Defines the anti-aliasing level. 152 * 153 * @since 12 154 */ 155 typedef enum { 156 /** 157 * Nearest-neighbor interpolation algorithm 158 */ 159 OH_PixelmapNative_AntiAliasing_NONE = 0, 160 /** 161 * Bilinear interpolation algorithm 162 */ 163 OH_PixelmapNative_AntiAliasing_LOW = 1, 164 /** 165 * Bilinear interpolation algorithm with mipmap linear filtering 166 */ 167 OH_PixelmapNative_AntiAliasing_MEDIUM = 2, 168 /** 169 * Cubic interpolation algorithm 170 */ 171 OH_PixelmapNative_AntiAliasing_HIGH = 3, 172 } OH_PixelmapNative_AntiAliasingLevel; 173 174 /** 175 * @brief Enumerates the HDR metadata types that need to be stored in Pixelmap. 176 * 177 * @since 12 178 */ 179 typedef enum { 180 /** 181 * Indicates the types of metadata that image needs to use. 182 */ 183 HDR_METADATA_TYPE = 0, 184 /** 185 * Static metadata key. 186 */ 187 HDR_STATIC_METADATA = 1, 188 /** 189 * Dynamic metadata key. 190 */ 191 HDR_DYNAMIC_METADATA = 2, 192 /** 193 * Gainmap metadata key. 194 */ 195 HDR_GAINMAP_METADATA = 3, 196 } OH_Pixelmap_HdrMetadataKey; 197 198 /** 199 * @brief Value for HDR_METADATA_TYPE. 200 * 201 * @since 12 202 */ 203 typedef enum { 204 /** 205 * No metadata. 206 */ 207 HDR_METADATA_TYPE_NONE = 0, 208 /** 209 * Indicates that metadata will be used for the base image. 210 */ 211 HDR_METADATA_TYPE_BASE = 1, 212 /** 213 * Indicates that metadata will be used for the gainmap image. 214 */ 215 HDR_METADATA_TYPE_GAINMAP = 2, 216 /** 217 * Indicates that metadata will be used for the alternate image. 218 */ 219 HDR_METADATA_TYPE_ALTERNATE = 3, 220 } OH_Pixelmap_HdrMetadataType; 221 222 /** 223 * @brief Value for HDR_DYNAMIC_METADATA. 224 * 225 * @since 12 226 */ 227 typedef struct OH_Pixelmap_HdrStaticMetadata { 228 /** 229 * The X-coordinate of the primary colors. The length of the array is three. Store in the order of r, g, b. 230 */ 231 float displayPrimariesX[3]; 232 /** 233 * The Y-coordinate of the primary colors. The length of the array is three. Store in the order of r, g, b. 234 */ 235 float displayPrimariesY[3]; 236 /** 237 * The X-coordinate of the white point value. 238 */ 239 float whitePointX; 240 /** 241 * The Y-coordinate of the white point value. 242 */ 243 float whitePointY; 244 /** 245 * Max luminance. 246 */ 247 float maxLuminance; 248 /** 249 * Min luminance. 250 */ 251 float minLuminance; 252 /** 253 * Maximun brightness of displayed content. 254 */ 255 float maxContentLightLevel; 256 /** 257 * Maximun average brightness of displayed content. 258 */ 259 float maxFrameAverageLightLevel; 260 } OH_Pixelmap_HdrStaticMetadata; 261 262 /** 263 * @brief Value for HDR_DYNAMIC_METADATA. 264 * 265 * @since 12 266 */ 267 typedef struct OH_Pixelmap_HdrDynamicMetadata { 268 /** 269 * The value of dynamic metadata. 270 */ 271 uint8_t* data; 272 /** 273 * The length of dynamic metadata. 274 */ 275 uint32_t length; 276 } OH_Pixelmap_HdrDynamicMetadata; 277 278 /** 279 * @brief Value for HDR_GAINMAP_METADATA. 280 * 281 * @since 12 282 */ 283 typedef struct OH_Pixelmap_HdrGainmapMetadata { 284 /** 285 * The version used by the writer. 286 */ 287 uint16_t writerVersion; 288 /** 289 * The minmum version a parser needs to understand. 290 */ 291 uint16_t minVersion; 292 /** 293 * The number of gain map channels, with a value of 1 or 3. 294 */ 295 uint8_t gainmapChannelNum; 296 /** 297 * Indicate whether to use the color space of the base image. 298 */ 299 bool useBaseColorFlag; 300 /** 301 * The baseline hdr headroom. 302 */ 303 float baseHdrHeadroom; 304 /** 305 * The alternate hdr headroom. 306 */ 307 float alternateHdrHeadroom; 308 /** 309 * The per-component max gain map values. 310 */ 311 float gainmapMax[3]; 312 /** 313 * The per-component min gain map values. 314 */ 315 float gainmapMin[3]; 316 /** 317 * The per-component gamma values. 318 */ 319 float gamma[3]; 320 /** 321 * The per-component baseline offset. 322 */ 323 float baselineOffset[3]; 324 /** 325 * The per-component alternate offset. 326 */ 327 float alternateOffset[3]; 328 } OH_Pixelmap_HdrGainmapMetadata; 329 330 /** 331 * @brief Value for HDR_METADATA_KEY. Corresponding relationship with HDR_METADATA_KEY. 332 * 333 * @since 12 334 */ 335 typedef struct OH_Pixelmap_HdrMetadataValue { 336 /** 337 * The value corresponding to the HDR_METADATA_TYPE key 338 */ 339 OH_Pixelmap_HdrMetadataType type; 340 /** 341 * The value corresponding to the HDR_STATIC_METADATA key 342 */ 343 OH_Pixelmap_HdrStaticMetadata staticMetadata; 344 /** 345 * The value corresponding to the HDR_DYNAMIC_METADATA key 346 */ 347 OH_Pixelmap_HdrDynamicMetadata dynamicMetadata; 348 /** 349 * The value corresponding to the HDR_GAINMAP_METADATA key 350 */ 351 OH_Pixelmap_HdrGainmapMetadata gainmapMetadata; 352 } OH_Pixelmap_HdrMetadataValue; 353 354 /** 355 * @brief Defines the options used for creating a pixel map. 356 * 357 * @since 12 358 */ 359 struct OH_Pixelmap_InitializationOptions; 360 typedef struct OH_Pixelmap_InitializationOptions OH_Pixelmap_InitializationOptions; 361 362 /** 363 * @brief Create a for InitializationOtions struct. 364 * 365 * @param options The InitializationOtions pointer will be operated. 366 * @return Returns {@link Image_ErrorCode} 367 * @since 12 368 */ 369 Image_ErrorCode OH_PixelmapInitializationOptions_Create(OH_Pixelmap_InitializationOptions **options); 370 371 /** 372 * @brief Get width number for InitializationOtions struct. 373 * 374 * @param options The InitializationOtions pointer will be operated. 375 * @param width the number of image width. 376 * @return Returns {@link Image_ErrorCode} 377 * @since 12 378 */ 379 Image_ErrorCode OH_PixelmapInitializationOptions_GetWidth(OH_Pixelmap_InitializationOptions *options, 380 uint32_t *width); 381 382 /** 383 * @brief Set width number for InitializationOtions struct. 384 * 385 * @param options The InitializationOtions pointer will be operated. 386 * @param width the number of image width. 387 * @return Returns {@link Image_ErrorCode} 388 * @since 12 389 */ 390 Image_ErrorCode OH_PixelmapInitializationOptions_SetWidth(OH_Pixelmap_InitializationOptions *options, 391 uint32_t width); 392 393 /** 394 * @brief Get height number for InitializationOtions struct. 395 * 396 * @param options The InitializationOtions pointer will be operated. 397 * @param height the number of image height. 398 * @return Returns {@link Image_ErrorCode} 399 * @since 12 400 */ 401 Image_ErrorCode OH_PixelmapInitializationOptions_GetHeight(OH_Pixelmap_InitializationOptions *options, 402 uint32_t *height); 403 404 /** 405 * @brief Set height number for InitializationOtions struct. 406 * 407 * @param options The InitializationOtions pointer will be operated. 408 * @param height the number of image height. 409 * @return Returns {@link Image_ErrorCode} 410 * @since 12 411 */ 412 Image_ErrorCode OH_PixelmapInitializationOptions_SetHeight(OH_Pixelmap_InitializationOptions *options, 413 uint32_t height); 414 415 /** 416 * @brief Get pixelFormat number for InitializationOtions struct. 417 * 418 * @param options The InitializationOtions pointer will be operated. 419 * @param pixelFormat the number of image pixelFormat. 420 * @return Returns {@link Image_ErrorCode} 421 * @since 12 422 */ 423 Image_ErrorCode OH_PixelmapInitializationOptions_GetPixelFormat(OH_Pixelmap_InitializationOptions *options, 424 int32_t *pixelFormat); 425 426 /** 427 * @brief Set pixelFormat number for InitializationOtions struct. 428 * 429 * @param options The InitializationOtions pointer will be operated. 430 * @param pixelFormat the number of image pixelFormat. 431 * @return Returns {@link Image_ErrorCode} 432 * @since 12 433 */ 434 Image_ErrorCode OH_PixelmapInitializationOptions_SetPixelFormat(OH_Pixelmap_InitializationOptions *options, 435 int32_t pixelFormat); 436 437 /** 438 * @brief Get pixelFormat number for InitializationOtions struct. 439 * 440 * @param options The InitializationOtions pointer will be operated. 441 * @param srcpixelFormat the number of image srcpixelFormat. 442 * @return Returns {@link Image_ErrorCode} 443 * @since 12 444 */ 445 Image_ErrorCode OH_PixelmapInitializationOptions_GetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options, 446 int32_t *srcpixelFormat); 447 448 /** 449 * @brief Set pixelFormat number for InitializationOtions struct. 450 * 451 * @param options The InitializationOtions pointer will be operated. 452 * @param srcpixelFormat the number of image srcpixelFormat. 453 * @return Returns {@link Image_ErrorCode} 454 * @since 12 455 */ 456 Image_ErrorCode OH_PixelmapInitializationOptions_SetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options, 457 int32_t srcpixelFormat); 458 459 /** 460 * @brief Get rowStride for InitializationOptions struct. 461 * 462 * @param options The InitializationOptions pointer will be operated. 463 * @param rowStride the rowStride of image buffer. 464 * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. 465 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if rowStride is null. 466 * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error, maybe options is released. 467 * @since 12 468 */ 469 Image_ErrorCode OH_PixelmapInitializationOptions_GetRowStride(OH_Pixelmap_InitializationOptions *options, 470 int32_t *rowStride); 471 472 /** 473 * @brief Set rowStride number for InitializationOptions struct. 474 * 475 * @param options The InitializationOptions pointer will be operated. 476 * @param rowStride the rowStride of image buffer. 477 * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. 478 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if rowStride does not match width. 479 * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error, maybe options is released. 480 * @since 12 481 */ 482 Image_ErrorCode OH_PixelmapInitializationOptions_SetRowStride(OH_Pixelmap_InitializationOptions *options, 483 int32_t rowStride); 484 485 /** 486 * @brief Get alphaType number for InitializationOtions struct. 487 * 488 * @param options The InitializationOtions pointer will be operated. 489 * @param alphaType the number of image alphaType. 490 * @return Returns {@link Image_ErrorCode} 491 * @since 12 492 */ 493 Image_ErrorCode OH_PixelmapInitializationOptions_GetAlphaType(OH_Pixelmap_InitializationOptions *options, 494 int32_t *alphaType); 495 496 /** 497 * @brief Set alphaType number for InitializationOtions struct. 498 * 499 * @param options The InitializationOtions pointer will be operated. 500 * @param alphaType the number of image alphaType. 501 * @return Returns {@link Image_ErrorCode} 502 * @since 12 503 */ 504 Image_ErrorCode OH_PixelmapInitializationOptions_SetAlphaType(OH_Pixelmap_InitializationOptions *options, 505 int32_t alphaType); 506 507 /** 508 * @brief delete InitializationOtions pointer. 509 * 510 * @param options The InitializationOtions pointer will be operated. 511 * @return Returns {@link Image_ErrorCode} 512 * @since 12 513 */ 514 Image_ErrorCode OH_PixelmapInitializationOptions_Release(OH_Pixelmap_InitializationOptions *options); 515 516 /** 517 * @brief Defines the pixel map information. 518 * 519 * @since 12 520 */ 521 struct OH_Pixelmap_ImageInfo; 522 typedef struct OH_Pixelmap_ImageInfo OH_Pixelmap_ImageInfo; 523 524 /** 525 * @brief Create imageinfo struct . 526 * 527 * @param info The imageinfo pointer will be operated. 528 * @return Returns {@link Image_ErrorCode} 529 * @since 12 530 */ 531 Image_ErrorCode OH_PixelmapImageInfo_Create(OH_Pixelmap_ImageInfo **info); 532 533 /** 534 * @brief Get width number for imageinfo struct. 535 * 536 * @param info The imageinfo pointer will be operated. 537 * @param width The number of imageinfo width. 538 * @return Returns {@link Image_ErrorCode} 539 * @since 12 540 */ 541 Image_ErrorCode OH_PixelmapImageInfo_GetWidth(OH_Pixelmap_ImageInfo *info, uint32_t *width); 542 543 /** 544 * @brief Get height number for imageinfo struct. 545 * 546 * @param info The imageinfo pointer will be operated. 547 * @param height The number of imageinfo height. 548 * @return Returns {@link Image_ErrorCode} 549 * @since 12 550 */ 551 Image_ErrorCode OH_PixelmapImageInfo_GetHeight(OH_Pixelmap_ImageInfo *info, uint32_t *height); 552 553 /** 554 * @brief Get rowStride number for imageinfo struct. 555 * 556 * @param info The imageinfo pointer will be operated. 557 * @param rowStride The number of imageinfo rowStride. 558 * @return Returns {@link Image_ErrorCode} 559 * @since 12 560 */ 561 Image_ErrorCode OH_PixelmapImageInfo_GetRowStride(OH_Pixelmap_ImageInfo *info, uint32_t *rowStride); 562 563 /** 564 * @brief Get pixelFormat number for imageinfo struct. 565 * 566 * @param info The imageinfo pointer will be operated. 567 * @param pixelFormat The number of imageinfo pixelFormat. 568 * @return Returns {@link Image_ErrorCode} 569 * @since 12 570 */ 571 Image_ErrorCode OH_PixelmapImageInfo_GetPixelFormat(OH_Pixelmap_ImageInfo *info, int32_t *pixelFormat); 572 573 /** 574 * @brief Get density number for imageinfo struct. 575 * 576 * @param info The imageinfo pointer will be operated. 577 * @param density The number of imageinfo density. 578 * @return Returns {@link Image_ErrorCode} 579 * @since 12 580 */ 581 Image_ErrorCode OH_PixelmapImageInfo_GetAlphaType(OH_Pixelmap_ImageInfo *info, int32_t *alphaType); 582 583 /** 584 * @brief Get isHdr boolean for imageinfo struct. 585 * 586 * @param info The imageinfo pointer will be operated. 587 * @param isHdr Whether the image has a high dynamic range. 588 * @return Returns {@link Image_ErrorCode} 589 * @since 12 590 */ 591 Image_ErrorCode OH_PixelmapImageInfo_GetDynamicRange(OH_Pixelmap_ImageInfo *info, bool *isHdr); 592 593 /** 594 * @brief Delete imageinfo struct pointer. 595 * 596 * @param info The imageinfo pointer will be operated. 597 * @return Returns {@link Image_ErrorCode} 598 * @since 12 599 */ 600 Image_ErrorCode OH_PixelmapImageInfo_Release(OH_Pixelmap_ImageInfo *info); 601 602 /** 603 * @brief Creates a <b>PixelMap</b> object. 604 * 605 * @param data Color buffer in BGRA_8888 format. 606 * @param dataLength Color buffer size in BGRA_8888 format. 607 * @param options IPixel properties, including the alpha type, size, pixel format, and editable. 608 * @param pixelmap Pixelmap pointer for created. 609 * @return Returns {@link Image_ErrorCode} 610 * @since 12 611 */ 612 Image_ErrorCode OH_PixelmapNative_CreatePixelmap(uint8_t *data, size_t dataLength, 613 OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap); 614 615 /** 616 * @brief Convert a native <b>PixelMap</b> object to <b>PixelMap</b> napi object. 617 * 618 * @param env Indicates the NAPI environment pointer. 619 * @param pixelmapNative Indicates a pointer to the <b>PixelMap</b> object created at the native layer. 620 * @param pixelmapNapi the <b>PixelMap</b> pointer will be converted. 621 * @return Image functions result code. 622 * {@link IMAGE_SUCCESS} if the execution is successful. 623 * {@link IMAGE_BAD_PARAMETER} pixelmapNative is nullptr 624 * @since 12 625 */ 626 Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeToNapi(napi_env env, OH_PixelmapNative *pixelmapNative, 627 napi_value *pixelmapNapi); 628 629 /** 630 * @brief Convert a <b>PixelMap</b> napi object to native <b>PixelMap</b> object. 631 * 632 * @param env Indicates the NAPI environment pointer. 633 * @param pixelmapNapi Indicates napi <b>PixelMap</b> object. 634 * @param pixelmapNative Indicates native <b>PixelMap</b> pointer to created. 635 * @return Image functions result code. 636 * {@link IMAGE_SUCCESS} if the execution is successful. 637 * {@link IMAGE_BAD_PARAMETER} pixelmapNative is nullptr, or pixelmapNapi is not a PixelMap 638 * @since 12 639 */ 640 Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeFromNapi(napi_env env, napi_value pixelmapNapi, 641 OH_PixelmapNative **pixelmapNative); 642 643 /** 644 * @brief Reads data of this pixel map to an Buffer. If this pixel map is created in the BGRA_8888 format, 645 * the data read is the same as the original data. 646 * 647 * @param pixelmap The Pixelmap pointer will be operated. 648 * @param destination Buffer to which the image pixel map data will be written. 649 * @param bufferSize Buffer size to which the image pixel map data will be written. 650 * @return Returns {@link Image_ErrorCode} 651 * @see OH_PixelmapNative 652 * @since 12 653 */ 654 Image_ErrorCode OH_PixelmapNative_ReadPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize); 655 656 /** 657 * @brief Reads image data in an Buffer and writes the data to a Pixelmap object. 658 * 659 * @param pixelmap The Pixelmap pointer will be operated. 660 * @param source Buffer from which the image data will be read. 661 * @param bufferSize Buffer size from which the image data will be read. 662 * @return Returns {@link Image_ErrorCode} 663 * @see OH_PixelmapNative 664 * @since 12 665 */ 666 Image_ErrorCode OH_PixelmapNative_WritePixels(OH_PixelmapNative *pixelmap, uint8_t *source, size_t bufferSize); 667 668 /** 669 * @brief Get argb pixel buffer from pixelmap. 670 * 671 * @param pixelmap The Pixelmap pointer to be operated. 672 * @param destination Buffer to which the image pixel map data will be written. 673 * @param bufferSize Buffer size to which the image pixel map data will be written. 674 * @return Function result code: 675 * {@link IMAGE_SUCCESS} If the operation is successful. 676 * {@link IMAGE_BAD_PARAMETER} If invalid parameter, destination and bufferSize are incorrect. 677 * {@link IMAGE_UNSUPPORTED_CONVERSION} If format does not support conversion to argb or conversion failed. 678 * {@link IMAGE_ALLOC_FAILED} If device has no memory. 679 * {@link IMAGE_COPY_FAILED} If memory copy failed. 680 * @see OH_PixelmapNative 681 * @since 13 682 */ 683 Image_ErrorCode OH_PixelmapNative_GetArgbPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize); 684 685 /** 686 * @brief Convert {@link OH_PixelmapNative} to standard dynamic range. 687 * 688 * @param pixelmap The Pixelmap pointer will be operated. Pointer connot be null. 689 * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - The operation is successful. 690 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - Parameter error.Possible causes:Parameter verification failed. 691 * returns {@link Image_ErrorCode} IMAGE_UNSUPPORTED_OPERATION - Unsupported operation.Pixelmap can't be converted. 692 * @since 12 693 */ 694 Image_ErrorCode OH_PixelmapNative_ToSdr(OH_PixelmapNative *pixelmap); 695 696 /** 697 * @brief Obtains pixel map information of this image. 698 * 699 * @param pixelmap The Pixelmap pointer will be operated. 700 * @param imageInfo Indicates the pointer to the image information. 701 * @return Returns {@link Image_ErrorCode} 702 * @see OH_PixelmapNative OH_Pixelmap_ImageInfo 703 * @since 12 704 */ 705 Image_ErrorCode OH_PixelmapNative_GetImageInfo(OH_PixelmapNative *pixelmap, OH_Pixelmap_ImageInfo *imageInfo); 706 707 /** 708 * @brief Sets an opacity rate for this image pixel map. 709 * 710 * @param pixelmap The Pixelmap pointer will be operated. 711 * @param rate Opacity rate to set. The value ranges from 0 to 1. 712 * @return Returns {@link Image_ErrorCode} 713 * @see OH_PixelmapNative 714 * @since 12 715 */ 716 Image_ErrorCode OH_PixelmapNative_Opacity(OH_PixelmapNative *pixelmap, float rate); 717 718 /** 719 * @brief Scales this image based on the input width and height. 720 * 721 * @param pixelmap The Pixelmap pointer will be operated. 722 * @param scaleX Scaling ratio of the width. 723 * @param scaleY Scaling ratio of the height. 724 * @return Returns {@link Image_ErrorCode} 725 * @see OH_PixelmapNative 726 * @since 12 727 */ 728 Image_ErrorCode OH_PixelmapNative_Scale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY); 729 730 /** 731 * @brief Scales this image based on the input width and height with anti-aliasing. 732 * 733 * @param pixelmap The Pixelmap pointer will be operated. 734 * @param scaleX Scaling ratio of the width. 735 * @param scaleY Scaling ratio of the height. 736 * @param level The anti-aliasing algorithm to be used. 737 * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. 738 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, x and y are incorrect. 739 * returns {@link Image_ErrorCode} IMAGE_TOO_LARGE - if image is too large. 740 * returns {@link Image_ErrorCode} IMAGE_ALLOC_FAILED - if device has no memory. 741 * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error, maybe source pixelmap is released. 742 * @see OH_PixelmapNative 743 * @since 12 744 */ 745 Image_ErrorCode OH_PixelmapNative_ScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY, 746 OH_PixelmapNative_AntiAliasingLevel level); 747 748 /** 749 * @brief Translates this image based on the input coordinates. 750 * 751 * @param pixelmap The Pixelmap pointer will be operated. 752 * @param x The distance to be translate in the X direction. 753 * @param y The distance to be translate in the Y direction. 754 * @return Returns {@link Image_ErrorCode} 755 * @see OH_PixelmapNative 756 * @since 12 757 */ 758 Image_ErrorCode OH_PixelmapNative_Translate(OH_PixelmapNative *pixelmap, float x, float y); 759 760 /** 761 * @brief Rotates this image based on the input angle. 762 * 763 * @param pixelmap The Pixelmap pointer will be operated. 764 * @param angle Angle to rotate. 765 * @return Returns {@link Image_ErrorCode} 766 * @see OH_PixelmapNative 767 * @since 12 768 */ 769 Image_ErrorCode OH_PixelmapNative_Rotate(OH_PixelmapNative *pixelmap, float angle); 770 771 /** 772 * @brief Flips this image horizontally or vertically, or both. 773 * 774 * @param pixelmap The Pixelmap pointer will be operated. 775 * @param shouldFilpHorizontally Whether to flip the image horizontally. 776 * @param shouldFilpVertically Whether to flip the image vertically. 777 * @return Returns {@link Image_ErrorCode} 778 * @see OH_PixelmapNative 779 * @since 12 780 */ 781 Image_ErrorCode OH_PixelmapNative_Flip(OH_PixelmapNative *pixelmap, bool shouldFilpHorizontally, 782 bool shouldFilpVertically); 783 784 /** 785 * @brief Crops this image based on the input size. 786 * 787 * @param pixelmap The Pixelmap pointer will be operated. 788 * @param region Area size, read according to area. 789 * @return Returns {@link Image_ErrorCode} 790 * @see OH_PixelmapNative 791 * @since 12 792 */ 793 Image_ErrorCode OH_PixelmapNative_Crop(OH_PixelmapNative *pixelmap, Image_Region *region); 794 795 /** 796 * @brief Releases an <b>OH_PixelmapNative</b> object. 797 * 798 * @param pixelmap The Pixelmap pointer will be operated. 799 * @return Returns {@link Image_ErrorCode} 800 * @see OH_PixelmapNative 801 * @since 12 802 */ 803 Image_ErrorCode OH_PixelmapNative_Release(OH_PixelmapNative *pixelmap); 804 805 /** 806 * @brief Converting images to alpha format 807 * 808 * @param srcpixelmap The source pixel map pointer will be operated. 809 * @param dstpixelmap The destination pixel map pointer will be operated. 810 * @param isPremul Whether it is pre-multiplied, true for prediction, false for non-pre-multiplied. 811 * @return Returns {@link Image_ErrorCode} 812 * @since 12 813 */ 814 Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixelmap, 815 OH_PixelmapNative* dstpixelmap, const bool isPremul); 816 817 /** 818 * @brief Create a empty <b>PixelMap</b> object. 819 * 820 * @param options IPixel properties, including the alpha type, size, pixel format, and editable. 821 * @param pixelmap Pixelmap pointer for created. 822 * @return Returns {@link Image_ErrorCode} 823 * @since 12 824 */ 825 Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap(OH_Pixelmap_InitializationOptions *options, 826 OH_PixelmapNative **pixelmap); 827 828 /** 829 * @brief Convert the image format based on the input target pixel format. 830 * 831 * @param srcPixelMap Source Image PixelMap. 832 * @param destPixelMap Destination Image PixelMap. 833 * @param destPixelFormat Destination Image PixelFormat. 834 * @return Returns {@link Image_ErrorCode} IMAGE_RESULT_SUCCESS - if the operation is successful. 835 * @since 12 836 */ 837 Image_ErrorCode OH_PixelMapNative_ConvertPixelFormat(OH_PixelmapNative *srcPixelMap, OH_PixelmapNative **destPixelMap, 838 int32_t destPixelFormat); 839 840 /** 841 * @brief Get metadata. 842 * 843 * @param pixelmap The Pixelmap pointer to be operated. 844 * @param key Type of metadata. 845 * @param value Value of metadata. 846 * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. 847 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, key and value are incorrect. 848 * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory dose not exist. 849 * returns {@link Image_ErrorCode} IMAGE_COPY_FAILED - if memory copy failed. 850 * @see OH_PixelMapNative 851 * @since 12 852 */ 853 Image_ErrorCode OH_PixelmapNative_GetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, 854 OH_Pixelmap_HdrMetadataValue **value); 855 856 /** 857 * @brief Set metadata. 858 * 859 * @param pixelmap The Pixelmap pointer to be operated. 860 * @param key Type of metadata. 861 * @param value Value of metadata. 862 * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. 863 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, key and value are incorrect. 864 * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory dose not exist. 865 * returns {@link Image_ErrorCode} IMAGE_COPY_FAILED - if memory copy failed. 866 * @see OH_PixelMapNative 867 * @since 12 868 */ 869 Image_ErrorCode OH_PixelmapNative_SetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, 870 OH_Pixelmap_HdrMetadataValue *value); 871 872 /** 873 * @brief Get the native buffer from the PixelMap. 874 * 875 * @param pixelmap The PixelMap to get the native buffer from. 876 * @param nativeBuffer The native buffer to retrieve. 877 * @return Returns {@link Image_ErrorCode} IMAGE_RESULT_SUCCESS - if the operation is successful. 878 * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, pixelmap or nativeBuffer is null. 879 * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory dose not exist. 880 * returns {@link Image_ErrorCode} IMAGE_DMA_OPERATION_FAILED - if operations related to DMA memory has failed. 881 * @see OH_PixelmapNative 882 * @since 12 883 */ 884 Image_ErrorCode OH_PixelmapNative_GetNativeBuffer(OH_PixelmapNative *pixelmap, OH_NativeBuffer **nativeBuffer); 885 886 /** 887 * @brief Set pixelmap memory name. 888 * 889 * @param pixelmap The Pixelmap pointer to be operated. 890 * @param name The pointer of name that needs to be set. 891 * @param size The size of name size that needs to be set. 892 * @return Function result code: 893 * {@link IMAGE_SUCCESS} If the operation is successful. 894 * {@link IMAGE_BAD_PARAMETER} If invalid parameter, name and size are incorrect. 895 * {@link IMAGE_UNSUPPORTED_MEMORY_FORMAT} If memory format is unsupported. 896 * @see OH_PixelmapNative 897 * @since 13 898 */ 899 Image_ErrorCode OH_PixelmapNative_SetMemoryName(OH_PixelmapNative *pixelmap, char *name, size_t *size); 900 901 /** 902 * @brief Get the native colorspace from the PixelMap. 903 * 904 * @param pixelmap The native pixelmap to get the native colorspace from. 905 * @param colorSpaceNative The native colorspace to retrieve. 906 * @return Function result code: 907 * {@link IMAGE_SUCCESS} If the execution is successful. 908 * {@link IMAGE_BAD_PARAMETER} The param of pixelmap or colorSpaceNative is nullptr or invalid. 909 * @see OH_PixelmapNative 910 * @since 13 911 */ 912 Image_ErrorCode OH_PixelmapNative_GetColorSpaceNative(OH_PixelmapNative *pixelmap, 913 OH_NativeColorSpaceManager **colorSpaceNative); 914 915 /** 916 * @brief Set the native colorspace for the PixelMap. 917 * 918 * @param pixelmap The native pixelmap to set the native colorspace for. 919 * @param colorSpaceNative The native colorspace to set. 920 * @return Function result code: 921 * {@link IMAGE_SUCCESS} If the execution is successful. 922 * {@link IMAGE_BAD_PARAMETER} The param of pixelmap or colorSpaceNative is nullptr or invalid. 923 * @see OH_PixelmapNative 924 * @since 13 925 */ 926 Image_ErrorCode OH_PixelmapNative_SetColorSpaceNative(OH_PixelmapNative *pixelmap, 927 OH_NativeColorSpaceManager *colorSpaceNative); 928 929 #ifdef __cplusplus 930 }; 931 #endif 932 /** @} */ 933 #endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXELMAP_NATIVE_H 934