1/* 2 * Copyright (c) 2021-2023 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 * @since 7 18 */ 19/** 20 * @form 21 * @since 9 22 */ 23declare enum ImageRenderMode { 24 /** 25 * Render according to the original image, including colors. 26 * @since 7 27 */ 28 /** 29 * Render according to the original image, including colors. 30 * @form 31 * @since 9 32 */ 33 Original, 34 35 /** 36 * Render the image as a template image, ignoring the color information of the image. 37 * @since 7 38 */ 39 /** 40 * Render the image as a template image, ignoring the color information of the image. 41 * @form 42 * @since 9 43 */ 44 Template, 45} 46 47/** 48 * @since 7 49 */ 50/** 51 * @form 52 * @since 9 53 */ 54declare enum ImageInterpolation { 55 /** 56 * Do not use interpolated image data. 57 * @since 7 58 */ 59 /** 60 * Do not use interpolated image data. 61 * @form 62 * @since 9 63 */ 64 None, 65 66 /** 67 * Low usage of interpolated image data. 68 * @since 7 69 */ 70 /** 71 * Low usage of interpolated image data. 72 * @form 73 * @since 9 74 */ 75 Low, 76 77 /** 78 * Interpolated image data is used moderately. 79 * @since 7 80 */ 81 /** 82 * Interpolated image data is used moderately. 83 * @form 84 * @since 9 85 */ 86 Medium, 87 88 /** 89 * High usage of interpolated image data may affect the speed of image rendering. 90 * @since 7 91 */ 92 /** 93 * High usage of interpolated image data may affect the speed of image rendering. 94 * @form 95 * @since 9 96 */ 97 High, 98} 99 100 101/** 102 * @since 7 103 */ 104/** 105 * @form 106 * @since 9 107 */ 108interface ImageInterface { 109 /** 110 * Set src to obtain images. 111 * @since 7 112 */ 113 /** 114 * Set src to obtain images 115 * @form 116 * @since 9 117 */ 118 (src: string | PixelMap | Resource): ImageAttribute; 119} 120 121/** 122 * @since 7 123 */ 124/** 125 * @form 126 * @since 9 127 */ 128declare class ImageAttribute extends CommonMethod<ImageAttribute> { 129 /** 130 * Placeholder displayed on load 131 * @since 7 132 */ 133 /** 134 * Placeholder displayed on load 135 * @form 136 * @since 9 137 */ 138 alt(value: string | Resource): ImageAttribute; 139 140 /** 141 * match Text Direction 142 * @since 7 143 */ 144 /** 145 * match Text Direction 146 * @form 147 * @since 9 148 */ 149 matchTextDirection(value: boolean): ImageAttribute; 150 151 /** 152 * Indicates whether the image follows the text direction. 153 * @since 7 154 */ 155 /** 156 * Indicates whether the image follows the text direction. 157 * @form 158 * @since 9 159 */ 160 fitOriginalSize(value: boolean): ImageAttribute; 161 162 /** 163 * fill Color 164 * @since 7 165 */ 166 /** 167 * fill Color 168 * @form 169 * @since 9 170 */ 171 fillColor(value: ResourceColor): ImageAttribute; 172 173 /** 174 * Sets the zoom type of an image. 175 * @since 7 176 */ 177 /** 178 * Sets the zoom type of an image. 179 * @form 180 * @since 9 181 */ 182 objectFit(value: ImageFit): ImageAttribute; 183 184 /** 185 * Set the repeat style of the picture 186 * @since 7 187 */ 188 /** 189 * Set the repeat style of the picture 190 * @form 191 * @since 9 192 */ 193 objectRepeat(value: ImageRepeat): ImageAttribute; 194 195 /** 196 * Set the auto style of the picture 197 * @since 7 198 */ 199 /** 200 * Set the auto style of the picture 201 * @form 202 * @since 9 203 */ 204 autoResize(value: boolean): ImageAttribute; 205 206 /** 207 * Sets the image rendering mode. 208 * @since 7 209 */ 210 /** 211 * Sets the image rendering mode. 212 * @form 213 * @since 9 214 */ 215 renderMode(value: ImageRenderMode): ImageAttribute; 216 217 /** 218 * Sets the interpolation effect of an image. The interpolation effect is only magnified for the image. 219 * @since 7 220 */ 221 /** 222 * Sets the interpolation effect of an image. The interpolation effect is only magnified for the image. 223 * @form 224 * @since 9 225 */ 226 interpolation(value: ImageInterpolation): ImageAttribute; 227 228 /** 229 * Specifies the picture decoding size. 230 * The original picture is decoded into a picture of a specified size. The unit of the number type is px. 231 * @since 7 232 */ 233 /** 234 * Specifies the picture decoding size. 235 * The original picture is decoded into a picture of a specified size. The unit of the number type is px. 236 * @form 237 * @since 9 238 */ 239 sourceSize(value: { width: number; height: number }): ImageAttribute; 240 241 /** 242 * Sets the synchronous or asynchronous mode for image loading. 243 * The default parameter type is bool, and the default value is false. 244 * @since 8 245 */ 246 /** 247 * Sets the synchronous or asynchronous mode for image loading. 248 * The default parameter type is bool, and the default value is false. 249 * @form 250 * @since 9 251 */ 252 syncLoad(value: boolean): ImageAttribute; 253 254 /** 255 * Sets the color filter effect on the image. 256 * @param value ColorFilter object. 257 * @form 258 * @since 9 259 */ 260 colorFilter(value: ColorFilter): ImageAttribute; 261 262 /** 263 * Allow replication. 264 * @form 265 * @since 9 266 */ 267 copyOption(value: CopyOptions): ImageAttribute; 268 269 /** 270 * Enable image dragging. 271 * Default value is false. 272 * @since 9 273 */ 274 draggable(value: boolean): ImageAttribute; 275 276 /** 277 * This callback is triggered when an image is successfully loaded. 278 * The size of the image source that is successfully loaded is returned, in pixels. 279 * @since 7 280 */ 281 /** 282 * This callback is triggered when an image is successfully loaded. 283 * The size of the image source that is successfully loaded is returned, in pixels. 284 * @form 285 * @since 9 286 */ 287 onComplete( 288 callback: (event?: { 289 width: number; 290 height: number; 291 componentWidth: number; 292 componentHeight: number; 293 loadingStatus: number; 294 }) => void, 295 ): ImageAttribute; 296 297 /** 298 * This callback is triggered when an exception occurs during image loading. 299 * @since 7 300 */ 301 /** 302 * This callback is triggered when an exception occurs during image loading. 303 * @form 304 * @since 9 305 */ 306 onError(callback: (event?: { componentWidth: number; componentHeight: number }) => void): ImageAttribute; 307 308 /** 309 * This callback is triggered when an exception occurs during image loading. 310 * The field of "message" carries the detailed information of failed image loading. 311 * @form 312 * @since 9 313 */ 314 onError(callback: (event?: { componentWidth: number; componentHeight: number; message: string }) => void): ImageAttribute; 315 316 /** 317 * When the loaded source file is a svg image, this callback is triggered when the playback of the svg image is complete. 318 * If the svg image is a wireless loop image, this callback is not triggered. 319 * @since 7 320 */ 321 /** 322 * When the loaded source file is a svg image, this callback is triggered when the playback of the svg image is complete. 323 * If the svg image is a wireless loop image, this callback is not triggered. 324 * @form 325 * @since 9 326 */ 327 onFinish(event: () => void): ImageAttribute; 328} 329 330/** 331 * Defines Image Component. 332 * @since 7 333 */ 334/** 335 * Defines Image Component. 336 * @form 337 * @since 9 338 */ 339declare const Image: ImageInterface; 340 341/** 342 * Defines Image Component instance. 343 * @since 7 344 */ 345/** 346 * Defines Image Component instance. 347 * @form 348 * @since 9 349 */ 350declare const ImageInstance: ImageAttribute; 351