• 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 delete InitializationOtions pointer.
506  *
507  * @param options The InitializationOtions pointer will be operated.
508  * @return Returns {@link Image_ErrorCode}
509  * @since 12
510  */
511 Image_ErrorCode OH_PixelmapInitializationOptions_Release(OH_Pixelmap_InitializationOptions *options);
512 
513 /**
514  * @brief Defines the pixel map information.
515  *
516  * @since 12
517  */
518 struct OH_Pixelmap_ImageInfo;
519 typedef struct OH_Pixelmap_ImageInfo OH_Pixelmap_ImageInfo;
520 
521 /**
522  * @brief Create imageinfo struct  .
523  *
524  * @param info The imageinfo pointer will be operated.
525  * @return Returns {@link Image_ErrorCode}
526  * @since 12
527  */
528 Image_ErrorCode OH_PixelmapImageInfo_Create(OH_Pixelmap_ImageInfo **info);
529 
530 /**
531  * @brief Get width number for imageinfo struct.
532  *
533  * @param info The imageinfo pointer will be operated.
534  * @param width The number of imageinfo width.
535  * @return Returns {@link Image_ErrorCode}
536  * @since 12
537  */
538 Image_ErrorCode OH_PixelmapImageInfo_GetWidth(OH_Pixelmap_ImageInfo *info, uint32_t *width);
539 
540 /**
541  * @brief Get height number for imageinfo struct.
542  *
543  * @param info The imageinfo pointer will be operated.
544  * @param height The number of imageinfo height.
545  * @return Returns {@link Image_ErrorCode}
546  * @since 12
547  */
548 Image_ErrorCode OH_PixelmapImageInfo_GetHeight(OH_Pixelmap_ImageInfo *info, uint32_t *height);
549 
550 /**
551  * @brief Get rowStride number for imageinfo struct.
552  *
553  * @param info The imageinfo pointer will be operated.
554  * @param rowStride The number of imageinfo rowStride.
555  * @return Returns {@link Image_ErrorCode}
556  * @since 12
557  */
558 Image_ErrorCode OH_PixelmapImageInfo_GetRowStride(OH_Pixelmap_ImageInfo *info, uint32_t *rowStride);
559 
560 /**
561  * @brief Get pixelFormat number for imageinfo struct.
562  *
563  * @param info The imageinfo pointer will be operated.
564  * @param pixelFormat The number of imageinfo pixelFormat.
565  * @return Returns {@link Image_ErrorCode}
566  * @since 12
567  */
568 Image_ErrorCode OH_PixelmapImageInfo_GetPixelFormat(OH_Pixelmap_ImageInfo *info, int32_t *pixelFormat);
569 
570 /**
571  * @brief Get alphaType number for imageinfo struct.
572  *
573  * @param info The imageinfo pointer will be operated.
574  * @param alphaType The number of imageinfo alphaType.
575  * @return Returns {@link Image_ErrorCode}
576  * @since 12
577  */
578 Image_ErrorCode OH_PixelmapImageInfo_GetAlphaType(OH_Pixelmap_ImageInfo *info, int32_t *alphaType);
579 
580 /**
581  * @brief Get isHdr boolean for imageinfo struct.
582  *
583  * @param info The imageinfo pointer will be operated. Pointer connot be null.
584  * @param isHdr Whether the image has a high dynamic range.
585  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - The operation is successful.
586  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - Parameter error.Possible causes:Parameter verification failed.
587  * @since 12
588  */
589 Image_ErrorCode OH_PixelmapImageInfo_GetDynamicRange(OH_Pixelmap_ImageInfo *info, bool *isHdr);
590 
591 /**
592  * @brief Delete imageinfo struct pointer.
593  *
594  * @param info The imageinfo pointer will be operated.
595  * @return Returns {@link Image_ErrorCode}
596  * @since 12
597  */
598 Image_ErrorCode OH_PixelmapImageInfo_Release(OH_Pixelmap_ImageInfo *info);
599 
600 /**
601  * @brief Creates a <b>PixelMap</b> object.
602  *
603  * @param data Color buffer in BGRA_8888 format.
604  * @param dataLength Color buffer size in BGRA_8888 format.
605  * @param options IPixel properties, including the alpha type, size, pixel format, and editable.
606  * @param pixelmap Pixelmap pointer for created.
607  * @return Returns {@link Image_ErrorCode}
608  * @since 12
609  */
610 Image_ErrorCode OH_PixelmapNative_CreatePixelmap(uint8_t *data, size_t dataLength,
611     OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap);
612 
613 /**
614  * @brief Convert a native <b>PixelMap</b> object to <b>PixelMap</b> napi object.
615  *
616  * @param env Indicates the NAPI environment pointer.
617  * @param pixelmapNative Indicates a pointer to the <b>PixelMap</b> object created at the native layer.
618  * @param pixelmapNapi the <b>PixelMap</b> pointer will be converted.
619  * @return Image functions result code.
620  *     {@link IMAGE_SUCCESS} if the execution is successful.
621  *     {@link IMAGE_BAD_PARAMETER} pixelmapNative is nullptr
622  * @since 12
623  */
624 Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeToNapi(napi_env env, OH_PixelmapNative *pixelmapNative,
625     napi_value *pixelmapNapi);
626 
627 /**
628  * @brief Convert a <b>PixelMap</b> napi object to native <b>PixelMap</b> object.
629  *
630  * @param env Indicates the NAPI environment pointer.
631  * @param pixelmapNapi Indicates napi <b>PixelMap</b> object.
632  * @param pixelmapNative Indicates native <b>PixelMap</b> pointer to created.
633  * @return Image functions result code.
634  *     {@link IMAGE_SUCCESS} if the execution is successful.
635  *     {@link IMAGE_BAD_PARAMETER} pixelmapNative is nullptr, or pixelmapNapi is not a PixelMap
636  * @since 12
637  */
638 Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeFromNapi(napi_env env, napi_value pixelmapNapi,
639     OH_PixelmapNative **pixelmapNative);
640 
641 /**
642  * @brief Reads data of this pixel map to an Buffer. If this pixel map is created in the BGRA_8888 format,
643  * the data read is the same as the original data.
644  *
645  * @param pixelmap The Pixelmap pointer will be operated.
646  * @param destination Buffer to which the image pixel map data will be written.
647  * @param bufferSize Buffer size to which the image pixel map data will be written.
648  * @return Returns {@link Image_ErrorCode}
649  * @since 12
650  */
651 Image_ErrorCode OH_PixelmapNative_ReadPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize);
652 
653 /**
654  * @brief Reads image data in an Buffer and writes the data to a Pixelmap object.
655  *
656  * @param pixelmap The Pixelmap pointer will be operated.
657  * @param source Buffer from which the image data will be read.
658  * @param bufferSize Buffer size from which the image data will be read.
659  * @return Returns {@link Image_ErrorCode}
660  * @since 12
661  */
662 Image_ErrorCode OH_PixelmapNative_WritePixels(OH_PixelmapNative *pixelmap, uint8_t *source, size_t bufferSize);
663 
664 /**
665  * @brief Get argb pixel buffer from pixelmap.
666  *
667  * @param pixelmap The Pixelmap pointer to be operated.
668  * @param destination Buffer to which the image pixel map data will be written.
669  * @param bufferSize Buffer size to which the image pixel map data will be written.
670  * @return Function result code:
671  *         {@link IMAGE_SUCCESS} If the operation is successful.
672  *         {@link IMAGE_BAD_PARAMETER} If invalid parameter, destination and bufferSize are incorrect.
673  *         {@link IMAGE_UNSUPPORTED_CONVERSION} If format does not support conversion to argb or conversion failed.
674  *         {@link IMAGE_ALLOC_FAILED} If device has no memory.
675  *         {@link IMAGE_COPY_FAILED} If memory copy failed.
676  * @see OH_PixelmapNative
677  * @since 13
678  */
679 Image_ErrorCode OH_PixelmapNative_GetArgbPixels(OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize);
680 
681 /**
682  * @brief Convert {@link OH_PixelmapNative} to standard dynamic range.
683  *
684  * @param pixelmap The Pixelmap pointer will be operated. Pointer connot be null.
685  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - The operation is successful.
686  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - Parameter error.Possible causes:Parameter verification failed.
687  * returns {@link Image_ErrorCode} IMAGE_UNSUPPORTED_OPERATION - Unsupported operation.Pixelmap can't be converted.
688  * @since 12
689  */
690 Image_ErrorCode OH_PixelmapNative_ToSdr(OH_PixelmapNative *pixelmap);
691 
692 /**
693  * @brief Obtains pixel map information of this image.
694  *
695  * @param pixelmap The Pixelmap pointer will be operated.
696  * @param imageInfo Indicates the pointer to the image information.
697  * @return Returns {@link Image_ErrorCode}
698  * @since 12
699  */
700 Image_ErrorCode OH_PixelmapNative_GetImageInfo(OH_PixelmapNative *pixelmap, OH_Pixelmap_ImageInfo *imageInfo);
701 
702 /**
703  * @brief Sets an opacity rate for this image pixel map.
704  *
705  * @param pixelmap The Pixelmap pointer will be operated.
706  * @param rate Opacity rate to set. The value ranges from 0 to 1.
707  * @return Returns {@link Image_ErrorCode}
708  * @since 12
709  */
710 Image_ErrorCode OH_PixelmapNative_Opacity(OH_PixelmapNative *pixelmap, float rate);
711 
712 /**
713  * @brief Scales this image based on the input width and height.
714  *
715  * @param pixelmap The Pixelmap pointer will be operated.
716  * @param scaleX Scaling ratio of the width.
717  * @param scaleY Scaling ratio of the height.
718  * @return Returns {@link Image_ErrorCode}
719  * @since 12
720  */
721 Image_ErrorCode OH_PixelmapNative_Scale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY);
722 
723 /**
724  * @brief Scales this image based on the input width and height with anti-aliasing.
725  *
726  * @param pixelmap The Pixelmap pointer will be operated.
727  * @param scaleX Scaling ratio of the width.
728  * @param scaleY Scaling ratio of the height.
729  * @param level The anti-aliasing algorithm to be used.
730  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
731  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, x and y are incorrect.
732  * returns {@link Image_ErrorCode} IMAGE_TOO_LARGE - if image is too large.
733  * returns {@link Image_ErrorCode} IMAGE_ALLOC_FAILED - if device has no memory.
734  * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error, maybe source pixelmap is released.
735  * @see OH_PixelmapNative
736  * @since 12
737  */
738 Image_ErrorCode OH_PixelmapNative_ScaleWithAntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY,
739     OH_PixelmapNative_AntiAliasingLevel level);
740 
741 /**
742  * @brief Translates this image based on the input coordinates.
743  *
744  * @param pixelmap The Pixelmap pointer will be operated.
745  * @param x The distance to be translate in the X direction.
746  * @param y The distance to be translate in the Y direction.
747  * @return Returns {@link Image_ErrorCode}
748  * @since 12
749  */
750 Image_ErrorCode OH_PixelmapNative_Translate(OH_PixelmapNative *pixelmap, float x, float y);
751 
752 /**
753  * @brief Rotates this image based on the input angle.
754  *
755  * @param pixelmap The Pixelmap pointer will be operated.
756  * @param angle Angle to rotate.
757  * @return Returns {@link Image_ErrorCode}
758  * @since 12
759  */
760 Image_ErrorCode OH_PixelmapNative_Rotate(OH_PixelmapNative *pixelmap, float angle);
761 
762 /**
763  * @brief Flips this image horizontally or vertically, or both.
764  *
765  * @param pixelmap The Pixelmap pointer will be operated.
766  * @param shouldFilpHorizontally Whether to flip the image horizontally.
767  * @param shouldFilpVertically Whether to flip the image vertically.
768  * @return Returns {@link Image_ErrorCode}
769  * @since 12
770  */
771 Image_ErrorCode OH_PixelmapNative_Flip(OH_PixelmapNative *pixelmap, bool shouldFilpHorizontally, bool shouldFilpVertically);
772 
773 /**
774  * @brief Crops this image based on the input size.
775  *
776  * @param pixelmap The Pixelmap pointer will be operated.
777  * @param region Area size, read according to area.
778  * @return Returns {@link Image_ErrorCode}
779  * @since 12
780  */
781 Image_ErrorCode OH_PixelmapNative_Crop(OH_PixelmapNative *pixelmap, Image_Region *region);
782 
783 /**
784  * @brief Releases an <b>OH_Pixelmap</b> object.
785  *
786  * @param pixelmap The Pixelmap pointer will be operated.
787  * @return Returns {@link Image_ErrorCode}
788  * @since 12
789  */
790 Image_ErrorCode OH_PixelmapNative_Release(OH_PixelmapNative *pixelmap);
791 
792 /**
793  * @brief Converting images to alpha format
794  *
795  * @param srcpixelmap The source pixel map pointer will be operated.
796  * @param dstpixelmap The destination pixel map pointer will be operated.
797  * @param isPremul Whether it is pre-multiplied, true for prediction, false for non-pre-multiplied.
798  * @return Returns {@link Image_ErrorCode}
799  * @since 12
800  */
801 Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixelmap,
802     OH_PixelmapNative* dstpixelmap, const bool isPremul);
803 
804 /**
805  * @brief Create a empty <b>PixelMap</b> object.
806  *
807  * @param options IPixel properties, including the alpha type, size, pixel format, and editable.
808  * @param pixelmap Pixelmap pointer for created.
809  * @return Returns {@link Image_ErrorCode}
810  * @since 12
811  */
812 Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap(
813     OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap);
814 
815 /**
816  * @brief Get metadata.
817  *
818  * @param pixelmap The Pixelmap pointer to be operated.
819  * @param key Type of metadata.
820  * @param value Value of metadata.
821  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
822  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, key and value are incorrect.
823  * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory does not exist.
824  * returns {@link Image_ErrorCode} IMAGE_COPY_FAILED - if memory copy failed.
825  * @see OH_PixelmapNative
826  * @since 12
827  */
828 Image_ErrorCode OH_PixelmapNative_GetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key,
829     OH_Pixelmap_HdrMetadataValue **value);
830 
831 /**
832  * @brief Set metadata.
833  *
834  * @param pixelmap The Pixelmap pointer to be operated.
835  * @param key Type of metadata.
836  * @param value Value of metadata.
837  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
838  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, key and value are incorrect.
839  * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory does not exist.
840  * returns {@link Image_ErrorCode} IMAGE_COPY_FAILED - if memory copy failed.
841  * @see OH_PixelmapNative
842  * @since 12
843  */
844 Image_ErrorCode OH_PixelmapNative_SetMetadata(OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key,
845     OH_Pixelmap_HdrMetadataValue *value);
846 
847 /**
848  * @brief Get the native buffer from the PixelMap.
849  *
850  * @param pixelmap The PixelMap to get the native buffer from.
851  * @param nativeBuffer The native buffer to retrieve.
852  * @return Returns {@link Image_ErrorCode} IMAGE_RESULT_SUCCESS - if the operation is successful.
853  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter, pixelmap or nativeBuffer is null.
854  * returns {@link Image_ErrorCode} IMAGE_DMA_NOT_EXIST - if DMA memory dose not exist.
855  * returns {@link Image_ErrorCode} IMAGE_DMA_OPERATION_FAILED - if operations related to DMA memory has failed.
856  * @see OH_PixelmapNative
857  * @since 12
858  */
859 Image_ErrorCode OH_PixelmapNative_GetNativeBuffer(OH_PixelmapNative *pixelmap, OH_NativeBuffer **nativeBuffer);
860 
861 /**
862  * @brief Get the native colorspace from the PixelMap.
863  *
864  * @param pixelmap The native pixelmap to get the native colorspace from.
865  * @param colorSpaceNative The native colorspace to retrieve.
866  * @return Function result code:
867  *         {@link IMAGE_SUCCESS} If the execution is successful.
868  *         {@link IMAGE_BAD_PARAMETER} The param of pixelmap or colorSpaceNative is nullptr or invalid.
869  * @see OH_PixelmapNative
870  * @since 13
871  */
872 Image_ErrorCode OH_PixelmapNative_GetColorSpaceNative(OH_PixelmapNative *pixelmap,
873     OH_NativeColorSpaceManager **colorSpaceNative);
874 
875 /**
876  * @brief Set the native colorspace for the PixelMap.
877  *
878  * @param pixelmap The native pixelmap to set the native colorspace for.
879  * @param colorSpaceNative The native colorspace to set.
880  * @return Function result code:
881  *         {@link IMAGE_SUCCESS} If the execution is successful.
882  *         {@link IMAGE_BAD_PARAMETER} The param of pixelmap or colorSpaceNative is nullptr or invalid.
883  * @see OH_PixelmapNative
884  * @since 13
885  */
886 Image_ErrorCode OH_PixelmapNative_SetColorSpaceNative(OH_PixelmapNative *pixelmap,
887     OH_NativeColorSpaceManager *colorSpaceNative);
888 
889 /**
890  * @brief Set pixelmap memory name.
891  *
892  * @param pixelmap The Pixelmap pointer to be operated.
893  * @param name The pointer of name that needs to be set.
894  * @param size The size of name size that needs to be set.
895  * @return Function result code:
896  *         {@link IMAGE_SUCCESS} If the operation is successful.
897  *         {@link IMAGE_BAD_PARAMETER} If invalid parameter, name and size are incorrect.
898  *         {@link IMAGE_UNSUPPORTED_MEMORY_FORMAT} If memory format is unsupported.
899  * @see OH_PixelmapNative
900  * @since 13
901  */
902 Image_ErrorCode OH_PixelmapNative_SetMemoryName(OH_PixelmapNative *pixelmap, char *name, size_t *size);
903 
904 #ifdef __cplusplus
905 };
906 #endif
907 /** @} */
908 #endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXELMAP_NATIVE_H_
909