• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# drawing_brush.h
2
3<!--Kit: ArkGraphics 2D-->
4<!--Subsystem: Graphic-->
5<!--Owner: @hangmengxin-->
6<!--Designer: @wangyanglan-->
7<!--Tester: @nobuggers-->
8<!--Adviser: @ge-yafang-->
9
10## 概述
11
12文件中定义了与画刷相关的功能函数。
13
14<!--RP1-->
15**相关示例:** [NDKAPIDrawing (API14)](https://gitcode.com/openharmony/applications_app_samples/tree/master/code/DocsSample/Drawing/NDKAPIDrawing)<!--RP1End-->
16
17**引用文件:** <native_drawing/drawing_brush.h>
18
19**库:** libnative_drawing.so
20
21**起始版本:** 8
22
23**相关模块:** [Drawing](capi-drawing.md)
24
25## 汇总
26
27### 结构体
28
29| 名称 | typedef关键字 | 描述 |
30| -- | -- | -- |
31| [OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md) | OH_NativeColorSpaceManager | 声明色域管理对象,提供获取色域基础属性的能力。 |
32
33### 函数
34
35| 名称 | 描述 |
36| -- | -- |
37| [OH_Drawing_Brush* OH_Drawing_BrushCreate(void)](#oh_drawing_brushcreate) | 用于创建一个画刷对象。 |
38| [OH_Drawing_Brush* OH_Drawing_BrushCopy(OH_Drawing_Brush* brush)](#oh_drawing_brushcopy) | 创建一个画刷对象副本[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md),用于拷贝一个已有画刷对象。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
39| [void OH_Drawing_BrushDestroy(OH_Drawing_Brush* brush)](#oh_drawing_brushdestroy) | 用于销毁画刷对象并回收该对象占有的内存。 |
40| [bool OH_Drawing_BrushIsAntiAlias(const OH_Drawing_Brush* brush)](#oh_drawing_brushisantialias) | 用于获取画刷是否设置抗锯齿属性,如果为真则说明画刷会启用抗锯齿功能,在绘制图形时会对图形的边缘像素进行半透明的模糊处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
41| [void OH_Drawing_BrushSetAntiAlias(OH_Drawing_Brush* brush, bool antiAlias)](#oh_drawing_brushsetantialias) | 用于设置画刷的抗锯齿属性,设置为真则画刷在绘制图形时会对图形的边缘像素进行半透明的模糊处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
42| [uint32_t OH_Drawing_BrushGetColor(const OH_Drawing_Brush* brush)](#oh_drawing_brushgetcolor) | 用于获取画刷的颜色属性,颜色属性描述了画刷填充图形时使用的颜色,用一个32位(ARGB)的变量表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
43| [void OH_Drawing_BrushSetColor(OH_Drawing_Brush* brush, uint32_t color)](#oh_drawing_brushsetcolor) | 用于设置画刷的颜色属性,颜色属性描述了画刷填充图形时使用的颜色,用一个32位(ARGB)的变量表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
44| [uint8_t OH_Drawing_BrushGetAlpha(const OH_Drawing_Brush* brush)](#oh_drawing_brushgetalpha) | 获取画刷的透明度值。画刷在填充形状时透明通道会使用该值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
45| [void OH_Drawing_BrushSetAlpha(OH_Drawing_Brush* brush, uint8_t alpha)](#oh_drawing_brushsetalpha) | 为画刷设置透明度值。画刷在填充形状时透明通道会使用该值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
46| [void OH_Drawing_BrushSetShaderEffect(OH_Drawing_Brush* brush, OH_Drawing_ShaderEffect* shaderEffect)](#oh_drawing_brushsetshadereffect) | 为画刷设置着色器效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
47| [void OH_Drawing_BrushSetShadowLayer(OH_Drawing_Brush* brush, OH_Drawing_ShadowLayer* shadowLayer)](#oh_drawing_brushsetshadowlayer) | 为画刷设置阴影层,设置的阴影层效果当前仅在绘制文字时生效。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
48| [void OH_Drawing_BrushSetFilter(OH_Drawing_Brush* brush, OH_Drawing_Filter* filter)](#oh_drawing_brushsetfilter) | 为画刷设置滤波器[OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)。滤波器是一个容器,可以承载蒙版滤波器和颜色滤波器。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
49| [void OH_Drawing_BrushGetFilter(OH_Drawing_Brush* brush, OH_Drawing_Filter* filter)](#oh_drawing_brushgetfilter) | 从画刷获取滤波器[OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)。滤波器是一个容器,可以承载蒙版滤波器和颜色滤波器。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush、filter任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
50| [void OH_Drawing_BrushSetBlendMode(OH_Drawing_Brush* brush, OH_Drawing_BlendMode blendMode)](#oh_drawing_brushsetblendmode) | 为画刷设置一个混合器,该混合器实现了指定的混合模式枚举。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>blendMode不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。 |
51| [void OH_Drawing_BrushReset(OH_Drawing_Brush* brush)](#oh_drawing_brushreset) | 将画刷重置至初始状态,清空所有已设置的属性。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 |
52| [OH_Drawing_ErrorCode OH_Drawing_BrushSetColor4f(OH_Drawing_Brush* brush, float a, float r, float g, float b,OH_NativeColorSpaceManager* colorSpaceManager)](#oh_drawing_brushsetcolor4f) | 设置画刷的颜色。颜色将被画刷用来填充形状。<br> 颜色采用浮点数表示的ARGB格式,色彩空间由[OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md)指定。<br> 如果colorSpaceManager为nullptr,使用SRGB(基于IEC 61966-2.1:1999的标准红绿蓝色彩空间)色彩空间作为默认值。 |
53| [OH_Drawing_ErrorCode OH_Drawing_BrushGetAlphaFloat(const OH_Drawing_Brush* brush, float* a)](#oh_drawing_brushgetalphafloat) | 获取画刷颜色的透明度值。 |
54| [OH_Drawing_ErrorCode OH_Drawing_BrushGetRedFloat(const OH_Drawing_Brush* brush, float* r)](#oh_drawing_brushgetredfloat) | 获取画刷颜色的红色分量。 |
55| [OH_Drawing_ErrorCode OH_Drawing_BrushGetGreenFloat(const OH_Drawing_Brush* brush, float* g)](#oh_drawing_brushgetgreenfloat) | 获取画刷颜色的绿色分量。 |
56| [OH_Drawing_ErrorCode OH_Drawing_BrushGetBlueFloat(const OH_Drawing_Brush* brush, float* b)](#oh_drawing_brushgetbluefloat) | 获取画刷颜色的蓝色分量。 |
57
58## 函数说明
59
60### OH_Drawing_BrushCreate()
61
62```
63OH_Drawing_Brush* OH_Drawing_BrushCreate(void)
64```
65
66**描述**
67
68用于创建一个画刷对象。
69
70**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
71
72**起始版本:** 8
73
74**返回:**
75
76| 类型 | 说明 |
77| -- | -- |
78| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* | 函数会返回一个指针,指针指向创建的画刷对象。 |
79
80### OH_Drawing_BrushCopy()
81
82```
83OH_Drawing_Brush* OH_Drawing_BrushCopy(OH_Drawing_Brush* brush)
84```
85
86**描述**
87
88创建一个画刷对象副本[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md),用于拷贝一个已有画刷对象。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
89
90**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
91
92**起始版本:** 12
93
94
95**参数:**
96
97| 参数项 | 描述 |
98| -- | -- |
99| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
100
101**返回:**
102
103| 类型 | 说明 |
104| -- | -- |
105| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* | 函数会返回一个指针,指针指向创建的画刷对象副本[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)。如果对象返回NULL,表示创建失败;可能的原因是可用内存为空,或者是brush为NULL。 |
106
107### OH_Drawing_BrushDestroy()
108
109```
110void OH_Drawing_BrushDestroy(OH_Drawing_Brush* brush)
111```
112
113**描述**
114
115用于销毁画刷对象并回收该对象占有的内存。
116
117**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
118
119**起始版本:** 8
120
121
122**参数:**
123
124| 参数项 | 描述 |
125| -- | -- |
126| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
127
128### OH_Drawing_BrushIsAntiAlias()
129
130```
131bool OH_Drawing_BrushIsAntiAlias(const OH_Drawing_Brush* brush)
132```
133
134**描述**
135
136用于获取画刷是否设置抗锯齿属性,如果为真则说明画刷会启用抗锯齿功能,在绘制图形时会对图形的边缘像素进行半透明的模糊处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
137
138**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
139
140**起始版本:** 8
141
142
143**参数:**
144
145| 参数项 | 描述 |
146| -- | -- |
147| const [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
148
149**返回:**
150
151| 类型 | 说明 |
152| -- | -- |
153| bool | 函数返回画刷对象是否设置抗锯齿属性,返回真则设置了抗锯齿,返回假则没有设置抗锯齿。 |
154
155### OH_Drawing_BrushSetAntiAlias()
156
157```
158void OH_Drawing_BrushSetAntiAlias(OH_Drawing_Brush* brush, bool antiAlias)
159```
160
161**描述**
162
163用于设置画刷的抗锯齿属性,设置为真则画刷在绘制图形时会对图形的边缘像素进行半透明的模糊处理。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
164
165**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
166
167**起始版本:** 8
168
169
170**参数:**
171
172| 参数项 | 描述 |
173| -- | -- |
174| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
175| bool antiAlias | 真为抗锯齿,假则不做抗锯齿处理。 |
176
177### OH_Drawing_BrushGetColor()
178
179```
180uint32_t OH_Drawing_BrushGetColor(const OH_Drawing_Brush* brush)
181```
182
183**描述**
184
185用于获取画刷的颜色属性,颜色属性描述了画刷填充图形时使用的颜色,用一个32位(ARGB)的变量表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
186
187**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
188
189**起始版本:** 8
190
191
192**参数:**
193
194| 参数项 | 描述 |
195| -- | -- |
196| const [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
197
198**返回:**
199
200| 类型 | 说明 |
201| -- | -- |
202| uint32_t | 函数返回一个描述颜色的32位(ARGB)变量。 |
203
204### OH_Drawing_BrushSetColor()
205
206```
207void OH_Drawing_BrushSetColor(OH_Drawing_Brush* brush, uint32_t color)
208```
209
210**描述**
211
212用于设置画刷的颜色属性,颜色属性描述了画刷填充图形时使用的颜色,用一个32位(ARGB)的变量表示。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
213
214**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
215
216**起始版本:** 8
217
218
219**参数:**
220
221| 参数项 | 描述 |
222| -- | -- |
223| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
224| uint32_t color | 描述颜色的32位(ARGB)变量。 |
225
226### OH_Drawing_BrushGetAlpha()
227
228```
229uint8_t OH_Drawing_BrushGetAlpha(const OH_Drawing_Brush* brush)
230```
231
232**描述**
233
234获取画刷的透明度值。画刷在填充形状时透明通道会使用该值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
235
236**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
237
238**起始版本:** 11
239
240
241**参数:**
242
243| 参数项 | 描述 |
244| -- | -- |
245| const [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 表示指向画刷对象的指针。 |
246
247**返回:**
248
249| 类型 | 说明 |
250| -- | -- |
251| uint8_t | 返回一个8位变量,用于表示透明度值。 |
252
253### OH_Drawing_BrushSetAlpha()
254
255```
256void OH_Drawing_BrushSetAlpha(OH_Drawing_Brush* brush, uint8_t alpha)
257```
258
259**描述**
260
261为画刷设置透明度值。画刷在填充形状时透明通道会使用该值。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
262
263**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
264
265**起始版本:** 11
266
267
268**参数:**
269
270| 参数项 | 描述 |
271| -- | -- |
272| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
273| uint8_t alpha | 表示要设置的透明度值,是一个8位变量。 |
274
275### OH_Drawing_BrushSetShaderEffect()
276
277```
278void OH_Drawing_BrushSetShaderEffect(OH_Drawing_Brush* brush, OH_Drawing_ShaderEffect* shaderEffect)
279```
280
281**描述**
282
283为画刷设置着色器效果。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
284
285**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
286
287**起始版本:** 11
288
289
290**参数:**
291
292| 参数项 | 描述 |
293| -- | -- |
294| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
295| [OH_Drawing_ShaderEffect](capi-drawing-oh-drawing-shadereffect.md)* shaderEffect | 表示指向着色器对象的指针,为NULL表示清空画刷的着色器效果。 |
296
297### OH_Drawing_BrushSetShadowLayer()
298
299```
300void OH_Drawing_BrushSetShadowLayer(OH_Drawing_Brush* brush, OH_Drawing_ShadowLayer* shadowLayer)
301```
302
303**描述**
304
305为画刷设置阴影层,设置的阴影层效果当前仅在绘制文字时生效。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
306
307**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
308
309**起始版本:** 12
310
311
312**参数:**
313
314| 参数项 | 描述 |
315| -- | -- |
316| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
317| [OH_Drawing_ShadowLayer](capi-drawing-oh-drawing-shadowlayer.md)* shadowLayer | 表示指向阴影层的指针,为NULL表示清空画刷的阴影层效果。 |
318
319### OH_Drawing_BrushSetFilter()
320
321```
322void OH_Drawing_BrushSetFilter(OH_Drawing_Brush* brush, OH_Drawing_Filter* filter)
323```
324
325**描述**
326
327为画刷设置滤波器[OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)。滤波器是一个容器,可以承载蒙版滤波器和颜色滤波器。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
328
329**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
330
331**起始版本:** 11
332
333
334**参数:**
335
336| 参数项 | 描述 |
337| -- | -- |
338| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象的指针。 |
339| [OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)* filter | 表示指向滤波器对象的指针,为NULL表示清空画刷滤波器。 |
340
341### OH_Drawing_BrushGetFilter()
342
343```
344void OH_Drawing_BrushGetFilter(OH_Drawing_Brush* brush, OH_Drawing_Filter* filter)
345```
346
347**描述**
348
349从画刷获取滤波器[OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)。滤波器是一个容器,可以承载蒙版滤波器和颜色滤波器。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush、filter任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
350
351**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
352
353**起始版本:** 12
354
355
356**参数:**
357
358| 参数项 | 描述 |
359| -- | -- |
360| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)的指针。 |
361| [OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)* filter | 表示指向滤波器对象[OH_Drawing_Filter](capi-drawing-oh-drawing-filter.md)的指针。 |
362
363### OH_Drawing_BrushSetBlendMode()
364
365```
366void OH_Drawing_BrushSetBlendMode(OH_Drawing_Brush* brush, OH_Drawing_BlendMode blendMode)
367```
368
369**描述**
370
371为画刷设置一个混合器,该混合器实现了指定的混合模式枚举。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER;<br>blendMode不在枚举范围内时返回OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE。
372
373**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
374
375**起始版本:** 12
376
377
378**参数:**
379
380| 参数项 | 描述 |
381| -- | -- |
382| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)的指针。 |
383| [OH_Drawing_BlendMode](capi-drawing-types-h.md#oh_drawing_blendmode) blendMode | 混合模式枚举类型[OH_Drawing_BlendMode](capi-drawing-types-h.md#oh_drawing_blendmode)。 |
384
385### OH_Drawing_BrushReset()
386
387```
388void OH_Drawing_BrushReset(OH_Drawing_Brush* brush)
389```
390
391**描述**
392
393将画刷重置至初始状态,清空所有已设置的属性。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>brush为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。
394
395**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
396
397**起始版本:** 12
398
399
400**参数:**
401
402| 参数项 | 描述 |
403| -- | -- |
404| [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 指向画刷对象[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)的指针。 |
405
406
407### OH_Drawing_BrushSetColor4f()
408
409```
410OH_Drawing_ErrorCode OH_Drawing_BrushSetColor4f(OH_Drawing_Brush* brush, float a, float r, float g, float b,OH_NativeColorSpaceManager* colorSpaceManager)
411```
412
413**描述**
414
415设置画刷的颜色。颜色将被画刷用来填充形状。<br> 颜色采用浮点数表示的ARGB格式,色彩空间由[OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md)指定。<br> 如果colorSpaceManager为nullptr,使用SRGB(基于IEC 61966-2.1:1999的标准红绿蓝色彩空间)色彩空间作为默认值。
416
417**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
418
419**起始版本:** 20
420
421**参数:**
422
423| 参数项 | 描述 |
424| -- | -- |
425| OH_Drawing_Brush* brush | 表示指向[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)对象的指针。 |
426| float a | 表示颜色中的透明度值,用0.0 ~ 1.0之间的浮点数表示,大于1.0时,取1.0,小于0.0时,取0.0。 |
427| float r | 表示颜色中的红色分量,用0.0 ~ 1.0之间的浮点数表示,大于1.0时,取1.0,小于0.0时,取0.0。 |
428| float g | 表示颜色中的绿色分量,用0.0 ~ 1.0之间的浮点数表示,大于1.0时,取1.0,小于0.0时,取0.0。 |
429| float b | 表示颜色中的蓝色分量,用0.0 ~ 1.0之间的浮点数表示,大于1.0时,取1.0,小于0.0时,取0.0。 |
430| [OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md)* colorSpaceManager | 表示指向[OH_NativeColorSpaceManager](capi-nativecolorspacemanager-oh-nativecolorspacemanager.md)对象的指针。 |
431
432**返回:**
433
434| 类型 | 说明 |
435| -- | -- |
436| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数brush为NULL。 |
437
438### OH_Drawing_BrushGetAlphaFloat()
439
440```
441OH_Drawing_ErrorCode OH_Drawing_BrushGetAlphaFloat(const OH_Drawing_Brush* brush, float* a)
442```
443
444**描述**
445
446获取画刷颜色的透明度值。
447
448**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
449
450**起始版本:** 20
451
452**参数:**
453
454| 参数项 | 描述 |
455| -- | -- |
456| const [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 表示指向[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)对象的指针。 |
457| float* a | 表示颜色的透明度,范围为0.0 ~ 1.0的浮点数。 |
458
459**返回:**
460
461| 类型 | 说明 |
462| -- | -- |
463| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数brush或a为NULL。 |
464
465### OH_Drawing_BrushGetRedFloat()
466
467```
468OH_Drawing_ErrorCode OH_Drawing_BrushGetRedFloat(const OH_Drawing_Brush* brush, float* r)
469```
470
471**描述**
472
473获取画刷颜色的红色分量。
474
475**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
476
477**起始版本:** 20
478
479**参数:**
480
481| 参数项 | 描述 |
482| -- | -- |
483| const [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 表示指向[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)对象的指针。 |
484| float* r | 表示颜色中的红色分量,范围为0.0 ~ 1.0的浮点数。 |
485
486**返回:**
487
488| 类型 | 说明 |
489| -- | -- |
490| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数brush或r为NULL。 |
491
492### OH_Drawing_BrushGetGreenFloat()
493
494```
495OH_Drawing_ErrorCode OH_Drawing_BrushGetGreenFloat(const OH_Drawing_Brush* brush, float* g)
496```
497
498**描述**
499
500获取画刷颜色的绿色分量。
501
502**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
503
504**起始版本:** 20
505
506**参数:**
507
508| 参数项 | 描述 |
509| -- | -- |
510| const [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 表示指向[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)对象的指针。 |
511| float* g | 表示颜色中的绿色分量,范围为0.0 ~ 1.0的浮点数。 |
512
513**返回:**
514
515| 类型 | 说明 |
516| -- | -- |
517| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数brush或g为NULL。 |
518
519### OH_Drawing_BrushGetBlueFloat()
520
521```
522OH_Drawing_ErrorCode OH_Drawing_BrushGetBlueFloat(const OH_Drawing_Brush* brush, float* b)
523```
524
525**描述**
526
527获取画刷颜色的蓝色分量。
528
529**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing
530
531**起始版本:** 20
532
533**参数:**
534
535| 参数项 | 描述 |
536| -- | -- |
537| const [OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)* brush | 表示指向[OH_Drawing_Brush](capi-drawing-oh-drawing-brush.md)对象的指针。 |
538| float* b | 表示颜色中的蓝色分量,范围为0.0 ~ 1.0的浮点数。 |
539
540**返回:**
541
542| 类型 | 说明 |
543| -- | -- |
544| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行结果。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数brush或b为NULL。 |