• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) 2022 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
16import { AsyncCallback } from './@ohos.base';
17import image from './@ohos.multimedia.image';
18
19/**
20 * @name  effectKit
21 * @since 9
22 */
23declare namespace effectKit {
24
25  /**
26   * The Filter of FilterChain.
27   * @since 9
28   * @syscap SystemCapability.Multimedia.Image.Core
29   */
30  interface Filter {
31
32    /**
33    * A blur effect is added to the image.
34    * @since 9
35    * @syscap SystemCapability.Multimedia.Image.Core
36    * @param radius The degree of blur, the value is measured in pixels.
37    * @returns Filters for the current effect have been added.
38    */
39    blur(radius: number): Filter;
40
41    /**
42    * A Brightness effect is added to the image.
43    * @since 9
44    * @syscap SystemCapability.Multimedia.Image.Core
45    * @param bright The degree of light and darkness,the value range is 0 to 1.
46    * @returns Filters for the current effect have been added.
47    */
48    brightness(bright: number): Filter;
49
50    /**
51    * A Grayscale effect is added to the image.
52    * @since 9
53    * @syscap SystemCapability.Multimedia.Image.Core
54    * @returns Filters for the current effect have been added.
55    */
56    grayscale(): Filter;
57
58    /**
59    * Gets the PixelMap where all filter effects have been added to the image.
60    * @since 9
61    * @syscap SystemCapability.Multimedia.Image.Core
62    * @returns image.PixelMap.
63    */
64    getPixelMap(): image.PixelMap;
65  }
66
67  /**
68   * The color picker of an image.
69   * @since 9
70   * @syscap SystemCapability.Multimedia.Image.Core
71   */
72  interface ColorPicker {
73
74    /**
75     * get main color of an image
76     * @since 9
77     * @syscap SystemCapability.Multimedia.Image.Core
78     */
79    getMainColor(): Promise<Color>;
80
81    /**
82     * get main color of an image
83     * @since 9
84     * @syscap SystemCapability.Multimedia.Image.Core
85     */
86    getMainColorSync(): Color;
87
88    /**
89     * Get largest proportion color of an image
90     * @since 10
91     * @syscap SystemCapability.Multimedia.Image.Core
92     * @returns {Color} Largest proportion color picked in the image.
93     */
94    getLargestProportionColor(): Color;
95
96    /**
97     * Get highest saturation color of an image
98     * @since 10
99     * @syscap SystemCapability.Multimedia.Image.Core
100     * @returns {Color} Highest saturation color picked in the image.
101     */
102    getHighestSaturationColor(): Color;
103
104    /**
105     * Get average color of an image
106     * @since 10
107     * @syscap SystemCapability.Multimedia.Image.Core
108     * @returns {Color} Average color calculated in the image.
109     */
110    getAverageColor(): Color;
111
112    /**
113     * Determine whether the color is black or white or gray
114     * @since 10
115     * @syscap SystemCapability.Multimedia.Image.Core
116     * @param {color} number The 32 bit ARGB color to discriminate.
117     * @returns {boolean} Result of judging black, white and gray.
118     */
119    isBlackOrWhiteOrGrayColor(color: number): boolean;
120  }
121
122  /**
123   * The color param.
124   * @since 9
125   * @syscap SystemCapability.Multimedia.Image.Core
126   */
127  interface Color {
128
129    /**
130     * Red
131     * @since 9
132     * @syscap SystemCapability.Multimedia.Image.Core
133     */
134    red: number;
135
136    /**
137     * Green
138     * @since 9
139     * @syscap SystemCapability.Multimedia.Image.Core
140     */
141    green: number;
142
143    /**
144     * Blue
145     * @since 9
146     * @syscap SystemCapability.Multimedia.Image.Core
147     */
148    blue: number;
149
150    /**
151     * Alpha
152     * @since 9
153     * @syscap SystemCapability.Multimedia.Image.Core
154     */
155    alpha: number;
156  }
157
158  /**
159   * Create a FilterChain to add multiple effects to an image.
160   * @since 9
161   * @syscap SystemCapability.Multimedia.Image.Core
162   * @param image.PixelMap.
163   * @returns Returns the head node of FilterChain.
164   */
165  function createEffect(source: image.PixelMap): Filter;
166
167  /**
168   * Create a color picker to get color of an image.
169   * @param { image.PixelMap } source - the source pixelmap.
170   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
171   * @throws { BusinessError } 401 - Input parameter error.
172   * @syscap SystemCapability.Multimedia.Image.Core
173   * @since 9
174   */
175  function createColorPicker(source: image.PixelMap): Promise<ColorPicker>;
176
177  /**
178   * Create a color picker to get color of an image.
179   * @param { image.PixelMap } source - the source pixelmap.
180   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
181   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
182   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
183   * @throws { BusinessError } 401 - Input parameter error.
184   * @syscap SystemCapability.Multimedia.Image.Core
185   * @since 10
186   */
187  function createColorPicker(source: image.PixelMap, region: Array<number>): Promise<ColorPicker>;
188
189  /**
190   * Create a color picker to get color of an image.
191   * @param { image.PixelMap } source - the source pixelmap.
192   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
193   * @throws { BusinessError } 401 - Input parameter error.
194   * @syscap SystemCapability.Multimedia.Image.Core
195   * @since 9
196   */
197  function createColorPicker(source: image.PixelMap, callback: AsyncCallback<ColorPicker>): void;
198
199  /**
200   * Create a color picker to get color of an image.
201   * @param { image.PixelMap } source - the source pixelmap.
202   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
203   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
204   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
205   * @throws { BusinessError } 401 - Input parameter error.
206   * @syscap SystemCapability.Multimedia.Image.Core
207   * @since 10
208   */
209  function createColorPicker(source: image.PixelMap, region: Array<number>, callback: AsyncCallback<ColorPicker>): void;
210}
211
212export default effectKit;
213