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