• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 alphaMode number for imageinfo struct.
576  *
577  * @param info The imageinfo pointer will be operated.
578  * @param alphaMode The number of imageinfo alphaMode.
579  * @return Image functions result code.
580  *     {@link IMAGE_SUCCESS} if the execution is successful.
581  *     {@link IMAGE_BAD_PARAMETER} info is nullptr, or alphaMode is nullptr.
582  * @since 20
583  */
584 Image_ErrorCode OH_PixelmapImageInfo_GetAlphaMode(OH_Pixelmap_ImageInfo *info, int32_t *alphaMode);
585 
586 /**
587  * @brief Get rowStride number for imageinfo struct.
588  *
589  * @param info The imageinfo pointer will be operated.
590  * @param rowStride The number of imageinfo rowStride.
591  * @return Returns {@link Image_ErrorCode}
592  * @since 12
593  */
594 Image_ErrorCode OH_PixelmapImageInfo_GetRowStride(OH_Pixelmap_ImageInfo *info, uint32_t *rowStride);
595 
596 /**
597  * @brief Get pixelFormat number for imageinfo struct.
598  *
599  * @param info The imageinfo pointer will be operated.
600  * @param pixelFormat The number of imageinfo pixelFormat.
601  * @return Returns {@link Image_ErrorCode}
602  * @since 12
603  */
604 Image_ErrorCode OH_PixelmapImageInfo_GetPixelFormat(OH_Pixelmap_ImageInfo *info, int32_t *pixelFormat);
605 
606 /**
607  * @brief Get alphaType number for imageinfo struct.
608  *
609  * @param info The imageinfo pointer will be operated.
610  * @param alphaType The number of imageinfo alphaType.
611  * @return Returns {@link Image_ErrorCode}
612  * @since 12
613  */
614 Image_ErrorCode OH_PixelmapImageInfo_GetAlphaType(OH_Pixelmap_ImageInfo *info, int32_t *alphaType);
615 
616 /**
617  * @brief Get isHdr boolean for imageinfo struct.
618  *
619  * @param info The imageinfo pointer will be operated. Pointer connot be null.
620  * @param isHdr Whether the image has a high dynamic range.
621  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - The operation is successful.
622  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - Parameter error.Possible causes:Parameter verification failed.
623  * @since 12
624  */
625 Image_ErrorCode OH_PixelmapImageInfo_GetDynamicRange(OH_Pixelmap_ImageInfo *info, bool *isHdr);
626 
627 /**
628  * @brief Delete imageinfo struct pointer.
629  *
630  * @param info The imageinfo pointer will be operated.
631  * @return Returns {@link Image_ErrorCode}
632  * @since 12
633  */
634 Image_ErrorCode OH_PixelmapImageInfo_Release(OH_Pixelmap_ImageInfo *info);
635 
636 /**
637  * @brief Creates a <b>PixelMap</b> object.
638  *
639  * @param data Color buffer in BGRA_8888 format.
640  * @param dataLength Color buffer size in BGRA_8888 format.
641  * @param options IPixel properties, including the alpha type, size, pixel format, and editable.
642  * @param pixelmap Pixelmap pointer for created.
643  * @return Returns {@link Image_ErrorCode}
644  * @since 12
645  */
646 Image_ErrorCode OH_PixelmapNative_CreatePixelmap(uint8_t *data, size_t dataLength,
647     OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap);
648 
649 /**
650  * @brief Creates a pixelmap based on options {@link OH_Pixelmap_InitializationOptions}, the memory type used by the
651  * pixelmap can be specified by allocatorType {@link IMAGE_ALLOCATOR_MODE}. By default, the system selects the memory
652  * type based on the image type, image size, platform capability, etc. When processing the pixelmap returned by this
653  * interface, please always consider the impact of stride.
654  *
655  * @param data Input color buffer in BGRA_8888 format by default.
656  * @param dataLength Length of input buffer in bytes.
657  * @param options Pixelmap initialization properties including size, pixel format, alpha type, and editable flags.
658  * @param allocator Indicate which memory type will be used by the returned pixelmap.
659  * @param pixelmap Output parameter receiving the created pixelmap object pointer.
660  * @return Function result code:
661  *         {@link IMAGE_SUCCESS} If the operation is successful.
662  *         {@link IMAGE_BAD_PARAMETER} If the param is nullptr or invalid.
663  *         {@link IMAGE_TOO_LARGE} too large data or image.
664  *         {@link IMAGE_UNSUPPORTED_OPERATION} unsupported operations.
665  *         {@link IMAGE_DMA_OPERATION_FAILED} DMA operation failed.
666  *         {@link IMAGE_ALLOCATOR_MODE_UNSUPPORTED} unsupported allocator mode, e.g.,
667  *         use share memory to create a HDR image as only DMA supported hdr metadata.
668  * @since 20
669  */
670 Image_ErrorCode OH_PixelmapNative_CreatePixelmapUsingAllocator(uint8_t *data, size_t dataLength,
671     OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap);
672 
673 /**
674  * @brief Convert a native <b>PixelMap</b> object to <b>PixelMap</b> napi object.
675  *
676  * @param env Indicates the NAPI environment pointer.
677  * @param pixelmapNative Indicates a pointer to the <b>PixelMap</b> object created at the native layer.
678  * @param pixelmapNapi the <b>PixelMap</b> pointer will be converted.
679  * @return Image functions result code.
680  *     {@link IMAGE_SUCCESS} if the execution is successful.
681  *     {@link IMAGE_BAD_PARAMETER} pixelmapNative is nullptr
682  * @since 12
683  */
684 Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeToNapi(napi_env env, OH_PixelmapNative *pixelmapNative,
685     napi_value *pixelmapNapi);
686 
687 /**
688  * @brief Convert a <b>PixelMap</b> napi object to native <b>PixelMap</b> object.
689  *
690  * @param env Indicates the NAPI environment pointer.
691  * @param pixelmapNapi Indicates napi <b>PixelMap</b> object.
692  * @param pixelmapNative Indicates native <b>PixelMap</b> pointer to created.
693  * @return Image functions result code.
694  *     {@link IMAGE_SUCCESS} if the execution is successful.
695  *     {@link IMAGE_BAD_PARAMETER} pixelmapNative is nullptr, or pixelmapNapi is not a PixelMap
696  * @since 12
697  */
698 Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeFromNapi(napi_env env, napi_value pixelmapNapi,
699     OH_PixelmapNative **pixelmapNative);
700 
701 /**
702  * @brief Reads data of this pixel map to an Buffer. If this pixel map is created in the BGRA_8888 format,
703  * the data read is the same as the original data.
704  *
705  * @param pixelmap The Pixelmap pointer will be operated.
706  * @param destination Buffer to which the image pixel map data will be written.
707  * @param bufferSize Buffer size to which the image pixel map data will be written.
708  * @return Returns {@link Image_ErrorCode}
709  * @since 12
710  */
711 Image_ErrorCode OH_PixelmapNative_ReadPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize);
712 
713 /**
714  * @brief Reads image data in an Buffer and writes the data to a Pixelmap object.
715  *
716  * @param pixelmap The Pixelmap pointer will be operated.
717  * @param source Buffer from which the image data will be read.
718  * @param bufferSize Buffer size from which the image data will be read.
719  * @return Returns {@link Image_ErrorCode}
720  * @since 12
721  */
722 Image_ErrorCode OH_PixelmapNative_WritePixels(OH_PixelmapNative *pixelmap, uint8_t *source, size_t bufferSize);
723 
724 /**
725  * @brief Get argb pixel buffer from pixelmap.
726  *
727  * @param pixelmap The Pixelmap pointer to be operated.
728  * @param destination Buffer to which the image pixel map data will be written.
729  * @param bufferSize Buffer size to which the image pixel map data will be written.
730  * @return Function result code:
731  *         {@link IMAGE_SUCCESS} If the operation is successful.
732  *         {@link IMAGE_BAD_PARAMETER} If invalid parameter, destination and bufferSize are incorrect.
733  *         {@link IMAGE_UNSUPPORTED_CONVERSION} If format does not support conversion to argb or conversion failed.
734  *         {@link IMAGE_ALLOC_FAILED} If device has no memory.
735  *         {@link IMAGE_COPY_FAILED} If memory copy failed.
736  * @see OH_PixelmapNative
737  * @since 13
738  */
739 Image_ErrorCode OH_PixelmapNative_GetArgbPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize);
740 
741 /**
742  * @brief Convert {@link OH_PixelmapNative} to standard dynamic range.
743  *
744  * @param pixelmap The Pixelmap pointer will be operated. Pointer connot be null.
745  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - The operation is successful.
746  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - Parameter error.Possible causes:Parameter verification failed.
747  * returns {@link Image_ErrorCode} IMAGE_UNSUPPORTED_OPERATION - Unsupported operation.Pixelmap can't be converted.
748  * @since 12
749  */
750 Image_ErrorCode OH_PixelmapNative_ToSdr(OH_PixelmapNative *pixelmap);
751 
752 /**
753  * @brief Obtains pixel map information of this image.
754  *
755  * @param pixelmap The Pixelmap pointer will be operated.
756  * @param imageInfo Indicates the pointer to the image information.
757  * @return Returns {@link Image_ErrorCode}
758  * @since 12
759  */
760 Image_ErrorCode OH_PixelmapNative_GetImageInfo(OH_PixelmapNative *pixelmap, OH_Pixelmap_ImageInfo *imageInfo);
761 
762 /**
763  * @brief Sets an opacity rate for this image pixel map.
764  *
765  * @param pixelmap The Pixelmap pointer will be operated.
766  * @param rate Opacity rate to set. The value ranges from 0 to 1.
767  * @return Returns {@link Image_ErrorCode}
768  * @since 12
769  */
770 Image_ErrorCode OH_PixelmapNative_Opacity(OH_PixelmapNative *pixelmap, float rate);
771 
772 /**
773  * @brief Scales this image based on the input width and height.
774  *
775  * @param pixelmap The Pixelmap pointer will be operated.
776  * @param scaleX Scaling ratio of the width.
777  * @param scaleY Scaling ratio of the height.
778  * @return Returns {@link Image_ErrorCode}
779  * @since 12
780  */
781 Image_ErrorCode OH_PixelmapNative_Scale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY);
782 
783 /**
784  * @brief Scales this image based on the input width and height with anti-aliasing.
785  *
786  * @param pixelmap The Pixelmap pointer will be operated.
787  * @param scaleX Scaling ratio of the width.
788  * @param scaleY Scaling ratio of the height.
789  * @param level The anti-aliasing algorithm to be used.
790  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
791  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, x and y are incorrect.
792  * returns {@link Image_ErrorCode} IMAGE_TOO_LARGE - if image is too large.
793  * returns {@link Image_ErrorCode} IMAGE_ALLOC_FAILED - if device has no memory.
794  * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error, maybe source pixelmap is released.
795  * @see OH_PixelmapNative
796  * @since 12
797  */
798 Image_ErrorCode OH_PixelmapNative_ScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY,
799     OH_PixelmapNative_AntiAliasingLevel level);
800 
801 /**
802  * @brief Create a scaled pixelmap based on the source pixelmap and the input width and height.
803  *
804  * @param srcPixelmap The source native pixelmap.
805  * @param dstPixelmap The destination native pixelmap for create.
806  * @param scaleX Scaling ratio of the width.
807  * @param scaleY Scaling ratio of the height.
808  * @return Function result code:
809  *         {@link IMAGE_SUCCESS} If the execution is successful.
810  *         {@link IMAGE_BAD_PARAMETER} If the param is nullptr or invalid.
811  * @see OH_PixelmapNative
812  * @since 18
813  */
814 Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMap(OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap,
815     float scaleX, float scaleY);
816 
817 /**
818  * @brief Create a scaled pixelmap based on the source pixelmap and the input width and height with anti-aliasing.
819  *
820  * @param srcPixelmap The source native pixelmap.
821  * @param dstPixelmap The destination native pixelmap for create.
822  * @param scaleX Scaling ratio of the width.
823  * @param scaleY Scaling ratio of the height.
824  * @param level The anti-aliasing algorithm to be used.
825  * @return Function result code:
826  *         {@link IMAGE_SUCCESS} If the execution is successful.
827  *         {@link IMAGE_BAD_PARAMETER} If the param is nullptr or invalid.
828  *         {@link IMAGE_TOO_LARGE} If image is too large.
829  *         {@link IMAGE_ALLOC_FAILED} If device has no memory.
830  * @see OH_PixelmapNative
831  * @since 18
832  */
833 Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMapWithAntiAliasing(OH_PixelmapNative *srcPixelmap,
834     OH_PixelmapNative **dstPixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level);
835 
836 /**
837  * @brief Translates this image based on the input coordinates.
838  *
839  * @param pixelmap The Pixelmap pointer will be operated.
840  * @param x The distance to be translate in the X direction.
841  * @param y The distance to be translate in the Y direction.
842  * @return Returns {@link Image_ErrorCode}
843  * @since 12
844  */
845 Image_ErrorCode OH_PixelmapNative_Translate(OH_PixelmapNative *pixelmap, float x, float y);
846 
847 /**
848  * @brief Rotates this image based on the input angle.
849  *
850  * @param pixelmap The Pixelmap pointer will be operated.
851  * @param angle Angle to rotate.
852  * @return Returns {@link Image_ErrorCode}
853  * @since 12
854  */
855 Image_ErrorCode OH_PixelmapNative_Rotate(OH_PixelmapNative *pixelmap, float angle);
856 
857 /**
858  * @brief Flips this image horizontally or vertically, or both.
859  *
860  * @param pixelmap The Pixelmap pointer will be operated.
861  * @param shouldFilpHorizontally Whether to flip the image horizontally.
862  * @param shouldFilpVertically Whether to flip the image vertically.
863  * @return Returns {@link Image_ErrorCode}
864  * @since 12
865  */
866 Image_ErrorCode OH_PixelmapNative_Flip(OH_PixelmapNative *pixelmap, bool shouldFilpHorizontally, bool shouldFilpVertically);
867 
868 /**
869  * @brief Crops this image based on the input size.
870  *
871  * @param pixelmap The Pixelmap pointer will be operated.
872  * @param region Area size, read according to area.
873  * @return Returns {@link Image_ErrorCode}
874  * @since 12
875  */
876 Image_ErrorCode OH_PixelmapNative_Crop(OH_PixelmapNative *pixelmap, Image_Region *region);
877 
878 /**
879  * @brief Releases an <b>OH_Pixelmap</b> object.
880  *
881  * @param pixelmap The Pixelmap pointer will be operated.
882  * @return Returns {@link Image_ErrorCode}
883  * @since 12
884  */
885 Image_ErrorCode OH_PixelmapNative_Release(OH_PixelmapNative *pixelmap);
886 
887 /**
888  * @brief Destroys an <b>OH_PixelmapNative</b> object and deallocates its resources.
889  *
890  * @param pixelmap A pointer to the OH_PixelmapNative pointer to destroy.
891  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
892  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if pixelmap is null or *pixelmap is null.
893  * @since 18
894  */
895 Image_ErrorCode OH_PixelmapNative_Destroy(OH_PixelmapNative **pixelmap);
896 
897 /**
898  * @brief Converting images to alpha format
899  *
900  * @param srcpixelmap The source pixel map pointer will be operated.
901  * @param dstpixelmap The destination pixel map pointer will be operated.
902  * @param isPremul Whether it is pre-multiplied, true for prediction, false for non-pre-multiplied.
903  * @return Returns {@link Image_ErrorCode}
904  * @since 12
905  */
906 Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixelmap,
907     OH_PixelmapNative* dstpixelmap, const bool isPremul);
908 
909 /**
910  * @brief Create a empty <b>PixelMap</b> object.
911  *
912  * @param options IPixel properties, including the alpha type, size, pixel format, and editable.
913  * @param pixelmap Pixelmap pointer for created.
914  * @return Returns {@link Image_ErrorCode}
915  * @since 12
916  */
917 Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap(
918     OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap);
919 
920 /**
921  * @brief Creates a empty pixelmap based on options {@link OH_Pixelmap_InitializationOptions}, the memory type used by the
922  * pixelmap can be specified by allocatorType {@link IMAGE_ALLOCATOR_MODE}. By default, the system selects the memory
923  * type based on the image type, image size, platform capability, etc. When processing the pixelmap returned by this
924  * interface, please always consider the impact of stride.
925  *
926  * @param options Pixelmap initialization properties including size, pixel format, alpha type, and editable flags.
927  * @param allocator Indicate which memory type will be used by the returned pixelmap.
928  * @param pixelmap Output parameter receiving the created pixelmap object pointer.
929  * @return Function result code:
930  *         {@link IMAGE_SUCCESS} If the operation is successful.
931  *         {@link IMAGE_BAD_PARAMETER} If the param is nullptr or invalid.
932  *         {@link IMAGE_TOO_LARGE} too large data or image.
933  *         {@link IMAGE_UNSUPPORTED_OPERATION} unsupported operations.
934  *         {@link IMAGE_ALLOCATOR_MODE_UNSUPPORTED} unsupported allocator mode, e.g., use
935  *         share memory to create a HDR image as only DMA supported hdr metadata.
936  * @since 20
937  */
938 Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmapUsingAllocator(
939     OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap);
940 
941 /**
942  * @brief Get metadata.
943  *
944  * @param pixelmap The Pixelmap pointer to be operated.
945  * @param key Type of metadata.
946  * @param value Value of metadata.
947  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
948  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, key and value are incorrect.
949  * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory does not exist.
950  * returns {@link Image_ErrorCode} IMAGE_COPY_FAILED - if memory copy failed.
951  * @see OH_PixelmapNative
952  * @since 12
953  */
954 Image_ErrorCode OH_PixelmapNative_GetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key,
955     OH_Pixelmap_HdrMetadataValue **value);
956 
957 /**
958  * @brief Set metadata.
959  *
960  * @param pixelmap The Pixelmap pointer to be operated.
961  * @param key Type of metadata.
962  * @param value Value of metadata.
963  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
964  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, key and value are incorrect.
965  * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory does not exist.
966  * returns {@link Image_ErrorCode} IMAGE_COPY_FAILED - if memory copy failed.
967  * @see OH_PixelmapNative
968  * @since 12
969  */
970 Image_ErrorCode OH_PixelmapNative_SetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key,
971     OH_Pixelmap_HdrMetadataValue *value);
972 
973 /**
974  * @brief Get the native buffer from the PixelMap.
975  *
976  * @param pixelmap The PixelMap to get the native buffer from.
977  * @param nativeBuffer The native buffer to retrieve.
978  * @return Returns {@link Image_ErrorCode} IMAGE_RESULT_SUCCESS - if the operation is successful.
979  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, pixelmap or nativeBuffer is null.
980  * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory dose not exist.
981  * returns {@link Image_ErrorCode} IMAGE_DMA_OPERATION_FAILED - if operations related to DMA memory has failed.
982  * @see OH_PixelmapNative
983  * @since 12
984  */
985 Image_ErrorCode OH_PixelmapNative_GetNativeBuffer(OH_PixelmapNative *pixelmap, OH_NativeBuffer **nativeBuffer);
986 
987 /**
988  * @brief Get the native colorspace from the PixelMap.
989  *
990  * @param pixelmap The native pixelmap to get the native colorspace from.
991  * @param colorSpaceNative The native colorspace to retrieve.
992  * @return Function result code:
993  *         {@link IMAGE_SUCCESS} If the execution is successful.
994  *         {@link IMAGE_BAD_PARAMETER} The param of pixelmap or colorSpaceNative is nullptr or invalid.
995  * @see OH_PixelmapNative
996  * @since 13
997  */
998 Image_ErrorCode OH_PixelmapNative_GetColorSpaceNative(OH_PixelmapNative *pixelmap,
999     OH_NativeColorSpaceManager **colorSpaceNative);
1000 
1001 /**
1002  * @brief Set the native colorspace for the PixelMap.
1003  *
1004  * @param pixelmap The native pixelmap to set the native colorspace for.
1005  * @param colorSpaceNative The native colorspace to set.
1006  * @return Function result code:
1007  *         {@link IMAGE_SUCCESS} If the execution is successful.
1008  *         {@link IMAGE_BAD_PARAMETER} The param of pixelmap or colorSpaceNative is nullptr or invalid.
1009  * @see OH_PixelmapNative
1010  * @since 13
1011  */
1012 Image_ErrorCode OH_PixelmapNative_SetColorSpaceNative(OH_PixelmapNative *pixelmap,
1013     OH_NativeColorSpaceManager *colorSpaceNative);
1014 
1015 /**
1016  * @brief Set pixelmap memory name.
1017  *
1018  * @param pixelmap The Pixelmap pointer to be operated.
1019  * @param name The pointer of name that needs to be set.
1020  * @param size The size of name size that needs to be set.
1021  * @return Function result code:
1022  *         {@link IMAGE_SUCCESS} If the operation is successful.
1023  *         {@link IMAGE_BAD_PARAMETER} If invalid parameter, name and size are incorrect.
1024  *         {@link IMAGE_UNSUPPORTED_MEMORY_FORMAT} If memory format is unsupported.
1025  * @see OH_PixelmapNative
1026  * @since 13
1027  */
1028 Image_ErrorCode OH_PixelmapNative_SetMemoryName(OH_PixelmapNative *pixelmap, char *name, size_t *size);
1029 
1030 /**
1031  * @brief Get the total number of bytes occupied by all pixels in the Pixelmap, without any padding.
1032  *
1033  * @param pixelmap The Pixelmap pointer to be operated.
1034  * @param byteCount The total number of bytes to be retrieved.
1035  * @return Function result code:
1036  *         {@link IMAGE_SUCCESS} If the operation is successful.
1037  *         {@link IMAGE_BAD_PARAMETER} If invalid parameter, pixelmap or byteCount are invalid.
1038  * @see OH_PixelmapNative
1039  * @since 18
1040  */
1041 Image_ErrorCode OH_PixelmapNative_GetByteCount(OH_PixelmapNative *pixelmap, uint32_t *byteCount);
1042 
1043 /**
1044  * @brief Get the size of the allocated memory used to store this pixelmap's pixels.
1045  *
1046  * @param pixelmap The Pixelmap pointer to be operated.
1047  * @param allocationByteCount The size of the allocated memory.
1048  * @return Function result code:
1049  *         {@link IMAGE_SUCCESS} If the operation is successful.
1050  *         {@link IMAGE_BAD_PARAMETER} If invalid parameter, pixelmap or allocationByteCount are invalid.
1051  * @see OH_PixelmapNative
1052  * @since 18
1053  */
1054 Image_ErrorCode OH_PixelmapNative_GetAllocationByteCount(OH_PixelmapNative *pixelmap, uint32_t *allocationByteCount);
1055 
1056 /**
1057  * @brief Obtains the memory address of a PixelMap and locks the memory.
1058  *        When the memory is locked, any operation that modifies or releases the PixelMap will fail and return
1059  *        {@link IMAGE_BAD_PARAMETER}.
1060  *
1061  * @param pixelmap The PixelMap pointer to be operated.
1062  * @param addr The double pointer to the memory address of the PixelMap.
1063  * @return Function result code:
1064  *         {@link IMAGE_SUCCESS} If the operation is successful.
1065  *         {@link IMAGE_BAD_PARAMETER} If invalid parameter, pixelmap or addr are invalid.
1066  *         {@link IMAGE_LOCK_UNLOCK_FAILED} If memory failed to be locked.
1067  * @see OH_PixelmapNative
1068  * @since 15
1069  */
1070 Image_ErrorCode OH_PixelmapNative_AccessPixels(OH_PixelmapNative *pixelmap, void **addr);
1071 
1072 /**
1073  * @brief Unlocks the memory of the PixelMap data.
1074  *        This function is used with {@link OH_PixelmapNative_AccessPixels} in pairs.
1075  *
1076  * @param pixelmap The PixelMap pointer to be operated.
1077  * @return Function result code:
1078  *         {@link IMAGE_SUCCESS} If the operation is successful.
1079  *         {@link IMAGE_BAD_PARAMETER} If invalid parameter, pixelmap is invalid.
1080  *         {@link IMAGE_LOCK_UNLOCK_FAILED} If memory failed to be unlocked.
1081  * @see OH_PixelmapNative
1082  * @since 15
1083  */
1084 Image_ErrorCode OH_PixelmapNative_UnaccessPixels(OH_PixelmapNative *pixelmap);
1085 
1086 #ifdef __cplusplus
1087 };
1088 #endif
1089 /** @} */
1090 #endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXELMAP_NATIVE_H_
1091