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### Files 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 134## Function Description 135 136 137### OH_Filter_Blur() 138 139``` 140EffectErrorCode OH_Filter_Blur (OH_Filter* filter, float radius ) 141``` 142 143**Description** 144 145Creates the frosted glass effect and adds it to a filter. 146 147**Since**: 12 148 149**Parameters** 150 151| Name| Description| 152| -------- | -------- | 153| filter | Pointer to the filter.| 154| radius | Blur radius of the frosted glass effect, in px.| 155 156**Returns** 157 158Returns a status code defined in [EffectErrorCode](#effecterrorcode). 159 160 161### OH_Filter_BlurWithTileMode() 162 163``` 164EffectErrorCode OH_Filter_BlurWithTileMode (OH_Filter* filter, float radius, EffectTileMode tileMode ) 165``` 166 167**Description** 168 169Creates the frosted glass effect and adds it to a filter. 170 171**Since**: 14 172 173**Parameters** 174 175| Name| Description| 176| -------- | -------- | 177| filter | Pointer to the filter.| 178| radius | Blur radius of the frosted glass effect, in px.| 179| tileMode | Tile mode of the shader effect. For details about the available options, see [EffectTileMode](#effecttilemode).| 180 181**Returns** 182 183Returns a status code defined in [EffectErrorCode](#effecterrorcode). 184 185If the operation is successful, **EFFECT_SUCCESS** is returned. 186 187If a parameter is invalid, **EFFECT_BAD_PARAMETER** is returned. 188 189 190### OH_Filter_Brighten() 191 192``` 193EffectErrorCode OH_Filter_Brighten (OH_Filter* filter, float brightness ) 194``` 195 196**Description** 197 198Creates the brightening effect and adds it to a filter. 199 200**Since**: 12 201 202**Parameters** 203 204| Name| Description| 205| -------- | -------- | 206| filter | Pointer to the filter.| 207| brightness | Luminance of the brightening effect. The value ranges from 0 to 1. When the value is **0**, the image remains unchanged.| 208 209**Returns** 210 211Returns a status code defined in [EffectErrorCode](#effecterrorcode). 212 213 214### OH_Filter_CreateEffect() 215 216``` 217EffectErrorCode OH_Filter_CreateEffect (OH_PixelmapNative* pixelmap, OH_Filter** filter ) 218``` 219 220**Description** 221 222Creates an **OH_Filter** object. 223 224**Since**: 12 225 226**Parameters** 227 228| Name| Description| 229| -------- | -------- | 230| pixelmap | Pointer to the PixelMap.| 231| filter | Double pointer to the filter created.| 232 233**Returns** 234 235Returns a status code defined in [EffectErrorCode](#effecterrorcode). 236 237 238### OH_Filter_GetEffectPixelMap() 239 240``` 241EffectErrorCode OH_Filter_GetEffectPixelMap (OH_Filter* filter, OH_PixelmapNative** pixelmap ) 242``` 243 244**Description** 245 246Obtains the PixelMap used to create a filter. 247 248**Since**: 12 249 250**Parameters** 251 252| Name| Description| 253| -------- | -------- | 254| filter | Pointer to the filter.| 255| pixelmap | Double pointer to the PixelMap obtained.| 256 257**Returns** 258 259Returns a status code defined in [EffectErrorCode](#effecterrorcode). 260 261 262### OH_Filter_GrayScale() 263 264``` 265EffectErrorCode OH_Filter_GrayScale (OH_Filter* filter) 266``` 267 268**Description** 269 270Creates the grayscale effect and adds it to a filter. 271 272**Since**: 12 273 274**Parameters** 275 276| Name| Description| 277| -------- | -------- | 278| filter | Pointer to the filter.| 279 280**Returns** 281 282Returns a status code defined in [EffectErrorCode](#effecterrorcode). 283 284 285### OH_Filter_Invert() 286 287``` 288EffectErrorCode OH_Filter_Invert (OH_Filter* filter) 289``` 290 291**Description** 292 293Creates the inverted color effect and adds it to a filter. 294 295**Since**: 12 296 297**Parameters** 298 299| Name| Description| 300| -------- | -------- | 301| filter | Pointer to the filter.| 302 303**Returns** 304 305Returns a status code defined in [EffectErrorCode](#effecterrorcode). 306 307 308### OH_Filter_Release() 309 310``` 311EffectErrorCode OH_Filter_Release (OH_Filter* filter) 312``` 313 314**Description** 315 316Releases an **OH_Filter** object. 317 318**Since**: 12 319 320**Parameters** 321 322| Name| Description| 323| -------- | -------- | 324| filter | Pointer to the filter.| 325 326**Returns** 327 328Returns a status code defined in [EffectErrorCode](#effecterrorcode). 329 330 331### OH_Filter_SetColorMatrix() 332 333``` 334EffectErrorCode OH_Filter_SetColorMatrix (OH_Filter* filter, OH_Filter_ColorMatrix* matrix ) 335``` 336 337**Description** 338 339Creates a custom effect through a matrix and adds it to a filter. 340 341**Since**: 12 342 343**Parameters** 344 345| Name| Description| 346| -------- | -------- | 347| filter | Pointer to the filter.| 348| matrix | Pointer to a custom matrix, which is an [OH_Filter_ColorMatrix](_o_h___filter___color_matrix.md) object.| 349 350**Returns** 351 352Returns a status code defined in [EffectErrorCode](#effecterrorcode). 353