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 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_Brighten](#oh_filter_brighten) ([OH_Filter](_o_h___filter.md) \*filter, float brightness) | Creates the brightening effect and adds it to a filter.| 53| [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.| 54| [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.| 55| [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.| 56| [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.| 57 58 59## Type Description 60 61 62### EffectErrorCode 63 64``` 65typedef enum EffectErrorCode EffectErrorCode 66``` 67 68**Description** 69 70Defines an enum for the status codes that may be used by the effect filter. 71 72**Since**: 12 73 74 75### pixelMap 76 77``` 78typedef struct OH_Filter pixelMap 79``` 80 81**Description** 82 83Defines a struct for a filter used to generate a filter pixel map. 84 85**Since**: 12 86 87 88## Enum Description 89 90 91### EffectErrorCode 92 93``` 94enum EffectErrorCode 95``` 96 97**Description** 98 99Enumerates the status codes that may be used by the effect filter. 100 101**Since**: 12 102 103| Value| Description| 104| -------- | -------- | 105| EFFECT_SUCCESS | Operation successful.| 106| EFFECT_BAD_PARAMETER | Invalid parameter.| 107| EFFECT_UNSUPPORTED_OPERATION | Unsupported operation.| 108| EFFECT_UNKNOWN_ERROR | Unknown error.| 109 110 111## Function Description 112 113 114### OH_Filter_Blur() 115 116``` 117EffectErrorCode OH_Filter_Blur (OH_Filter* filter, float radius ) 118``` 119 120**Description** 121 122Creates the frosted glass effect and adds it to a filter. 123 124**Since**: 12 125 126**Parameters** 127 128| Name| Description| 129| -------- | -------- | 130| filter | Pointer to the filter.| 131| radius | Blur radius of the frosted glass effect, in px.| 132 133**Returns** 134 135Returns a status code defined in [EffectErrorCode](#effecterrorcode). 136 137 138### OH_Filter_Brighten() 139 140``` 141EffectErrorCode OH_Filter_Brighten (OH_Filter* filter, float brightness ) 142``` 143 144**Description** 145 146Creates the brightening effect and adds it to a filter. 147 148**Since**: 12 149 150**Parameters** 151 152| Name| Description| 153| -------- | -------- | 154| filter | Pointer to the filter.| 155| brightness | Luminance of the brightening effect. The value ranges from 0 to 1. When the value is **0**, the image remains unchanged.| 156 157**Returns** 158 159Returns a status code defined in [EffectErrorCode](#effecterrorcode). 160 161 162### OH_Filter_CreateEffect() 163 164``` 165EffectErrorCode OH_Filter_CreateEffect (OH_PixelmapNative* pixelmap, OH_Filter** filter ) 166``` 167 168**Description** 169 170Creates an **OH_Filter** object. 171 172**Since**: 12 173 174**Parameters** 175 176| Name| Description| 177| -------- | -------- | 178| pixelmap | Pointer to the pixel map.| 179| filter | Double pointer to the filter created.| 180 181**Returns** 182 183Returns a status code defined in [EffectErrorCode](#effecterrorcode). 184 185 186### OH_Filter_GetEffectPixelMap() 187 188``` 189EffectErrorCode OH_Filter_GetEffectPixelMap (OH_Filter* filter, OH_PixelmapNative** pixelmap ) 190``` 191 192**Description** 193 194Obtains the pixel map used to create a filter. 195 196**Since**: 12 197 198**Parameters** 199 200| Name| Description| 201| -------- | -------- | 202| filter | Pointer to the filter.| 203| pixelmap | Double pointer to the pixel map obtained.| 204 205**Returns** 206 207Returns a status code defined in [EffectErrorCode](#effecterrorcode). 208 209 210### OH_Filter_GrayScale() 211 212``` 213EffectErrorCode OH_Filter_GrayScale (OH_Filter* filter) 214``` 215 216**Description** 217 218Creates the grayscale effect and adds it to a filter. 219 220**Since**: 12 221 222**Parameters** 223 224| Name| Description| 225| -------- | -------- | 226| filter | Pointer to the filter.| 227 228**Returns** 229 230Returns a status code defined in [EffectErrorCode](#effecterrorcode). 231 232 233### OH_Filter_Invert() 234 235``` 236EffectErrorCode OH_Filter_Invert (OH_Filter* filter) 237``` 238 239**Description** 240 241Creates the inverted color effect and adds it to a filter. 242 243**Since**: 12 244 245**Parameters** 246 247| Name| Description| 248| -------- | -------- | 249| filter | Pointer to the filter.| 250 251**Returns** 252 253Returns a status code defined in [EffectErrorCode](#effecterrorcode). 254 255 256### OH_Filter_Release() 257 258``` 259EffectErrorCode OH_Filter_Release (OH_Filter* filter) 260``` 261 262**Description** 263 264Releases an **OH_Filter** object. 265 266**Since**: 12 267 268**Parameters** 269 270| Name| Description| 271| -------- | -------- | 272| filter | Pointer to the filter.| 273 274**Returns** 275 276Returns a status code defined in [EffectErrorCode](#effecterrorcode). 277 278 279### OH_Filter_SetColorMatrix() 280 281``` 282EffectErrorCode OH_Filter_SetColorMatrix (OH_Filter* filter, OH_Filter_ColorMatrix* matrix ) 283``` 284 285**Description** 286 287Creates a custom effect through a matrix and adds it to a filter. 288 289**Since**: 12 290 291**Parameters** 292 293| Name| Description| 294| -------- | -------- | 295| filter | Pointer to the filter.| 296| matrix | Pointer to a custom matrix, which is an [OH_Filter_ColorMatrix](_o_h___filter___color_matrix.md) object.| 297 298**Returns** 299 300Returns a status code defined in [EffectErrorCode](#effecterrorcode). 301