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