1# EffectKit
2
3
4## Overview
5
6The EffectKit module provides the basic image processing capabilities, including brightness adjustment, blurring, and grayscale adjustment.
7
8**Since**: 12
9
10
11## Summary
12
13
14### File
15
16| Name| Description|
17| -------- | -------- |
18| [effect_filter.h](effect__filter_8h.md) | Declares the APIs of an image effect filter.|
19| [effect_types.h](effect__types_8h.md) | Declares the data types of the image effect filter.|
20
21
22### Structs
23
24| Name| Description|
25| -------- | -------- |
26| struct  [OH_Filter](_o_h___filter.md) | Describes a filter used to generate a filter pixel map.|
27| struct  [OH_Filter_ColorMatrix](_o_h___filter___color_matrix.md) | Describes a matrix used to create an effect filter.|
28
29
30### Types
31
32| Name| Description|
33| -------- | -------- |
34| typedef struct [OH_Filter](_o_h___filter.md)  [pixelMap](#pixelmap) | Defines a struct for a filter used to generate a filter pixel map.|
35| typedef enum [EffectErrorCode](#effecterrorcode)  [EffectErrorCode](#effecterrorcode) | Defines an enum for the status codes that may be used by the effect filter.|
36
37
38### Enums
39
40| Name| Description|
41| -------- | -------- |
42| [EffectErrorCode](#effecterrorcode) { EFFECT_SUCCESS = 0, EFFECT_BAD_PARAMETER = 401, EFFECT_UNSUPPORTED_OPERATION = 7600201, EFFECT_UNKNOWN_ERROR = 7600901 } | Enumerates the status codes that may be used by the effect filter.|
43| [EffectTileMode](#effecttilemode) { CLAMP = 0, REPEAT, MIRROR, DECAL } | Enumerates the tile modes of the shader effect.|
44
45### Functions
46
47| Name| Description|
48| -------- | -------- |
49| [EffectErrorCode](#effecterrorcode) [OH_Filter_CreateEffect](#oh_filter_createeffect) (OH_PixelmapNative \*pixelmap, [OH_Filter](_o_h___filter.md) \*\*filter) | Creates an **OH_Filter** object.|
50| [EffectErrorCode](#effecterrorcode) [OH_Filter_Release](#oh_filter_release) ([OH_Filter](_o_h___filter.md) \*filter) | Releases an **OH_Filter** object.|
51| [EffectErrorCode](#effecterrorcode) [OH_Filter_Blur](#oh_filter_blur) ([OH_Filter](_o_h___filter.md) \*filter, float radius) | Creates the frosted glass effect and adds it to a filter.|
52| [EffectErrorCode](#effecterrorcode) [OH_Filter_BlurWithTileMode](#oh_filter_blurwithtilemode) ([OH_Filter](_o_h___filter.md) \*filter, float radius, [EffectTileMode](#effecttilemode) tileMode) | Creates the frosted glass effect and adds it to a filter.|
53| [EffectErrorCode](#effecterrorcode) [OH_Filter_Brighten](#oh_filter_brighten) ([OH_Filter](_o_h___filter.md) \*filter, float brightness) | Creates the brightening effect and adds it to a filter.|
54| [EffectErrorCode](#effecterrorcode) [OH_Filter_GrayScale](#oh_filter_grayscale) ([OH_Filter](_o_h___filter.md) \*filter) | Creates the grayscale effect and adds it to a filter.|
55| [EffectErrorCode](#effecterrorcode) [OH_Filter_Invert](#oh_filter_invert) ([OH_Filter](_o_h___filter.md) \*filter) | Creates the inverted color effect and adds it to a filter.|
56| [EffectErrorCode](#effecterrorcode) [OH_Filter_SetColorMatrix](#oh_filter_setcolormatrix) ([OH_Filter](_o_h___filter.md) \*filter, [OH_Filter_ColorMatrix](_o_h___filter___color_matrix.md) \*matrix) | Creates a custom effect through a matrix and adds it to a filter.|
57| [EffectErrorCode](#effecterrorcode) [OH_Filter_GetEffectPixelMap](#oh_filter_geteffectpixelmap) ([OH_Filter](_o_h___filter.md) \*filter, OH_PixelmapNative \*\*pixelmap) | Obtains the pixel map used to create a filter.|
58
59
60## Type Description
61
62
63### EffectErrorCode
64
65```
66typedef enum EffectErrorCode EffectErrorCode
67```
68
69**Description**
70
71Defines an enum for the status codes that may be used by the effect filter.
72
73**Since**: 12
74
75
76### pixelMap
77
78```
79typedef struct OH_Filter pixelMap
80```
81
82**Description**
83
84Defines a struct for a filter used to generate a filter pixel map.
85
86**Since**: 12
87
88
89## Enum Description
90
91
92### EffectErrorCode
93
94```
95enum EffectErrorCode
96```
97
98**Description**
99
100Enumerates the status codes that may be used by the effect filter.
101
102**Since**: 12
103
104| Value| Description|
105| -------- | -------- |
106| EFFECT_SUCCESS | Operation successful.|
107| EFFECT_BAD_PARAMETER | Invalid parameter.|
108| EFFECT_UNSUPPORTED_OPERATION | Unsupported operation.|
109| EFFECT_UNKNOWN_ERROR | Unknown error.|
110
111
112### EffectTileMode
113
114```
115enum EffectTileMode
116```
117
118**Description**
119
120Enumerates the tile modes of the shader effect.
121
122**Since**: 14
123
124| Value| Description|
125| -------- | -------- |
126| CLAMP | Replicates the edge color if the shader effect draws outside of its original boundary.|
127| REPEAT | Repeats the shader effect in both horizontal and vertical directions.|
128| MIRROR | Repeats the shader effect in both horizontal and vertical directions, alternating mirror images.|
129| DECAL | Renders the shader effect only within the original boundary.|
130
131## Function Description
132
133
134### OH_Filter_Blur()
135
136```
137EffectErrorCode OH_Filter_Blur (OH_Filter* filter, float radius )
138```
139
140**Description**
141
142Creates the frosted glass effect and adds it to a filter.
143
144**Since**: 12
145
146**Parameters**
147
148| Name| Description|
149| -------- | -------- |
150| filter | Pointer to the filter.|
151| radius | Blur radius of the frosted glass effect, in px.|
152
153**Returns**
154
155Returns a status code defined in [EffectErrorCode](#effecterrorcode).
156
157
158### OH_Filter_BlurWithTileMode()
159
160```
161EffectErrorCode OH_Filter_BlurWithTileMode (OH_Filter* filter, float radius, EffectTileMode tileMode )
162```
163
164**Description**
165
166Creates the frosted glass effect and adds it to a filter.
167
168**Since**: 14
169
170**Parameters**
171
172| Name| Description|
173| -------- | -------- |
174| filter | Pointer to the filter.|
175| radius | Blur radius of the frosted glass effect, in px.|
176| tileMode | Tile mode of the shader effect. For details about the available options, see [EffectTileMode](#effecttilemode).|
177
178**Returns**
179
180Returns a status code defined in [EffectErrorCode](#effecterrorcode).
181
182### OH_Filter_Brighten()
183
184```
185EffectErrorCode OH_Filter_Brighten (OH_Filter* filter, float brightness )
186```
187
188**Description**
189
190Creates the brightening effect and adds it to a filter.
191
192**Since**: 12
193
194**Parameters**
195
196| Name| Description|
197| -------- | -------- |
198| filter | Pointer to the filter.|
199| brightness | Luminance of the brightening effect. The value ranges from 0 to 1. When the value is **0**, the image remains unchanged.|
200
201**Returns**
202
203Returns a status code defined in [EffectErrorCode](#effecterrorcode).
204
205
206### OH_Filter_CreateEffect()
207
208```
209EffectErrorCode OH_Filter_CreateEffect (OH_PixelmapNative* pixelmap, OH_Filter** filter )
210```
211
212**Description**
213
214Creates an **OH_Filter** object.
215
216**Since**: 12
217
218**Parameters**
219
220| Name| Description|
221| -------- | -------- |
222| pixelmap | Pointer to the pixel map.|
223| filter | Double pointer to the filter created.|
224
225**Returns**
226
227Returns a status code defined in [EffectErrorCode](#effecterrorcode).
228
229
230### OH_Filter_GetEffectPixelMap()
231
232```
233EffectErrorCode OH_Filter_GetEffectPixelMap (OH_Filter* filter, OH_PixelmapNative** pixelmap )
234```
235
236**Description**
237
238Obtains the pixel map used to create a filter.
239
240**Since**: 12
241
242**Parameters**
243
244| Name| Description|
245| -------- | -------- |
246| filter | Pointer to the filter.|
247| pixelmap | Double pointer to the pixel map obtained.|
248
249**Returns**
250
251Returns a status code defined in [EffectErrorCode](#effecterrorcode).
252
253
254### OH_Filter_GrayScale()
255
256```
257EffectErrorCode OH_Filter_GrayScale (OH_Filter* filter)
258```
259
260**Description**
261
262Creates the grayscale effect and adds it to a filter.
263
264**Since**: 12
265
266**Parameters**
267
268| Name| Description|
269| -------- | -------- |
270| filter | Pointer to the filter.|
271
272**Returns**
273
274Returns a status code defined in [EffectErrorCode](#effecterrorcode).
275
276
277### OH_Filter_Invert()
278
279```
280EffectErrorCode OH_Filter_Invert (OH_Filter* filter)
281```
282
283**Description**
284
285Creates the inverted color effect and adds it to a filter.
286
287**Since**: 12
288
289**Parameters**
290
291| Name| Description|
292| -------- | -------- |
293| filter | Pointer to the filter.|
294
295**Returns**
296
297Returns a status code defined in [EffectErrorCode](#effecterrorcode).
298
299
300### OH_Filter_Release()
301
302```
303EffectErrorCode OH_Filter_Release (OH_Filter* filter)
304```
305
306**Description**
307
308Releases an **OH_Filter** object.
309
310**Since**: 12
311
312**Parameters**
313
314| Name| Description|
315| -------- | -------- |
316| filter | Pointer to the filter.|
317
318**Returns**
319
320Returns a status code defined in [EffectErrorCode](#effecterrorcode).
321
322
323### OH_Filter_SetColorMatrix()
324
325```
326EffectErrorCode OH_Filter_SetColorMatrix (OH_Filter* filter, OH_Filter_ColorMatrix* matrix )
327```
328
329**Description**
330
331Creates a custom effect through a matrix and adds it to a filter.
332
333**Since**: 12
334
335**Parameters**
336
337| Name| Description|
338| -------- | -------- |
339| filter | Pointer to the filter.|
340| matrix | Pointer to a custom matrix, which is an [OH_Filter_ColorMatrix](_o_h___filter___color_matrix.md) object.|
341
342**Returns**
343
344Returns a status code defined in [EffectErrorCode](#effecterrorcode).
345