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 * @namespace effectKit
36 * @crossplatform
37 * @form
38 * @atomicservice
39 * @since 14
40 */
41
42declare namespace effectKit {
43
44  /**
45   * The Filter of FilterChain.
46   * @typedef Filter
47   * @syscap SystemCapability.Multimedia.Image.Core
48   * @since 9
49   */
50  /**
51   * The Filter of FilterChain.
52   * @typedef Filter
53   * @syscap SystemCapability.Multimedia.Image.Core
54   * @form
55   * @atomicservice
56   * @since 12
57   */
58  /**
59   * The Filter of FilterChain.
60   * @typedef Filter
61   * @syscap SystemCapability.Multimedia.Image.Core
62   * @crossplatform
63   * @form
64   * @atomicservice
65   * @since 14
66   */
67  interface Filter {
68
69    /**
70    * A blur effect is added to the image.
71    * @param { number } radius - The degree of blur, the value is measured in pixels.
72    * @returns { Filter } Filters for the current effect have been added.
73    * @syscap SystemCapability.Multimedia.Image.Core
74    * @since 9
75    */
76    /**
77    * A blur effect is added to the image.
78    * @param { number } radius - The degree of blur, the value is measured in pixels.
79    * @returns { Filter } Filters for the current effect have been added.
80    * @syscap SystemCapability.Multimedia.Image.Core
81    * @form
82    * @atomicservice
83    * @since 12
84    */
85    /**
86    * A blur effect is added to the image.
87    * @param { number } radius - The degree of blur, the value is measured in pixels.
88    * @returns { Filter } Filters for the current effect have been added.
89    * @syscap SystemCapability.Multimedia.Image.Core
90    * @crossplatform
91    * @form
92    * @atomicservice
93    * @since 14
94    */
95    blur(radius: number): Filter;
96
97    /**
98    * A Brightness effect is added to the image.
99    * @param { number } bright - The degree of light and darkness,the value range is 0 to 1.
100    * @returns { Filter } Filters for the current effect have been added.
101    * @syscap SystemCapability.Multimedia.Image.Core
102    * @since 9
103    */
104    /**
105    * A Brightness effect is added to the image.
106    * @param { number } bright - The degree of light and darkness,the value range is 0 to 1.
107    * @returns { Filter } Filters for the current effect have been added.
108    * @syscap SystemCapability.Multimedia.Image.Core
109    * @form
110    * @atomicservice
111    * @since 12
112    */
113    /**
114    * A Brightness effect is added to the image.
115    * @param { number } bright - The degree of light and darkness,the value range is 0 to 1.
116    * @returns { Filter } Filters for the current effect have been added.
117    * @syscap SystemCapability.Multimedia.Image.Core
118    * @crossplatform
119    * @form
120    * @atomicservice
121    * @since 14
122    */
123    brightness(bright: number): Filter;
124
125    /**
126    * A Grayscale effect is added to the image.
127    * @returns { Filter } Filters for the current effect have been added.
128    * @syscap SystemCapability.Multimedia.Image.Core
129    * @since 9
130    */
131    /**
132    * A Grayscale effect is added to the image.
133    * @returns { Filter } Filters for the current effect have been added.
134    * @syscap SystemCapability.Multimedia.Image.Core
135    * @form
136    * @atomicservice
137    * @since 12
138    */
139    /**
140    * A Grayscale effect is added to the image.
141    * @returns { Filter } Filters for the current effect have been added.
142    * @syscap SystemCapability.Multimedia.Image.Core
143    * @crossplatform
144    * @form
145    * @atomicservice
146    * @since 14
147    */
148    grayscale(): Filter;
149
150    /**
151    * A invert effect is added to the image.
152    * @returns { Filter } Filters for the current effect have been added.
153    * @syscap SystemCapability.Multimedia.Image.Core
154    * @since 12
155    */
156    /**
157    * A invert effect is added to the image.
158    * @returns { Filter } Filters for the current effect have been added.
159    * @syscap SystemCapability.Multimedia.Image.Core
160    * @crossplatform
161    * @since 14
162    */
163    invert(): Filter;
164
165    /**
166     * A custom effect is added to the image.
167     *
168     * @param { Array<number> } colorMatrix - A matrix of 5x4 size for create effect filter.
169     * @returns { Filter } Filters for the current effect have been added.
170     * @throws { BusinessError } 401 - Input parameter error.
171     * @syscap SystemCapability.Multimedia.Image.Core
172     * @since 12
173     */
174    /**
175     * A custom effect is added to the image.
176     *
177     * @param { Array<number> } colorMatrix - A matrix of 5x4 size for create effect filter.
178     * @returns { Filter } Filters for the current effect have been added.
179     * @throws { BusinessError } 401 - Input parameter error.
180     * @syscap SystemCapability.Multimedia.Image.Core
181     * @crossplatform
182     * @since 14
183     */
184    setColorMatrix(colorMatrix: Array<number>): Filter;
185
186    /**
187    * Gets the PixelMap where all filter effects have been added to the image.
188    * @returns { image.PixelMap } image.PixelMap.
189    * @syscap SystemCapability.Multimedia.Image.Core
190    * @since 9
191    * @deprecated since 11
192    * @useinstead effectKit.Filter#getEffectPixelMap
193    */
194    getPixelMap(): image.PixelMap;
195  
196    /**
197    * Gets the PixelMap where all filter effects have been added to the image.
198    * @returns { Promise<image.PixelMap> } - returns the PixelMap generated.
199    * @syscap SystemCapability.Multimedia.Image.Core
200    * @since 11
201    */
202    /**
203    * Gets the PixelMap where all filter effects have been added to the image.
204    * @returns { Promise<image.PixelMap> } - returns the PixelMap generated.
205    * @syscap SystemCapability.Multimedia.Image.Core
206    * @form
207    * @atomicservice
208    * @since 12
209    */
210    /**
211    * Gets the PixelMap where all filter effects have been added to the image.
212    * @returns { Promise<image.PixelMap> } - returns the PixelMap generated.
213    * @syscap SystemCapability.Multimedia.Image.Core
214    * @crossplatform
215    * @form
216    * @atomicservice
217    * @since 14
218    */
219    getEffectPixelMap(): Promise<image.PixelMap>;
220  }
221
222  /**
223   * The color picker of an image.
224   * @typedef ColorPicker
225   * @syscap SystemCapability.Multimedia.Image.Core
226   * @since 9
227   */
228  /**
229   * The color picker of an image.
230   * @typedef ColorPicker
231   * @syscap SystemCapability.Multimedia.Image.Core
232   * @form
233   * @atomicservice
234   * @since 12
235   */
236  /**
237   * The color picker of an image.
238   * @typedef ColorPicker
239   * @syscap SystemCapability.Multimedia.Image.Core
240   * @crossplatform
241   * @form
242   * @atomicservice
243   * @since 14
244   */
245  interface ColorPicker {
246
247    /**
248     * get main color of an image
249     * @returns { Promise<Color> } returns the MainColor generated.
250     * @syscap SystemCapability.Multimedia.Image.Core
251     * @since 9
252     */
253    /**
254     * get main color of an image
255     * @returns { Promise<Color> } returns the MainColor generated.
256     * @syscap SystemCapability.Multimedia.Image.Core
257     * @form
258     * @atomicservice
259     * @since 12
260     */
261    /**
262     * get main color of an image
263     * @returns { Promise<Color> } returns the MainColor generated.
264     * @syscap SystemCapability.Multimedia.Image.Core
265     * @crossplatform
266     * @form
267     * @atomicservice
268     * @since 14
269     */
270    getMainColor(): Promise<Color>;
271
272    /**
273     * get main color of an image
274     * @returns { Color } Main color picked in the image.
275     * @syscap SystemCapability.Multimedia.Image.Core
276     * @since 9
277     */
278    /**
279     * get main color of an image
280     * @returns { Color } Main color picked in the image.
281     * @syscap SystemCapability.Multimedia.Image.Core
282     * @form
283     * @atomicservice
284     * @since 12
285     */
286    /**
287     * get main color of an image
288     * @returns { Color } Main color picked in the image.
289     * @syscap SystemCapability.Multimedia.Image.Core
290     * @crossplatform
291     * @form
292     * @atomicservice
293     * @since 14
294     */
295    getMainColorSync(): Color;
296
297    /**
298     * Get largest proportion color of an image
299     * @returns { Color } Largest proportion color picked in the image.
300     * @syscap SystemCapability.Multimedia.Image.Core
301     * @since 10
302     */
303    /**
304     * Get largest proportion color of an image
305     * @returns { Color } Largest proportion color picked in the image.
306     * @syscap SystemCapability.Multimedia.Image.Core
307     * @form
308     * @atomicservice
309     * @since 12
310     */
311    /**
312     * Get largest proportion color of an image
313     * @returns { Color } Largest proportion color picked in the image.
314     * @syscap SystemCapability.Multimedia.Image.Core
315     * @crossplatform
316     * @form
317     * @atomicservice
318     * @since 14
319     */
320    getLargestProportionColor(): Color;
321
322    /**
323     * Get top proportion color of an image
324     * @param { number } colorCount - The number of colors to require, the value is 1 to 10.
325     * @returns { Array<Color | null> } An array of feature colors sorted by proportion, with a size equal to
326     *                                  the minimum of colorCount and the actual number of extracted feature colors.
327     * @syscap SystemCapability.Multimedia.Image.Core
328     * @form
329     * @atomicservice
330     * @since 12
331     */
332    /**
333     * Get top proportion color of an image
334     * @param { number } colorCount - The number of colors to require, the value is 1 to 10.
335     * @returns { Array<Color | null> } An array of feature colors sorted by proportion, with a size equal to
336     *                                  the minimum of colorCount and the actual number of extracted feature colors.
337     * @syscap SystemCapability.Multimedia.Image.Core
338     * @crossplatform
339     * @form
340     * @atomicservice
341     * @since 14
342     */
343    getTopProportionColors(colorCount: number): Array<Color | null>;
344
345    /**
346     * Get highest saturation color of an image
347     * @returns { Color } Highest saturation color picked in the image.
348     * @syscap SystemCapability.Multimedia.Image.Core
349     * @since 10
350     */
351    /**
352     * Get highest saturation color of an image
353     * @returns { Color } Highest saturation color picked in the image.
354     * @syscap SystemCapability.Multimedia.Image.Core
355     * @form
356     * @atomicservice
357     * @since 12
358     */
359    /**
360     * Get highest saturation color of an image
361     * @returns { Color } Highest saturation color picked in the image.
362     * @syscap SystemCapability.Multimedia.Image.Core
363     * @crossplatform
364     * @form
365     * @atomicservice
366     * @since 14
367     */
368    getHighestSaturationColor(): Color;
369
370    /**
371     * Get average color of an image
372     * @returns { Color } Average color calculated in the image.
373     * @syscap SystemCapability.Multimedia.Image.Core
374     * @since 10
375     */
376    /**
377     * Get average color of an image
378     * @returns { Color } Average color calculated in the image.
379     * @syscap SystemCapability.Multimedia.Image.Core
380     * @form
381     * @atomicservice
382     * @since 12
383     */
384    /**
385     * Get average color of an image
386     * @returns { Color } Average color calculated in the image.
387     * @syscap SystemCapability.Multimedia.Image.Core
388     * @crossplatform
389     * @form
390     * @atomicservice
391     * @since 14
392     */
393    getAverageColor(): Color;
394
395    /**
396     * Determine whether the color is black or white or gray
397     * @param { number } color - The 32 bit ARGB color to discriminate.
398     * @returns { boolean } Result of judging black, white and gray.
399     * @syscap SystemCapability.Multimedia.Image.Core
400     * @since 10
401     */
402    /**
403     * Determine whether the color is black or white or gray
404     * @param { number } color - The 32 bit ARGB color to discriminate.
405     * @returns { boolean } Result of judging black, white and gray.
406     * @syscap SystemCapability.Multimedia.Image.Core
407     * @form
408     * @atomicservice
409     * @since 12
410     */
411    /**
412     * Determine whether the color is black or white or gray
413     * @param { number } color - The 32 bit ARGB color to discriminate.
414     * @returns { boolean } Result of judging black, white and gray.
415     * @syscap SystemCapability.Multimedia.Image.Core
416     * @crossplatform
417     * @form
418     * @atomicservice
419     * @since 14
420     */
421    isBlackOrWhiteOrGrayColor(color: number): boolean;
422  }
423
424  /**
425   * The color param.
426   * @typedef Color
427   * @syscap SystemCapability.Multimedia.Image.Core
428   * @since 9
429   */
430  /**
431   * The color param.
432   * @typedef Color
433   * @syscap SystemCapability.Multimedia.Image.Core
434   * @form
435   * @atomicservice
436   * @since 12
437   */
438  /**
439   * The color param.
440   * @typedef Color
441   * @syscap SystemCapability.Multimedia.Image.Core
442   * @crossplatform
443   * @form
444   * @atomicservice
445   * @since 14
446   */
447  interface Color {
448
449    /**
450     * Red
451     * @type { number }
452     * @syscap SystemCapability.Multimedia.Image.Core
453     * @since 9
454     */
455    /**
456     * Red
457     * @type { number }
458     * @syscap SystemCapability.Multimedia.Image.Core
459     * @form
460     * @atomicservice
461     * @since 12
462     */
463    /**
464     * Red
465     * @type { number }
466     * @syscap SystemCapability.Multimedia.Image.Core
467     * @crossplatform
468     * @form
469     * @atomicservice
470     * @since 14
471     */
472    red: number;
473
474    /**
475     * Green
476     * @type { number }
477     * @syscap SystemCapability.Multimedia.Image.Core
478     * @since 9
479     */
480    /**
481     * Green
482     * @type { number }
483     * @syscap SystemCapability.Multimedia.Image.Core
484     * @form
485     * @atomicservice
486     * @since 12
487     */
488    /**
489     * Green
490     * @type { number }
491     * @syscap SystemCapability.Multimedia.Image.Core
492     * @crossplatform
493     * @form
494     * @atomicservice
495     * @since 14
496     */
497    green: number;
498
499    /**
500     * Blue
501     * @type { number }
502     * @syscap SystemCapability.Multimedia.Image.Core
503     * @since 9
504     */
505    /**
506     * Blue
507     * @type { number }
508     * @syscap SystemCapability.Multimedia.Image.Core
509     * @form
510     * @atomicservice
511     * @since 12
512     */
513    /**
514     * Blue
515     * @type { number }
516     * @syscap SystemCapability.Multimedia.Image.Core
517     * @crossplatform
518     * @form
519     * @atomicservice
520     * @since 14
521     */
522    blue: number;
523
524    /**
525     * Alpha
526     * @type { number }
527     * @syscap SystemCapability.Multimedia.Image.Core
528     * @since 9
529     */
530    /**
531     * Alpha
532     * @type { number }
533     * @syscap SystemCapability.Multimedia.Image.Core
534     * @form
535     * @atomicservice
536     * @since 12
537     */
538    /**
539     * Alpha
540     * @type { number }
541     * @syscap SystemCapability.Multimedia.Image.Core
542     * @crossplatform
543     * @form
544     * @atomicservice
545     * @since 14
546     */
547    alpha: number;
548  }
549
550  /**
551   * Create a FilterChain to add multiple effects to an image.
552   * @param { image.PixelMap } source - the source pixelmap.
553   * @returns { Filter } Returns the head node of FilterChain.
554   * @syscap SystemCapability.Multimedia.Image.Core
555   * @since 9
556   */
557  /**
558   * Create a FilterChain to add multiple effects to an image.
559   * @param { image.PixelMap } source - the source pixelmap.
560   * @returns { Filter } Returns the head node of FilterChain.
561   * @syscap SystemCapability.Multimedia.Image.Core
562   * @form
563   * @atomicservice
564   * @since 12
565   */
566  /**
567   * Create a FilterChain to add multiple effects to an image.
568   * @param { image.PixelMap } source - the source pixelmap.
569   * @returns { Filter } Returns the head node of FilterChain.
570   * @syscap SystemCapability.Multimedia.Image.Core
571   * @crossplatform
572   * @form
573   * @atomicservice
574   * @since 14
575   */
576  function createEffect(source: image.PixelMap): Filter;
577
578  /**
579   * Create a color picker to get color of an image.
580   * @param { image.PixelMap } source - the source pixelmap.
581   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
582   * @throws { BusinessError } 401 - Input parameter error.
583   * @syscap SystemCapability.Multimedia.Image.Core
584   * @since 9
585   */
586  /**
587   * Create a color picker to get color of an image.
588   * @param { image.PixelMap } source - the source pixelmap.
589   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
590   * @throws { BusinessError } 401 - Input parameter error.
591   * @syscap SystemCapability.Multimedia.Image.Core
592   * @form
593   * @atomicservice
594   * @since 12
595   */
596  /**
597   * Create a color picker to get color of an image.
598   * @param { image.PixelMap } source - the source pixelmap.
599   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
600   * @throws { BusinessError } 401 - Input parameter error.
601   * @syscap SystemCapability.Multimedia.Image.Core
602   * @crossplatform
603   * @form
604   * @atomicservice
605   * @since 14
606   */
607  function createColorPicker(source: image.PixelMap): Promise<ColorPicker>;
608
609  /**
610   * Create a color picker to get color of an image.
611   * @param { image.PixelMap } source - the source pixelmap.
612   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
613   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
614   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
615   * @throws { BusinessError } 401 - Input parameter error.
616   * @syscap SystemCapability.Multimedia.Image.Core
617   * @since 10
618   */
619  /**
620   * Create a color picker to get color of an image.
621   * @param { image.PixelMap } source - the source pixelmap.
622   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
623   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
624   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
625   * @throws { BusinessError } 401 - Input parameter error.
626   * @syscap SystemCapability.Multimedia.Image.Core
627   * @form
628   * @atomicservice
629   * @since 12
630   */
631  /**
632   * Create a color picker to get color of an image.
633   * @param { image.PixelMap } source - the source pixelmap.
634   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
635   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
636   * @returns { Promise<ColorPicker> } - returns the ColorPicker generated.
637   * @throws { BusinessError } 401 - Input parameter error.
638   * @syscap SystemCapability.Multimedia.Image.Core
639   * @crossplatform
640   * @form
641   * @atomicservice
642   * @since 14
643   */
644  function createColorPicker(source: image.PixelMap, region: Array<number>): Promise<ColorPicker>;
645
646  /**
647   * Create a color picker to get color of an image.
648   * @param { image.PixelMap } source - the source pixelmap.
649   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
650   * @throws { BusinessError } 401 - Input parameter error.
651   * @syscap SystemCapability.Multimedia.Image.Core
652   * @since 9
653   */
654  /**
655   * Create a color picker to get color of an image.
656   * @param { image.PixelMap } source - the source pixelmap.
657   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
658   * @throws { BusinessError } 401 - Input parameter error.
659   * @syscap SystemCapability.Multimedia.Image.Core
660   * @form
661   * @atomicservice
662   * @since 12
663   */
664  /**
665   * Create a color picker to get color of an image.
666   * @param { image.PixelMap } source - the source pixelmap.
667   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
668   * @throws { BusinessError } 401 - Input parameter error.
669   * @syscap SystemCapability.Multimedia.Image.Core
670   * @crossplatform
671   * @form
672   * @atomicservice
673   * @since 14
674   */
675  function createColorPicker(source: image.PixelMap, callback: AsyncCallback<ColorPicker>): void;
676  
677  /**
678   * Create a color picker to get color of an image.
679   * @param { image.PixelMap } source - the source pixelmap.
680   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
681   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
682   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
683   * @throws { BusinessError } 401 - Input parameter error.
684   * @syscap SystemCapability.Multimedia.Image.Core
685   * @since 10
686   */
687  /**
688   * Create a color picker to get color of an image.
689   * @param { image.PixelMap } source - the source pixelmap.
690   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
691   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
692   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
693   * @throws { BusinessError } 401 - Input parameter error.
694   * @syscap SystemCapability.Multimedia.Image.Core
695   * @form
696   * @atomicservice
697   * @since 12
698   */
699  /**
700   * Create a color picker to get color of an image.
701   * @param { image.PixelMap } source - the source pixelmap.
702   * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates,
703   * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap.
704   * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker.
705   * @throws { BusinessError } 401 - Input parameter error.
706   * @syscap SystemCapability.Multimedia.Image.Core
707   * @crossplatform
708   * @form
709   * @atomicservice
710   * @since 14
711   */
712  function createColorPicker(source: image.PixelMap, region: Array<number>, callback: AsyncCallback<ColorPicker>): void;
713}
714
715export default effectKit;
716