• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef C_INCLUDE_DRAWING_IMAGE_FILTER_H
17 #define C_INCLUDE_DRAWING_IMAGE_FILTER_H
18 
19 /**
20  * @addtogroup Drawing
21  * @{
22  *
23  * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
24  *
25  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
26  *
27  * @since 12
28  * @version 1.0
29  */
30 
31 /**
32  * @file drawing_image_filter.h
33  *
34  * @brief Declares functions related to the <b>imageFilter</b> object in the drawing module.
35  *
36  * @since 12
37  * @version 1.0
38  */
39 
40 #include "drawing_shader_effect.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Creates an <b>OH_Drawing_ImageFilter</b> object that blurs its input by the separate x and y sigmas.
48  *
49  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
50  * @param sigmaX Indicates the Gaussian sigma value for blurring along the x axis.
51  * @param sigmaY Indicates the Gaussian sigma value for blurring along the y axis.
52  * @param OH_Drawing_TileMode Indicates the tile mode applied at edges.
53  * @param OH_Drawing_ImageFilter Indicates the input filter that is blurred, uses source bitmap if this is null.
54  * @return Returns the pointer to the <b>OH_Drawing_ImageFilter</b> object created.
55  * @since 12
56  * @version 1.0
57  */
58 OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlur(float sigmaX, float sigmaY, OH_Drawing_TileMode,
59     OH_Drawing_ImageFilter*);
60 
61 /**
62  * @brief Creates an <b>OH_Drawing_ImageFilter</b> object that blurs its input by the separate x and y sigmas.
63  * Supports an optional crop rectangle to restrict the blur effect to a specific region of the input.
64  *
65  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
66  * @param sigmaX Indicates the Gaussian sigma value for blurring along the x axis.
67  * @param sigmaY Indicates the Gaussian sigma value for blurring along the y axis.
68  * @param tileMode Indicates the tile mode applied at edges.
69  * @param input Indicates the input filter that is blurred, uses source bitmap if this is null.
70  * @param rect Indicates optional rectangle that crops the input and output.
71  *             If rect is null, the blur effect applies to the entire input image.
72  * @return Returns the pointer to the <b>OH_Drawing_ImageFilter</b> object created.
73  * @since 20
74  * @version 1.0
75  */
76 OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlurWithCrop(float sigmaX, float sigmaY,
77     OH_Drawing_TileMode tileMode, OH_Drawing_ImageFilter* input, const OH_Drawing_Rect* rect);
78 
79 /**
80  * @brief Creates an <b>OH_Drawing_ImageFilter</b> object that applies the color filter to the input.
81  *
82  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
83  * @param OH_Drawing_ColorFilter Indicates the color filter that transforms the input image.
84  * @param OH_Drawing_ImageFilter Indicates the input filter, or uses the source bitmap if this is null.
85  * @return Returns the pointer to the <b>OH_Drawing_ImageFilter</b> object created.
86  * @since 12
87  * @version 1.0
88  */
89 OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromColorFilter(OH_Drawing_ColorFilter*, OH_Drawing_ImageFilter*);
90 
91 /**
92  * @brief Creates an <b>OH_Drawing_ImageFilter</b> object with the provided x and y offset.
93  *
94  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
95  * @param x Indicates the x offset.
96  * @param y Indicates the y offset.
97  * @param imageFilter Indicates the input filter, or uses the source bitmap if this is null.
98  * @return Returns the pointer to the <b>OH_Drawing_ImageFilter</b> object created.
99  *         If nullptr is returned, the creation fails.
100  *         The possible cause of the failure is that the available memory is empty.
101  * @since 20
102  * @version 1.0
103  */
104 OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateOffset(float x, float y, OH_Drawing_ImageFilter* imageFilter);
105 
106 /**
107  * @brief Creates an <b>OH_Drawing_ImageFilter</b> object that applies the shader to the input.
108  *
109  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
110  * @param shaderEffect Indicates the shader effect to be applied to the image.
111  * @return Returns the pointer to the <b>OH_Drawing_ImageFilter</b> object created.
112  *         If nullptr is returned, the creation fails.
113  *         The possible cause of the failure is that the available memory is empty or
114  *         a nullptr <b>OH_Drawing_ShaderEffect</b> is passed.
115  * @since 20
116  * @version 1.0
117  */
118 OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromShaderEffect(OH_Drawing_ShaderEffect* shaderEffect);
119 
120 /**
121  * @brief Destroys an <b>OH_Drawing_ImageFilter</b> object and reclaims the memory occupied by the object.
122  *
123  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
124  * @param OH_Drawing_ImageFilter Indicates the pointer to an <b>OH_Drawing_ImageFilter</b> object.
125  * @since 12
126  * @version 1.0
127  */
128 void OH_Drawing_ImageFilterDestroy(OH_Drawing_ImageFilter*);
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 /** @} */
134 #endif