• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 * Use the DrawableDescriptor class to get drawable image.
18 *
19 * @syscap SystemCapability.ArkUI.ArkUI.Full
20 * @since 10
21 */
22declare type DrawableDescriptor = import ('../api/@ohos.arkui.drawableDescriptor').DrawableDescriptor;
23
24/**
25 * @enum { number }
26 * @syscap SystemCapability.ArkUI.ArkUI.Full
27 * @since 7
28 */
29/**
30 * @enum { number }
31 * @syscap SystemCapability.ArkUI.ArkUI.Full
32 * @since 9
33 * @form
34 */
35/**
36 * @enum { number }
37 * @syscap SystemCapability.ArkUI.ArkUI.Full
38 * @crossplatform
39 * @since 10
40 * @form
41 */
42declare enum ImageRenderMode {
43  /**
44   * Render according to the original image, including colors.
45   *
46   * @syscap SystemCapability.ArkUI.ArkUI.Full
47   * @since 7
48   */
49  /**
50   * Render according to the original image, including colors.
51   *
52   * @syscap SystemCapability.ArkUI.ArkUI.Full
53   * @since 9
54   * @form
55   */
56  /**
57   * Render according to the original image, including colors.
58   *
59   * @syscap SystemCapability.ArkUI.ArkUI.Full
60   * @crossplatform
61   * @since 10
62   * @form
63   */
64  Original,
65
66  /**
67   * Render the image as a template image, ignoring the color information of the image.
68   *
69   * @syscap SystemCapability.ArkUI.ArkUI.Full
70   * @since 7
71   */
72  /**
73   * Render the image as a template image, ignoring the color information of the image.
74   *
75   * @syscap SystemCapability.ArkUI.ArkUI.Full
76   * @since 9
77   * @form
78   */
79  /**
80   * Render the image as a template image, ignoring the color information of the image.
81   *
82   * @syscap SystemCapability.ArkUI.ArkUI.Full
83   * @crossplatform
84   * @since 10
85   * @form
86   */
87  Template,
88}
89
90/**
91 * @enum { number }
92 * @syscap SystemCapability.ArkUI.ArkUI.Full
93 * @since 7
94 */
95/**
96 * @enum { number }
97 * @syscap SystemCapability.ArkUI.ArkUI.Full
98 * @since 9
99 * @form
100 */
101/**
102 * @enum { number }
103 * @syscap SystemCapability.ArkUI.ArkUI.Full
104 * @crossplatform
105 * @since 10
106 * @form
107 */
108declare enum ImageInterpolation {
109  /**
110   * Do not use interpolated image data.
111   *
112   * @syscap SystemCapability.ArkUI.ArkUI.Full
113   * @since 7
114   */
115  /**
116   * Do not use interpolated image data.
117   *
118   * @syscap SystemCapability.ArkUI.ArkUI.Full
119   * @since 9
120   * @form
121   */
122  /**
123   * Do not use interpolated image data.
124   *
125   * @syscap SystemCapability.ArkUI.ArkUI.Full
126   * @crossplatform
127   * @since 10
128   * @form
129   */
130  None,
131
132  /**
133   * Low usage of interpolated image data.
134   *
135   * @syscap SystemCapability.ArkUI.ArkUI.Full
136   * @since 7
137   */
138  /**
139   * Low usage of interpolated image data.
140   *
141   * @syscap SystemCapability.ArkUI.ArkUI.Full
142   * @since 9
143   * @form
144   */
145  /**
146   * Low usage of interpolated image data.
147   *
148   * @syscap SystemCapability.ArkUI.ArkUI.Full
149   * @crossplatform
150   * @since 10
151   * @form
152   */
153  Low,
154
155  /**
156   * Interpolated image data is used moderately.
157   *
158   * @syscap SystemCapability.ArkUI.ArkUI.Full
159   * @since 7
160   */
161  /**
162   * Interpolated image data is used moderately.
163   *
164   * @syscap SystemCapability.ArkUI.ArkUI.Full
165   * @since 9
166   * @form
167   */
168  /**
169   * Interpolated image data is used moderately.
170   *
171   * @syscap SystemCapability.ArkUI.ArkUI.Full
172   * @crossplatform
173   * @since 10
174   * @form
175   */
176  Medium,
177
178  /**
179   * High usage of interpolated image data may affect the speed of image rendering.
180   *
181   * @syscap SystemCapability.ArkUI.ArkUI.Full
182   * @since 7
183   */
184  /**
185   * High usage of interpolated image data may affect the speed of image rendering.
186   *
187   * @syscap SystemCapability.ArkUI.ArkUI.Full
188   * @since 9
189   * @form
190   */
191  /**
192   * High usage of interpolated image data may affect the speed of image rendering.
193   *
194   * @syscap SystemCapability.ArkUI.ArkUI.Full
195   * @crossplatform
196   * @since 10
197   * @form
198   */
199  High,
200}
201
202/**
203 * @interface ImageInterface
204 * @syscap SystemCapability.ArkUI.ArkUI.Full
205 * @since 7
206 */
207/**
208 * @interface ImageInterface
209 * @syscap SystemCapability.ArkUI.ArkUI.Full
210 * @since 9
211 * @form
212 */
213/**
214 * @interface ImageInterface
215 * @syscap SystemCapability.ArkUI.ArkUI.Full
216 * @crossplatform
217 * @since 10
218 * @form
219 */
220interface ImageInterface {
221  /**
222   * Set src to obtain images.
223   *
224   * @param { PixelMap | ResourceStr | DrawableDescriptor } src
225   * @returns { ImageAttribute }
226   * @syscap SystemCapability.ArkUI.ArkUI.Full
227   * @since 7
228   */
229  /**
230   * Set src to obtain images
231   *
232   * @param { PixelMap | ResourceStr | DrawableDescriptor } src
233   * @returns { ImageAttribute }
234   * @syscap SystemCapability.ArkUI.ArkUI.Full
235   * @since 9
236   * @form
237   */
238  /**
239   * Set src to obtain images
240   *
241   * @param { PixelMap | ResourceStr | DrawableDescriptor } src
242   * @returns { ImageAttribute }
243   * @syscap SystemCapability.ArkUI.ArkUI.Full
244   * @crossplatform
245   * @since 10
246   * @form
247   */
248  (src: PixelMap | ResourceStr | DrawableDescriptor): ImageAttribute;
249}
250
251/**
252 * @extends CommonMethod<ImageAttribute>
253 * @syscap SystemCapability.ArkUI.ArkUI.Full
254 * @since 7
255 */
256/**
257 * @extends CommonMethod<ImageAttribute>
258 * @syscap SystemCapability.ArkUI.ArkUI.Full
259 * @since 9
260 * @form
261 */
262/**
263 * @extends CommonMethod<ImageAttribute>
264 * @syscap SystemCapability.ArkUI.ArkUI.Full
265 * @crossplatform
266 * @since 10
267 * @form
268 */
269declare class ImageAttribute extends CommonMethod<ImageAttribute> {
270  /**
271   * Placeholder displayed on load
272   *
273   * @param { string | Resource } value
274   * @returns { ImageAttribute }
275   * @syscap SystemCapability.ArkUI.ArkUI.Full
276   * @since 7
277   */
278  /**
279   * Placeholder displayed on load
280   *
281   * @param { string | Resource } value
282   * @returns { ImageAttribute }
283   * @syscap SystemCapability.ArkUI.ArkUI.Full
284   * @since 9
285   * @form
286   */
287  /**
288   * Placeholder displayed on load
289   *
290   * @param { string | Resource } value
291   * @returns { ImageAttribute }
292   * @syscap SystemCapability.ArkUI.ArkUI.Full
293   * @crossplatform
294   * @since 10
295   * @form
296   */
297  alt(value: string | Resource): ImageAttribute;
298
299  /**
300   * match Text Direction
301   *
302   * @param { boolean } value
303   * @returns { ImageAttribute }
304   * @syscap SystemCapability.ArkUI.ArkUI.Full
305   * @since 7
306   */
307  /**
308   * match Text Direction
309   *
310   * @param { boolean } value
311   * @returns { ImageAttribute }
312   * @syscap SystemCapability.ArkUI.ArkUI.Full
313   * @since 9
314   * @form
315   */
316  /**
317   * match Text Direction
318   *
319   * @param { boolean } value
320   * @returns { ImageAttribute }
321   * @syscap SystemCapability.ArkUI.ArkUI.Full
322   * @crossplatform
323   * @since 10
324   * @form
325   */
326  matchTextDirection(value: boolean): ImageAttribute;
327
328  /**
329   * Indicates whether the image follows the text direction.
330   *
331   * @param { boolean } value
332   * @returns { ImageAttribute }
333   * @syscap SystemCapability.ArkUI.ArkUI.Full
334   * @since 7
335   */
336  /**
337   * Indicates whether the image follows the text direction.
338   *
339   * @param { boolean } value
340   * @returns { ImageAttribute }
341   * @syscap SystemCapability.ArkUI.ArkUI.Full
342   * @since 9
343   * @form
344   */
345  /**
346   * Indicates whether the image follows the text direction.
347   *
348   * @param { boolean } value
349   * @returns { ImageAttribute }
350   * @syscap SystemCapability.ArkUI.ArkUI.Full
351   * @crossplatform
352   * @since 10
353   * @form
354   */
355  fitOriginalSize(value: boolean): ImageAttribute;
356
357  /**
358   * fill Color
359   *
360   * @param { ResourceColor } value
361   * @returns { ImageAttribute }
362   * @syscap SystemCapability.ArkUI.ArkUI.Full
363   * @since 7
364   */
365  /**
366   * fill Color
367   *
368   * @param { ResourceColor } value
369   * @returns { ImageAttribute }
370   * @syscap SystemCapability.ArkUI.ArkUI.Full
371   * @since 9
372   * @form
373   */
374  /**
375   * fill Color
376   *
377   * @param { ResourceColor } value
378   * @returns { ImageAttribute }
379   * @syscap SystemCapability.ArkUI.ArkUI.Full
380   * @crossplatform
381   * @since 10
382   * @form
383   */
384  fillColor(value: ResourceColor): ImageAttribute;
385
386  /**
387   * Sets the zoom type of an image.
388   *
389   * @param { ImageFit } value
390   * @returns { ImageAttribute }
391   * @syscap SystemCapability.ArkUI.ArkUI.Full
392   * @since 7
393   */
394  /**
395   * Sets the zoom type of an image.
396   *
397   * @param { ImageFit } value
398   * @returns { ImageAttribute }
399   * @syscap SystemCapability.ArkUI.ArkUI.Full
400   * @since 9
401   * @form
402   */
403  /**
404   * Sets the zoom type of an image.
405   *
406   * @param { ImageFit } value
407   * @returns { ImageAttribute }
408   * @syscap SystemCapability.ArkUI.ArkUI.Full
409   * @crossplatform
410   * @since 10
411   * @form
412   */
413  objectFit(value: ImageFit): ImageAttribute;
414
415  /**
416   * Set the repeat style of the picture
417   *
418   * @param { ImageRepeat } value
419   * @returns { ImageAttribute }
420   * @syscap SystemCapability.ArkUI.ArkUI.Full
421   * @since 7
422   */
423  /**
424   * Set the repeat style of the picture
425   *
426   * @param { ImageRepeat } value
427   * @returns { ImageAttribute }
428   * @syscap SystemCapability.ArkUI.ArkUI.Full
429   * @since 9
430   * @form
431   */
432  /**
433   * Set the repeat style of the picture
434   *
435   * @param { ImageRepeat } value
436   * @returns { ImageAttribute }
437   * @syscap SystemCapability.ArkUI.ArkUI.Full
438   * @crossplatform
439   * @since 10
440   * @form
441   */
442  objectRepeat(value: ImageRepeat): ImageAttribute;
443
444  /**
445   * Set the auto style of the picture
446   *
447   * @param { boolean } value
448   * @returns { ImageAttribute }
449   * @syscap SystemCapability.ArkUI.ArkUI.Full
450   * @since 7
451   */
452  /**
453   * Set the auto style of the picture
454   *
455   * @param { boolean } value
456   * @returns { ImageAttribute }
457   * @syscap SystemCapability.ArkUI.ArkUI.Full
458   * @since 9
459   * @form
460   */
461  /**
462   * Set the auto style of the picture
463   *
464   * @param { boolean } value
465   * @returns { ImageAttribute }
466   * @syscap SystemCapability.ArkUI.ArkUI.Full
467   * @crossplatform
468   * @since 10
469   * @form
470   */
471  autoResize(value: boolean): ImageAttribute;
472
473  /**
474   * Sets the image rendering mode.
475   *
476   * @param { ImageRenderMode } value
477   * @returns { ImageAttribute }
478   * @syscap SystemCapability.ArkUI.ArkUI.Full
479   * @since 7
480   */
481  /**
482   * Sets the image rendering mode.
483   *
484   * @param { ImageRenderMode } value
485   * @returns { ImageAttribute }
486   * @syscap SystemCapability.ArkUI.ArkUI.Full
487   * @since 9
488   * @form
489   */
490  /**
491   * Sets the image rendering mode.
492   *
493   * @param { ImageRenderMode } value
494   * @returns { ImageAttribute }
495   * @syscap SystemCapability.ArkUI.ArkUI.Full
496   * @crossplatform
497   * @since 10
498   * @form
499   */
500  renderMode(value: ImageRenderMode): ImageAttribute;
501
502  /**
503   * Sets the interpolation effect of an image. The interpolation effect is only magnified for the image.
504   *
505   * @param { ImageInterpolation } value
506   * @returns { ImageAttribute }
507   * @syscap SystemCapability.ArkUI.ArkUI.Full
508   * @since 7
509   */
510  /**
511   * Sets the interpolation effect of an image. The interpolation effect is only magnified for the image.
512   *
513   * @param { ImageInterpolation } value
514   * @returns { ImageAttribute }
515   * @syscap SystemCapability.ArkUI.ArkUI.Full
516   * @since 9
517   * @form
518   */
519  /**
520   * Sets the interpolation effect of an image. The interpolation effect is only magnified for the image.
521   *
522   * @param { ImageInterpolation } value
523   * @returns { ImageAttribute }
524   * @syscap SystemCapability.ArkUI.ArkUI.Full
525   * @crossplatform
526   * @since 10
527   * @form
528   */
529  interpolation(value: ImageInterpolation): ImageAttribute;
530
531  /**
532   * Specifies the picture decoding size.
533   * The original picture is decoded into a picture of a specified size. The unit of the number type is px.
534   *
535   * @param { object } value
536   * @returns { ImageAttribute }
537   * @syscap SystemCapability.ArkUI.ArkUI.Full
538   * @since 7
539   */
540  /**
541   * Specifies the picture decoding size.
542   * The original picture is decoded into a picture of a specified size. The unit of the number type is px.
543   *
544   * @param { object } value
545   * @returns { ImageAttribute }
546   * @syscap SystemCapability.ArkUI.ArkUI.Full
547   * @since 9
548   * @form
549   */
550  /**
551   * Specifies the picture decoding size.
552   * The original picture is decoded into a picture of a specified size. The unit of the number type is px.
553   *
554   * @param { object } value
555   * @returns { ImageAttribute }
556   * @syscap SystemCapability.ArkUI.ArkUI.Full
557   * @crossplatform
558   * @since 10
559   * @form
560   */
561  sourceSize(value: { width: number; height: number }): ImageAttribute;
562
563  /**
564   * Sets the synchronous or asynchronous mode for image loading.
565   * The default parameter type is bool, and the default value is false.
566   *
567   * @param { boolean } value
568   * @returns { ImageAttribute }
569   * @syscap SystemCapability.ArkUI.ArkUI.Full
570   * @since 8
571   */
572  /**
573   * Sets the synchronous or asynchronous mode for image loading.
574   * The default parameter type is bool, and the default value is false.
575   *
576   * @param { boolean } value
577   * @returns { ImageAttribute }
578   * @syscap SystemCapability.ArkUI.ArkUI.Full
579   * @since 9
580   * @form
581   */
582  /**
583   * Sets the synchronous or asynchronous mode for image loading.
584   * The default parameter type is bool, and the default value is false.
585   *
586   * @param { boolean } value
587   * @returns { ImageAttribute }
588   * @syscap SystemCapability.ArkUI.ArkUI.Full
589   * @crossplatform
590   * @since 10
591   * @form
592   */
593  syncLoad(value: boolean): ImageAttribute;
594
595  /**
596   * Sets the color filter effect on the image.
597   *
598   * @param { ColorFilter } value ColorFilter object.
599   * @returns { ImageAttribute }
600   * @syscap SystemCapability.ArkUI.ArkUI.Full
601   * @since 9
602   * @form
603   */
604  /**
605   * Sets the color filter effect on the image.
606   *
607   * @param { ColorFilter } value ColorFilter object.
608   * @returns { ImageAttribute }
609   * @syscap SystemCapability.ArkUI.ArkUI.Full
610   * @crossplatform
611   * @since 10
612   * @form
613   */
614  colorFilter(value: ColorFilter): ImageAttribute;
615
616  /**
617   * Allow replication.
618   *
619   * @param { CopyOptions } value
620   * @returns { ImageAttribute }
621   * @syscap SystemCapability.ArkUI.ArkUI.Full
622   * @since 9
623   * @form
624   */
625  /**
626   * Allow replication.
627   *
628   * @param { CopyOptions } value
629   * @returns { ImageAttribute }
630   * @syscap SystemCapability.ArkUI.ArkUI.Full
631   * @crossplatform
632   * @since 10
633   * @form
634   */
635  copyOption(value: CopyOptions): ImageAttribute;
636
637  /**
638   * Enable image dragging.
639   * Default value is false.
640   *
641   * @param { boolean } value
642   * @returns { ImageAttribute }
643   * @syscap SystemCapability.ArkUI.ArkUI.Full
644   * @since 9
645   * @form
646   */
647  draggable(value: boolean): ImageAttribute;
648
649  /**
650   * This callback is triggered when an image is successfully loaded.
651   * The size of the image source that is successfully loaded is returned, in pixels.
652   *
653   * @param { function } callback
654   * @returns { ImageAttribute }
655   * @syscap SystemCapability.ArkUI.ArkUI.Full
656   * @since 7
657   */
658  /**
659   * This callback is triggered when an image is successfully loaded.
660   * The size of the image source that is successfully loaded is returned, in pixels.
661   *
662   * @param { function } callback
663   * @returns { ImageAttribute }
664   * @syscap SystemCapability.ArkUI.ArkUI.Full
665   * @since 9
666   * @form
667   */
668  /**
669   * This callback is triggered when an image is successfully loaded.
670   * The size of the image source that is successfully loaded is returned, in pixels.
671   *
672   * @param { function } callback
673   * @returns { ImageAttribute }
674   * @syscap SystemCapability.ArkUI.ArkUI.Full
675   * @crossplatform
676   * @since 10
677   * @form
678   */
679  onComplete(
680    callback: (event?: {
681      width: number;
682      height: number;
683      componentWidth: number;
684      componentHeight: number;
685      loadingStatus: number;
686      contentWidth: number;
687      contentHeight: number;
688      contentOffsetX: number;
689      contentOffsetY: number;
690    }) => void,
691  ): ImageAttribute;
692
693  /**
694   * This callback is triggered when an exception occurs during image loading.
695   *
696   * @param { function } callback
697   * @returns { ImageAttribute }
698   * @syscap SystemCapability.ArkUI.ArkUI.Full
699   * @since 7
700   */
701  /**
702   * This callback is triggered when an exception occurs during image loading.
703   *
704   * @param { function } callback
705   * @returns { ImageAttribute }
706   * @syscap SystemCapability.ArkUI.ArkUI.Full
707   * @since 9
708   * @form
709   */
710  /**
711   * This callback is triggered when an exception occurs during image loading.
712   *
713   * @param { function } callback
714   * @returns { ImageAttribute }
715   * @syscap SystemCapability.ArkUI.ArkUI.Full
716   * @crossplatform
717   * @since 10
718   * @form
719   */
720  onError(callback: (event: {
721    /**
722     * Component width.
723     *
724     * @type { number }
725     * @syscap SystemCapability.ArkUI.ArkUI.Full
726     * @crossplatform
727     * @since 10
728     * @form
729     */
730    componentWidth: number;
731
732    /**
733     * Component height.
734     *
735     * @type { number }
736     * @syscap SystemCapability.ArkUI.ArkUI.Full
737     * @crossplatform
738     * @since 10
739     * @form
740     */
741    componentHeight: number
742  }) => void): ImageAttribute;
743
744  /**
745   * This callback is triggered when an exception occurs during image loading.
746   * The field of "message" carries the detailed information of failed image loading.
747   *
748   * @param { function } callback
749   * @returns { ImageAttribute }
750   * @syscap SystemCapability.ArkUI.ArkUI.Full
751   * @since 9
752   * @form
753   */
754  /**
755   * This callback is triggered when an exception occurs during image loading.
756   * The field of "message" carries the detailed information of failed image loading.
757   *
758   * @param { function } callback
759   * @returns { ImageAttribute }
760   * @syscap SystemCapability.ArkUI.ArkUI.Full
761   * @crossplatform
762   * @since 10
763   * @form
764   */
765  onError(callback: (event: {
766    /**
767     * Component width.
768     *
769     * @type { number }
770     * @syscap SystemCapability.ArkUI.ArkUI.Full
771     * @crossplatform
772     * @since 10
773     * @form
774     */
775    componentWidth: number;
776
777    /**
778     * Component height.
779     *
780     * @type { number }
781     * @syscap SystemCapability.ArkUI.ArkUI.Full
782     * @crossplatform
783     * @since 10
784     * @form
785     */
786    componentHeight: number;
787
788    /**
789     * Message.
790     *
791     * @type { string }
792     * @syscap SystemCapability.ArkUI.ArkUI.Full
793     * @crossplatform
794     * @since 10
795     * @form
796     */
797    message: string
798  }) => void): ImageAttribute;
799
800  /**
801   * When the loaded source file is a svg image, this callback is triggered when the playback of the svg image is complete.
802   * If the svg image is a wireless loop image, this callback is not triggered.
803   *
804   * @param { function } event
805   * @returns { ImageAttribute }
806   * @syscap SystemCapability.ArkUI.ArkUI.Full
807   * @since 7
808   */
809  /**
810   * When the loaded source file is a svg image, this callback is triggered when the playback of the svg image is complete.
811   * If the svg image is a wireless loop image, this callback is not triggered.
812   *
813   * @param { function } event
814   * @returns { ImageAttribute }
815   * @syscap SystemCapability.ArkUI.ArkUI.Full
816   * @since 9
817   * @form
818   */
819  /**
820   * When the loaded source file is a svg image, this callback is triggered when the playback of the svg image is complete.
821   * If the svg image is a wireless loop image, this callback is not triggered.
822   *
823   * @param { function } event
824   * @returns { ImageAttribute }
825   * @syscap SystemCapability.ArkUI.ArkUI.Full
826   * @crossplatform
827   * @since 10
828   * @form
829   */
830  onFinish(event: () => void): ImageAttribute;
831}
832
833/**
834 * Defines Image Component.
835 *
836 * @syscap SystemCapability.ArkUI.ArkUI.Full
837 * @since 7
838 */
839/**
840 * Defines Image Component.
841 *
842 * @syscap SystemCapability.ArkUI.ArkUI.Full
843 * @since 9
844 * @form
845 */
846/**
847 * Defines Image Component.
848 *
849 * @syscap SystemCapability.ArkUI.ArkUI.Full
850 * @crossplatform
851 * @since 10
852 * @form
853 */
854declare const Image: ImageInterface;
855
856/**
857 * Defines Image Component instance.
858 *
859 * @syscap SystemCapability.ArkUI.ArkUI.Full
860 * @since 7
861 */
862/**
863 * Defines Image Component instance.
864 *
865 * @syscap SystemCapability.ArkUI.ArkUI.Full
866 * @since 9
867 * @form
868 */
869/**
870 * Defines Image Component instance.
871 *
872 * @syscap SystemCapability.ArkUI.ArkUI.Full
873 * @crossplatform
874 * @since 10
875 * @form
876 */
877declare const ImageInstance: ImageAttribute;
878