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