• 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
16/**
17 * @file
18 * @kit ArkGraphics2D
19 */
20
21import { AsyncCallback } from './@ohos.base';
22import image from './@ohos.multimedia.image';
23
24/**
25 * @namespace effectKit
26 * @since 9
27 */
28/**
29 * @namespace effectKit
30 * @form
31 * @atomicservice
32 * @since 12
33 */
34
35
36declare namespace effectKit {
37
38  /**
39   * The Filter of FilterChain.
40   * @typedef Filter
41   * @syscap SystemCapability.Multimedia.Image.Core
42   * @since 9
43   */
44  /**
45   * The Filter of FilterChain.
46   * @typedef Filter
47   * @syscap SystemCapability.Multimedia.Image.Core
48   * @form
49   * @atomicservice
50   * @since 12
51   */
52  interface Filter {
53
54    /**
55    * A blur effect is added to the image.
56    * @param { number } radius - The degree of blur, the value is measured in pixels.
57    * @returns { Filter } Filters for the current effect have been added.
58    * @syscap SystemCapability.Multimedia.Image.Core
59    * @since 9
60    */
61    /**
62    * A blur effect is added to the image.
63    * @param { number } radius - The degree of blur, the value is measured in pixels.
64    * @returns { Filter } Filters for the current effect have been added.
65    * @syscap SystemCapability.Multimedia.Image.Core
66    * @form
67    * @atomicservice
68    * @since 12
69    */
70    blur(radius: number): Filter;
71
72    /**
73    * A Brightness effect is added to the image.
74    * @param { number } bright - The degree of light and darkness,the value range is 0 to 1.
75    * @returns { Filter } Filters for the current effect have been added.
76    * @syscap SystemCapability.Multimedia.Image.Core
77    * @since 9
78    */
79    /**
80    * A Brightness effect is added to the image.
81    * @param { number } bright - The degree of light and darkness,the value range is 0 to 1.
82    * @returns { Filter } Filters for the current effect have been added.
83    * @syscap SystemCapability.Multimedia.Image.Core
84    * @form
85    * @atomicservice
86    * @since 12
87    */
88    brightness(bright: number): Filter;
89
90    /**
91    * A Grayscale effect is added to the image.
92    * @returns { Filter } Filters for the current effect have been added.
93    * @syscap SystemCapability.Multimedia.Image.Core
94    * @since 9
95    */
96    /**
97    * A Grayscale effect is added to the image.
98    * @returns { Filter } Filters for the current effect have been added.
99    * @syscap SystemCapability.Multimedia.Image.Core
100    * @form
101    * @atomicservice
102    * @since 12
103    */
104    grayscale(): Filter;
105
106    /**
107    * A invert effect is added to the image.
108    * @returns { Filter } Filters for the current effect have been added.
109    * @syscap SystemCapability.Multimedia.Image.Core
110    * @since 12
111    */
112    invert(): Filter;
113
114    /**
115     * A custom effect is added to the image.
116     *
117     * @param { Array<number> } colorMatrix - A matrix of 5x4 size for create effect filter.
118     * @returns { Filter } Filters for the current effect have been added.
119     * @throws { BusinessError } 401 - Input parameter error.
120     * @syscap SystemCapability.Multimedia.Image.Core
121     * @since 12
122     */
123    setColorMatrix(colorMatrix: Array<number>): Filter;
124
125    /**
126    * Gets the PixelMap where all filter effects have been added to the image.
127    * @returns { image.PixelMap } image.PixelMap.
128    * @syscap SystemCapability.Multimedia.Image.Core
129    * @since 9
130    * @deprecated since 11
131    * @useinstead effectKit.Filter#getEffectPixelMap
132    */
133    getPixelMap(): image.PixelMap;
134
135    /**
136    * Gets the PixelMap where all filter effects have been added to the image.
137    * @returns { Promise<image.PixelMap> } - returns the PixelMap generated.
138    * @syscap SystemCapability.Multimedia.Image.Core
139    * @since 11
140    */
141    /**
142    * Gets the PixelMap where all filter effects have been added to the image.
143    * @returns { Promise<image.PixelMap> } - returns the PixelMap generated.
144    * @syscap SystemCapability.Multimedia.Image.Core
145    * @form
146    * @atomicservice
147    * @since 12
148    */
149    getEffectPixelMap(): Promise<image.PixelMap>;
150  }
151
152  /**
153   * The color picker of an image.
154   * @typedef ColorPicker
155   * @syscap SystemCapability.Multimedia.Image.Core
156   * @since 9
157   */
158  /**
159   * The color picker of an image.
160   * @typedef ColorPicker
161   * @syscap SystemCapability.Multimedia.Image.Core
162   * @form
163   * @atomicservice
164   * @since 12
165   */
166  interface ColorPicker {
167
168    /**
169     * get main color of an image
170     * @returns { Promise<Color> } returns the MainColor generated.
171     * @syscap SystemCapability.Multimedia.Image.Core
172     * @since 9
173     */
174    /**
175     * get main color of an image
176     * @returns { Promise<Color> } returns the MainColor generated.
177     * @syscap SystemCapability.Multimedia.Image.Core
178     * @form
179     * @atomicservice
180     * @since 12
181     */
182    getMainColor(): Promise<Color>;
183
184    /**
185     * get main color of an image
186     * @returns { Color } Main color picked in the image.
187     * @syscap SystemCapability.Multimedia.Image.Core
188     * @since 9
189     */
190    /**
191     * get main color of an image
192     * @returns { Color } Main color picked in the image.
193     * @syscap SystemCapability.Multimedia.Image.Core
194     * @form
195     * @atomicservice
196     * @since 12
197     */
198    getMainColorSync(): Color;
199
200    /**
201     * Get largest proportion color of an image
202     * @returns { Color } Largest proportion color picked in the image.
203     * @syscap SystemCapability.Multimedia.Image.Core
204     * @since 10
205     */
206    /**
207     * Get largest proportion color of an image
208     * @returns { Color } Largest proportion color picked in the image.
209     * @syscap SystemCapability.Multimedia.Image.Core
210     * @form
211     * @atomicservice
212     * @since 12
213     */
214    getLargestProportionColor(): Color;
215
216    /**
217     * Get top proportion color of an image
218     * @param { number } colorCount - The number of colors to require, the value is 1 to 10.
219     * @returns { Array<Color | null> } An array of feature colors sorted by proportion, with a size equal to
220     *                                  the minimum of colorCount and the actual number of extracted feature colors.
221     * @syscap SystemCapability.Multimedia.Image.Core
222     * @form
223     * @atomicservice
224     * @since 12
225     */
226    getTopProportionColors(colorCount: number): Array<Color | null>;
227
228    /**
229     * Get highest saturation color of an image
230     * @returns { Color } Highest saturation color picked in the image.
231     * @syscap SystemCapability.Multimedia.Image.Core
232     * @since 10
233     */
234    /**
235     * Get highest saturation color of an image
236     * @returns { Color } Highest saturation color picked in the image.
237     * @syscap SystemCapability.Multimedia.Image.Core
238     * @form
239     * @atomicservice
240     * @since 12
241     */
242    getHighestSaturationColor(): Color;
243
244    /**
245     * Get average color of an image
246     * @returns { Color } Average color calculated in the image.
247     * @syscap SystemCapability.Multimedia.Image.Core
248     * @since 10
249     */
250    /**
251     * Get average color of an image
252     * @returns { Color } Average color calculated in the image.
253     * @syscap SystemCapability.Multimedia.Image.Core
254     * @form
255     * @atomicservice
256     * @since 12
257     */
258    getAverageColor(): Color;
259
260    /**
261     * Determine whether the color is black or white or gray
262     * @param { number } color - The 32 bit ARGB color to discriminate.
263     * @returns { boolean } Result of judging black, white and gray.
264     * @syscap SystemCapability.Multimedia.Image.Core
265     * @since 10
266     */
267    /**
268     * Determine whether the color is black or white or gray
269     * @param { number } color - The 32 bit ARGB color to discriminate.
270     * @returns { boolean } Result of judging black, white and gray.
271     * @syscap SystemCapability.Multimedia.Image.Core
272     * @form
273     * @atomicservice
274     * @since 12
275     */
276    isBlackOrWhiteOrGrayColor(color: number): boolean;
277  }
278
279  /**
280   * The color param.
281   * @typedef Color
282   * @syscap SystemCapability.Multimedia.Image.Core
283   * @since 9
284   */
285  /**
286   * The color param.
287   * @typedef Color
288   * @syscap SystemCapability.Multimedia.Image.Core
289   * @form
290   * @atomicservice
291   * @since 12
292   */
293  interface Color {
294
295    /**
296     * Red
297     * @type { number }
298     * @syscap SystemCapability.Multimedia.Image.Core
299     * @since 9
300     */
301    /**
302     * Red
303     * @type { number }
304     * @syscap SystemCapability.Multimedia.Image.Core
305     * @form
306     * @atomicservice
307     * @since 12
308     */
309    red: number;
310
311    /**
312     * Green
313     * @type { number }
314     * @syscap SystemCapability.Multimedia.Image.Core
315     * @since 9
316     */
317    /**
318     * Green
319     * @type { number }
320     * @syscap SystemCapability.Multimedia.Image.Core
321     * @form
322     * @atomicservice
323     * @since 12
324     */
325    green: number;
326
327    /**
328     * Blue
329     * @type { number }
330     * @syscap SystemCapability.Multimedia.Image.Core
331     * @since 9
332     */
333    /**
334     * Blue
335     * @type { number }
336     * @syscap SystemCapability.Multimedia.Image.Core
337     * @form
338     * @atomicservice
339     * @since 12
340     */
341    blue: number;
342
343    /**
344     * Alpha
345     * @type { number }
346     * @syscap SystemCapability.Multimedia.Image.Core
347     * @since 9
348     */
349    /**
350     * Alpha
351     * @type { number }
352     * @syscap SystemCapability.Multimedia.Image.Core
353     * @form
354     * @atomicservice
355     * @since 12
356     */
357    alpha: number;
358  }
359
360  /**
361   * Create a FilterChain to add multiple effects to an image.
362   * @param { image.PixelMap } source - the source pixelmap.
363   * @returns { Filter } Returns the head node of FilterChain.
364   * @syscap SystemCapability.Multimedia.Image.Core
365   * @since 9
366   */
367  /**
368   * Create a FilterChain to add multiple effects to an image.
369   * @param { image.PixelMap } source - the source pixelmap.
370   * @returns { Filter } Returns the head node of FilterChain.
371   * @syscap SystemCapability.Multimedia.Image.Core
372   * @form
373   * @atomicservice
374   * @since 12
375   */
376  function createEffect(source: image.PixelMap): Filter;
377
378  /**
379   * Create a color picker to get color of an image.
380   * @param { image.PixelMap } source - the source pixelmap.
381   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
382   * @throws { BusinessError } 401 - Input parameter error.
383   * @syscap SystemCapability.Multimedia.Image.Core
384   * @since 9
385   */
386  /**
387   * Create a color picker to get color of an image.
388   * @param { image.PixelMap } source - the source pixelmap.
389   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
390   * @throws { BusinessError } 401 - Input parameter error.
391   * @syscap SystemCapability.Multimedia.Image.Core
392   * @form
393   * @atomicservice
394   * @since 12
395   */
396  function createColorPicker(source: image.PixelMap): Promise<ColorPicker>;
397
398  /**
399   * Create a color picker to get color of an image.
400   * @param { image.PixelMap } source - the source pixelmap.
401   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
402   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
403   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
404   * @throws { BusinessError } 401 - Input parameter error.
405   * @syscap SystemCapability.Multimedia.Image.Core
406   * @since 10
407   */
408  /**
409   * Create a color picker to get color of an image.
410   * @param { image.PixelMap } source - the source pixelmap.
411   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
412   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
413   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
414   * @throws { BusinessError } 401 - Input parameter error.
415   * @syscap SystemCapability.Multimedia.Image.Core
416   * @form
417   * @atomicservice
418   * @since 12
419   */
420  function createColorPicker(source: image.PixelMap, region: Array<number>): Promise<ColorPicker>;
421
422  /**
423   * Create a color picker to get color of an image.
424   * @param { image.PixelMap } source - the source pixelmap.
425   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
426   * @throws { BusinessError } 401 - Input parameter error.
427   * @syscap SystemCapability.Multimedia.Image.Core
428   * @since 9
429   */
430  /**
431   * Create a color picker to get color of an image.
432   * @param { image.PixelMap } source - the source pixelmap.
433   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
434   * @throws { BusinessError } 401 - Input parameter error.
435   * @syscap SystemCapability.Multimedia.Image.Core
436   * @form
437   * @atomicservice
438   * @since 12
439   */
440  function createColorPicker(source: image.PixelMap, callback: AsyncCallback<ColorPicker>): void;
441
442  /**
443   * Create a color picker to get color of an image.
444   * @param { image.PixelMap } source - the source pixelmap.
445   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
446   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
447   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
448   * @throws { BusinessError } 401 - Input parameter error.
449   * @syscap SystemCapability.Multimedia.Image.Core
450   * @since 10
451   */
452  /**
453   * Create a color picker to get color of an image.
454   * @param { image.PixelMap } source - the source pixelmap.
455   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
456   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
457   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
458   * @throws { BusinessError } 401 - Input parameter error.
459   * @syscap SystemCapability.Multimedia.Image.Core
460   * @form
461   * @atomicservice
462   * @since 12
463   */
464  function createColorPicker(source: image.PixelMap, region: Array<number>, callback: AsyncCallback<ColorPicker>): void;
465}
466
467export default effectKit;
468