• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 #ifndef C_INCLUDE_DRAWING_TYPES_H
17 #define C_INCLUDE_DRAWING_TYPES_H
18 
19 /**
20  * @addtogroup Drawing
21  * @{
22  *
23  * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
24  *
25  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
26  *
27  * @since 8
28  * @version 1.0
29  */
30 
31 /**
32  * @file drawing_types.h
33  *
34  * @brief Declares the data types for drawing 2D graphics, including the canvas, brush, pen, bitmap, and path.
35  *
36  * @since 8
37  * @version 1.0
38  */
39 
40 #include <stdint.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Defines a rectangular canvas on which various shapes, images,
48  * and texts can be drawn by using the brush and pen.
49  *
50  * @since 8
51  * @version 1.0
52  */
53 typedef struct OH_Drawing_Canvas OH_Drawing_Canvas;
54 
55 /**
56  * @brief Defines a pen, which is used to describe the style and color to outline a shape.
57  *
58  * @since 8
59  * @version 1.0
60  */
61 typedef struct OH_Drawing_Pen OH_Drawing_Pen;
62 
63 /**
64  * @brief Defines as a brush, which is used to describe the style and color to fill in a shape.
65  *
66  * @since 8
67  * @version 1.0
68  */
69 typedef struct OH_Drawing_Brush OH_Drawing_Brush;
70 
71 /**
72  * @brief Defines a path, which is used to customize various shapes.
73  *
74  * @since 8
75  * @version 1.0
76  */
77 typedef struct OH_Drawing_Path OH_Drawing_Path;
78 
79 /**
80  * @brief Defines a bitmap, which is a memory that contains the pixel data of a shape.
81  *
82  * @since 8
83  * @version 1.0
84  */
85 typedef struct OH_Drawing_Bitmap OH_Drawing_Bitmap;
86 
87 /**
88  * @brief Enumerates storage formats of bitmap pixels.
89  *
90  * @since 8
91  * @version 1.0
92  */
93 typedef enum {
94     /** Unknown format. */
95     COLOR_FORMAT_UNKNOWN,
96     /** Each pixel is represented by 8 bits, which together indicate alpha. */
97     COLOR_FORMAT_ALPHA_8,
98     /**
99      * Each pixel is represented by 16 bits. From the most significant bit to the least significant bit,
100      * the first 5 bits indicate red, the subsequent 6 bits indicate green, and the last 5 bits indicate blue.
101      */
102     COLOR_FORMAT_RGB_565,
103     /**
104      * Each pixel is represented by 16 bits. From the most significant bit to the least significant bit,
105      * every 4 bits indicate alpha, red, green, and blue, respectively.
106      */
107     COLOR_FORMAT_ARGB_4444,
108     /**
109      * Each pixel is represented by 32 bits. From the most significant bit to the least significant bit,
110      * every 8 bits indicate alpha, red, green, and blue, respectively.
111      */
112     COLOR_FORMAT_RGBA_8888,
113     /**
114      * Each pixel is represented by 32 bits. From the most significant bit to the least significant bit,
115      * every 8 bits indicate blue, green, red, and alpha, respectively.
116      */
117     COLOR_FORMAT_BGRA_8888
118 } OH_Drawing_ColorFormat;
119 
120 /**
121  * @brief Enumerates alpha formats of bitmap pixels.
122  *
123  * @since 8
124  * @version 1.0
125  */
126 typedef enum {
127     /** Unknown format. */
128     ALPHA_FORMAT_UNKNOWN,
129     /** The bitmap does not have the alpha component. */
130     ALPHA_FORMAT_OPAQUE,
131     /** The color component of each pixel is premultiplied by the alpha component. */
132     ALPHA_FORMAT_PREMUL,
133     /** The color component of each pixel is not premultiplied by the alpha component. */
134     ALPHA_FORMAT_UNPREMUL
135 } OH_Drawing_AlphaFormat;
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 /** @} */
141 #endif
142