• 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
16import type { AsyncCallback } from './@ohos.base';
17import type colorSpaceManager from './@ohos.graphics.colorSpaceManager.d.ts';
18import type rpc from './@ohos.rpc';
19
20/**
21 * @name image
22 * @since 6
23 */
24declare namespace image {
25
26  /**
27   * Enumerates pixel map formats.
28   * @since 7
29   * @syscap SystemCapability.Multimedia.Image.Core
30   */
31  enum PixelMapFormat {
32    /**
33     * Indicates an unknown format.
34     * @since 7
35     * @syscap SystemCapability.Multimedia.Image.Core
36     */
37    UNKNOWN = 0,
38
39    /**
40     * Indicates that each pixel is stored on 16 bits. Only the R, G, and B components are encoded
41     * from the higher-order to the lower-order bits: red is stored with 5 bits of precision,
42     * green is stored with 6 bits of precision, and blue is stored with 5 bits of precision.
43     * @since 7
44     * @syscap SystemCapability.Multimedia.Image.Core
45     */
46    RGB_565 = 2,
47
48    /**
49     * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components:B(8bits), G(8bits), R(8bits), A(8bits)
50     * and are stored from the higher-order to the lower-order bits.
51     * @since 7
52     * @syscap SystemCapability.Multimedia.Image.Core
53     */
54    RGBA_8888 = 3,
55
56    /**
57     * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components:B(8bits), G(8bits), R(8bits), A(8bits)
58     * and are stored from the higher-order to the lower-order bits.
59     * @since 9
60     * @syscap SystemCapability.Multimedia.Image.Core
61     */
62    BGRA_8888 = 4,
63
64    /**
65     * Indicates that each pixel is stored on 24 bits. Each pixel contains 3 components:R(8bits), G(8bits), B(8bits)
66     * and are stored from the higher-order to the lower-order bits.
67     * @since 9
68     * @syscap SystemCapability.Multimedia.Image.Core
69     */
70    RGB_888 = 5,
71
72    /**
73     * Indicates that each pixel is stored on 8 bits. Each pixel contains 1 component:ALPHA(8bits)
74     * and is stored from the higher-order to the lower-order bits.
75     * @since 9
76     * @syscap SystemCapability.Multimedia.Image.Core
77     */
78    ALPHA_8 = 6,
79
80    /**
81     * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components:B(8bits), G(8bits), R(8bits), A(8bits)
82     * and are stored from the higher-order to the lower-order bits in F16.
83     * @since 9
84     * @syscap SystemCapability.Multimedia.Image.Core
85     */
86    RGBA_F16 = 7,
87
88    /**
89     * Indicates that the storage order is to store Y first and then V U alternately each occupies 8 bits
90     * and are stored from the higher-order to the lower-order bits.
91     * @since 9
92     * @syscap SystemCapability.Multimedia.Image.Core
93     */
94    NV21 = 8,
95
96    /**
97     * Indicates that the storage order is to store Y first and then U V alternately each occupies 8 bits
98     * and are stored from the higher-order to the lower-order bits.
99     * @since 9
100     * @syscap SystemCapability.Multimedia.Image.Core
101     */
102    NV12 = 9,
103  }
104
105  /**
106   * Describes the size of an image.
107   * @since 6
108   * @syscap SystemCapability.Multimedia.Image.Core
109   */
110  interface Size {
111    /**
112     * Height
113     * @since 6
114     * @syscap SystemCapability.Multimedia.Image.Core
115     */
116    height: number;
117
118    /**
119     * Width
120     * @since 6
121     * @syscap SystemCapability.Multimedia.Image.Core
122     */
123    width: number;
124  }
125
126  /**
127   * Enumerates exchangeable image file format (Exif) information types of an image.
128   * @since 7
129   * @syscap SystemCapability.Multimedia.Image.Core
130   */
131  enum PropertyKey {
132    /**
133     * Number of bits in each pixel of an image.
134     * @since 7
135     * @syscap SystemCapability.Multimedia.Image.Core
136     */
137    BITS_PER_SAMPLE = 'BitsPerSample',
138
139    /**
140     * Image rotation mode.
141     * @since 7
142     * @syscap SystemCapability.Multimedia.Image.Core
143     */
144    ORIENTATION = 'Orientation',
145
146    /**
147     * Image length.
148     * @since 7
149     * @syscap SystemCapability.Multimedia.Image.Core
150     */
151    IMAGE_LENGTH = 'ImageLength',
152
153    /**
154     * Image width.
155     * @since 7
156     * @syscap SystemCapability.Multimedia.Image.Core
157     */
158    IMAGE_WIDTH = 'ImageWidth',
159
160    /**
161     * GPS latitude.
162     * @since 7
163     * @syscap SystemCapability.Multimedia.Image.Core
164     */
165    GPS_LATITUDE = 'GPSLatitude',
166
167    /**
168     * GPS longitude.
169     * @since 7
170     * @syscap SystemCapability.Multimedia.Image.Core
171     */
172    GPS_LONGITUDE = 'GPSLongitude',
173
174    /**
175     * GPS latitude reference. For example, N indicates north latitude and S indicates south latitude.
176     * @since 7
177     * @syscap SystemCapability.Multimedia.Image.Core
178     */
179    GPS_LATITUDE_REF = 'GPSLatitudeRef',
180
181    /**
182     * GPS longitude reference. For example, E indicates east longitude and W indicates west longitude.
183     * @since 7
184     * @syscap SystemCapability.Multimedia.Image.Core
185     */
186    GPS_LONGITUDE_REF = 'GPSLongitudeRef',
187
188    /**
189     * Shooting time
190     * @since 9
191     * @syscap SystemCapability.Multimedia.Image.Core
192     */
193    DATE_TIME_ORIGINAL = 'DateTimeOriginal',
194
195    /**
196     * Exposure time
197     * @since 9
198     * @syscap SystemCapability.Multimedia.Image.Core
199     */
200    EXPOSURE_TIME = 'ExposureTime',
201
202    /**
203     * Scene type
204     * @since 9
205     * @syscap SystemCapability.Multimedia.Image.Core
206     */
207    SCENE_TYPE = 'SceneType',
208
209    /**
210     * ISO speedratings
211     * @since 9
212     * @syscap SystemCapability.Multimedia.Image.Core
213     */
214    ISO_SPEED_RATINGS = 'ISOSpeedRatings',
215
216    /**
217     * Aperture value
218     * @since 9
219     * @syscap SystemCapability.Multimedia.Image.Core
220     */
221    F_NUMBER = 'FNumber',
222
223    /**
224     * Date time
225     *
226     * @syscap SystemCapability.Multimedia.Image.Core
227     * @since 10
228     */
229    DATE_TIME = 'DateTime',
230
231     /**
232      * GPS time stamp
233      *
234      * @syscap SystemCapability.Multimedia.Image.Core
235      * @since 10
236      */
237    GPS_TIME_STAMP = 'GPSTimeStamp',
238
239     /**
240      * GPS date stamp
241      *
242      * @syscap SystemCapability.Multimedia.Image.Core
243      * @since 10
244      */
245    GPS_DATE_STAMP = 'GPSDateStamp',
246
247     /**
248      * Image description
249      *
250      * @syscap SystemCapability.Multimedia.Image.Core
251      * @since 10
252      */
253    IMAGE_DESCRIPTION = 'ImageDescription',
254
255     /**
256      * Make
257      *
258      * @syscap SystemCapability.Multimedia.Image.Core
259      * @since 10
260      */
261    MAKE = 'Make',
262
263     /**
264      * Model
265      *
266      * @syscap SystemCapability.Multimedia.Image.Core
267      * @since 10
268      */
269    MODEL = 'Model',
270
271     /**
272      * Photo mode
273      *
274      * @syscap SystemCapability.Multimedia.Image.Core
275      * @since 10
276      */
277    PHOTO_MODE = 'PhotoMode',
278
279     /**
280      * Sensitivity type
281      *
282      * @syscap SystemCapability.Multimedia.Image.Core
283      * @since 10
284      */
285    SENSITIVITY_TYPE = 'SensitivityType',
286
287     /**
288      * Standard output sensitivity
289      *
290      * @syscap SystemCapability.Multimedia.Image.Core
291      * @since 10
292      */
293    STANDARD_OUTPUT_SENSITIVITY = 'StandardOutputSensitivity',
294
295     /**
296      * Recommended exposure index
297      *
298      * @syscap SystemCapability.Multimedia.Image.Core
299      * @since 10
300      */
301    RECOMMENDED_EXPOSURE_INDEX = 'RecommendedExposureIndex',
302
303     /**
304      * ISO speed
305      *
306      * @syscap SystemCapability.Multimedia.Image.Core
307      * @since 10
308      */
309    ISO_SPEED = 'ISOSpeedRatings',
310
311     /**
312      * Aperture value
313      *
314      * @syscap SystemCapability.Multimedia.Image.Core
315      * @since 10
316      */
317    APERTURE_VALUE = 'ApertureValue',
318
319     /**
320      * Exposure bias value
321      *
322      * @syscap SystemCapability.Multimedia.Image.Core
323      * @since 10
324      */
325    EXPOSURE_BIAS_VALUE = 'ExposureBiasValue',
326
327     /**
328      * Metering mode
329      *
330      * @syscap SystemCapability.Multimedia.Image.Core
331      * @since 10
332      */
333    METERING_MODE = 'MeteringMode',
334
335     /**
336      * Light source
337      *
338      * @syscap SystemCapability.Multimedia.Image.Core
339      * @since 10
340      */
341    LIGHT_SOURCE = 'LightSource',
342
343     /**
344      * Flash
345      *
346      * @syscap SystemCapability.Multimedia.Image.Core
347      * @since 10
348      */
349    FLASH = 'Flash',
350
351     /**
352      * Focal length
353      *
354      * @syscap SystemCapability.Multimedia.Image.Core
355      * @since 10
356      */
357    FOCAL_LENGTH = 'FocalLength',
358
359     /**
360      * User comment
361      *
362      * @syscap SystemCapability.Multimedia.Image.Core
363      * @since 10
364      */
365    USER_COMMENT = 'UserComment',
366
367     /**
368      * Pixel x dimension
369      *
370      * @syscap SystemCapability.Multimedia.Image.Core
371      * @since 10
372      */
373    PIXEL_X_DIMENSION = 'PixelXDimension',
374
375     /**
376      * Pixel y dimension
377      *
378      * @syscap SystemCapability.Multimedia.Image.Core
379      * @since 10
380      */
381    PIXEL_Y_DIMENSION = 'PixelYDimension',
382
383     /**
384      * White balance
385      *
386      * @syscap SystemCapability.Multimedia.Image.Core
387      * @since 10
388      */
389    WHITE_BALANCE = 'WhiteBalance',
390
391     /**
392      * Focal length in 35mm film
393      *
394      * @syscap SystemCapability.Multimedia.Image.Core
395      * @since 10
396      */
397    FOCAL_LENGTH_IN_35_MM_FILM = 'FocalLengthIn35mmFilm',
398
399     /**
400      * Capture mode
401      *
402      * @syscap SystemCapability.Multimedia.Image.Core
403      * @since 10
404      */
405    CAPTURE_MODE = 'HwMnoteCaptureMode',
406
407     /**
408      * Physical aperture
409      *
410      * @syscap SystemCapability.Multimedia.Image.Core
411      * @since 10
412      */
413    PHYSICAL_APERTURE = 'HwMnotePhysicalAperture'
414  }
415
416  /**
417   * Enum for image formats.
418   * @since 9
419   * @syscap SystemCapability.Multimedia.Image.Core
420   */
421  enum ImageFormat {
422    /**
423     * YCBCR422 semi-planar format.
424     * @since 9
425     * @syscap SystemCapability.Multimedia.Image.Core
426     */
427    YCBCR_422_SP = 1000,
428
429    /**
430     * JPEG encoding format.
431     * @since 9
432     * @syscap SystemCapability.Multimedia.Image.Core
433     */
434    JPEG = 2000
435  }
436
437  /**
438   * Enumerates alpha types.
439   * @since 9
440   * @syscap SystemCapability.Multimedia.Image.Core
441   */
442  enum AlphaType {
443    /**
444     * Indicates an unknown alpha type.
445     * @since 9
446     * @syscap SystemCapability.Multimedia.Image.Core
447     */
448    UNKNOWN = 0,
449
450    /**
451     * Indicates that the image has no alpha channel, or all pixels in the image are fully opaque.
452     * @since 9
453     * @syscap SystemCapability.Multimedia.Image.Core
454     */
455    OPAQUE = 1,
456
457    /**
458     * Indicates that RGB components of each pixel in the image are premultiplied by alpha.
459     * @since 9
460     * @syscap SystemCapability.Multimedia.Image.Core
461     */
462    PREMUL = 2,
463
464    /**
465     * Indicates that RGB components of each pixel in the image are independent of alpha and are not premultiplied by alpha.
466     * @since 9
467     * @syscap SystemCapability.Multimedia.Image.Core
468     */
469    UNPREMUL = 3
470  }
471
472  /**
473   * Enum for image scale mode.
474   * @since 9
475   * @syscap SystemCapability.Multimedia.Image.Core
476   */
477  enum ScaleMode {
478    /**
479     * Indicates the effect that fits the image into the target size.
480     * @since 9
481     * @syscap SystemCapability.Multimedia.Image.Core
482     */
483    FIT_TARGET_SIZE = 0,
484
485    /**
486     * Indicates the effect that scales an image to fill the target image area and center-crops the part outside the area.
487     * @since 9
488     * @syscap SystemCapability.Multimedia.Image.Core
489     */
490    CENTER_CROP = 1,
491  }
492
493  /**
494   * The component type of image.
495   * @since 9
496   * @syscap SystemCapability.Multimedia.Image.ImageReceiver
497   */
498  enum ComponentType {
499    /**
500     * Luma info.
501     * @since 9
502     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
503     */
504    YUV_Y = 1,
505
506    /**
507     * Chrominance info.
508     * @since 9
509     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
510     */
511    YUV_U = 2,
512
513    /**
514     * Chroma info.
515     * @since 9
516     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
517     */
518    YUV_V = 3,
519
520    /**
521     * Jpeg type.
522     * @since 9
523     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
524     */
525    JPEG = 4,
526  }
527
528  /**
529   * Describes region information.
530   * @since 8
531   * @syscap SystemCapability.Multimedia.Image.Core
532   */
533  interface Region {
534    /**
535     * Image size.
536     * @since 7
537     * @syscap SystemCapability.Multimedia.Image.Core
538     */
539    size: Size;
540
541    /**
542     * x-coordinate at the upper left corner of the image.
543     * @since 7
544     * @syscap SystemCapability.Multimedia.Image.Core
545     */
546    x: number;
547
548    /**
549     * y-coordinate at the upper left corner of the image.
550     * @since 7
551     * @syscap SystemCapability.Multimedia.Image.Core
552     */
553    y: number;
554  }
555
556  /**
557   * Describes area information in an image.
558   * @since 7
559   * @syscap SystemCapability.Multimedia.Image.Core
560   */
561  interface PositionArea {
562    /**
563     * Image data that will be read or written.
564     * @since 7
565     * @syscap SystemCapability.Multimedia.Image.Core
566     */
567    pixels: ArrayBuffer;
568
569    /**
570     * Offset for data reading.
571     * @since 7
572     * @syscap SystemCapability.Multimedia.Image.Core
573     */
574    offset: number;
575
576    /**
577     * Number of bytes to read.
578     * @since 7
579     * @syscap SystemCapability.Multimedia.Image.Core
580     */
581    stride: number;
582
583    /**
584     * Region to read.
585     * @since 7
586     * @syscap SystemCapability.Multimedia.Image.Core
587     */
588    region: Region;
589  }
590
591  /**
592   * Describes image information.
593   * @since 6
594   * @syscap SystemCapability.Multimedia.Image.Core
595   */
596  interface ImageInfo {
597    /**
598     * Indicates image dimensions specified by a {@link Size} interface.
599     * @since 6
600     * @syscap SystemCapability.Multimedia.Image.Core
601     */
602    size: Size;
603
604    /**
605     * Indicates image default density.
606     * @since 9
607     * @syscap SystemCapability.Multimedia.Image.Core
608     */
609    density: number;
610  }
611
612  /**
613   * Describes the option for image packing.
614   * @since 6
615   * @syscap SystemCapability.Multimedia.Image.ImagePacker
616   */
617  interface PackingOption {
618    /**
619     * Multipurpose Internet Mail Extensions (MIME) format of the target image, for example, image/jpeg.
620     * @since 6
621     * @syscap SystemCapability.Multimedia.Image.ImagePacker
622     */
623    format: string;
624
625    /**
626     * Quality of the target image. The value is an integer ranging from 0 to 100. A larger value indicates better.
627     * @since 6
628     * @syscap SystemCapability.Multimedia.Image.ImagePacker
629     */
630    quality: number;
631
632    /**
633     * BufferSize of the target image.
634     * If this bufferSize is less than or equal to 0, it will be converted to 10MB.
635     * @since 9
636     * @syscap SystemCapability.Multimedia.Image.ImagePacker
637     */
638    bufferSize?: number;
639  }
640
641  /**
642   * Describes image properties.
643   * @since 7
644   * @syscap SystemCapability.Multimedia.Image.ImageSource
645   */
646  interface GetImagePropertyOptions {
647    /**
648     * Index of an image.
649     * @since 7
650     * @syscap SystemCapability.Multimedia.Image.ImageSource
651     */
652    index?: number;
653
654    /**
655     * Default property value.
656     * @since 7
657     * @syscap SystemCapability.Multimedia.Image.ImageSource
658     */
659    defaultValue?: string;
660  }
661
662  /**
663   * Describes image decoding parameters.
664   * @since 7
665   * @syscap SystemCapability.Multimedia.Image.ImageSource
666   */
667  interface DecodingOptions {
668    /**
669     * Number of image frames.
670     * @since 7
671     * @syscap SystemCapability.Multimedia.Image.ImageSource
672     */
673    index?: number;
674
675    /**
676     * Sampling ratio of the image pixel map.
677     * @since 7
678     * @syscap SystemCapability.Multimedia.Image.ImageSource
679     */
680    sampleSize?: number;
681
682    /**
683     * Rotation angle of the image pixel map. The value ranges from 0 to 360.
684     * @since 7
685     * @syscap SystemCapability.Multimedia.Image.ImageSource
686     */
687    rotate?: number;
688
689    /**
690     * Whether the image pixel map is editable.
691     * @since 7
692     * @syscap SystemCapability.Multimedia.Image.ImageSource
693     */
694    editable?: boolean;
695
696    /**
697     * Width and height of the image pixel map. The value (0, 0) indicates that the pixels are decoded
698     * based on the original image size.
699     * @since 7
700     * @syscap SystemCapability.Multimedia.Image.ImageSource
701     */
702    desiredSize?: Size;
703
704    /**
705     * Cropping region of the image pixel map.
706     * @since 7
707     * @syscap SystemCapability.Multimedia.Image.ImageSource
708     */
709    desiredRegion?: Region;
710
711    /**
712     * Data format of the image pixel map.
713     * @since 7
714     * @syscap SystemCapability.Multimedia.Image.ImageSource
715     */
716    desiredPixelFormat?: PixelMapFormat;
717
718    /**
719     * The density for image pixel map.
720     * @since 9
721     * @syscap SystemCapability.Multimedia.Image.ImageSource
722     */
723    fitDensity?: number;
724  }
725
726  /**
727   * Describes image color components.
728   * @since 9
729   * @syscap SystemCapability.Multimedia.Image.Core
730   */
731  interface Component {
732    /**
733     * Component type.
734     * @since 9
735     * @syscap SystemCapability.Multimedia.Image.Core
736     */
737    readonly componentType: ComponentType;
738
739    /**
740     * Row stride.
741     * @since 9
742     * @syscap SystemCapability.Multimedia.Image.Core
743     */
744    readonly rowStride: number;
745
746    /**
747     * Pixel stride.
748     * @since 9
749     * @syscap SystemCapability.Multimedia.Image.Core
750     */
751    readonly pixelStride: number;
752
753    /**
754     * Component buffer.
755     * @since 9
756     * @syscap SystemCapability.Multimedia.Image.Core
757     */
758    readonly byteBuffer: ArrayBuffer;
759  }
760
761  /**
762   * Initialization options for pixelmap.
763   * @since 8
764   * @syscap SystemCapability.Multimedia.Image.Core
765   */
766  interface InitializationOptions {
767    /**
768     * PixelMap size.
769     * @since 8
770     * @syscap SystemCapability.Multimedia.Image.Core
771     */
772    size: Size;
773
774    /**
775     * PixelMap expected format.
776     * @since 8
777     * @syscap SystemCapability.Multimedia.Image.Core
778     */
779    pixelFormat?: PixelMapFormat;
780
781    /**
782     * Editable or not.
783     * @since 8
784     * @syscap SystemCapability.Multimedia.Image.Core
785     */
786    editable?: boolean;
787
788    /**
789     * PixelMap expected alpha type.
790     * @since 9
791     * @syscap SystemCapability.Multimedia.Image.Core
792     */
793    alphaType?: AlphaType;
794
795    /**
796     * PixelMap expected scaling effect.
797     * @since 9
798     * @syscap SystemCapability.Multimedia.Image.Core
799     */
800    scaleMode?: ScaleMode;
801  }
802
803  /**
804   * Initialization options for ImageSource.
805   * @since 9
806   * @syscap SystemCapability.Multimedia.Image.Core
807   */
808  interface SourceOptions {
809    /**
810     * The density for ImageSource.
811     * @since 9
812     * @syscap SystemCapability.Multimedia.Image.Core
813     */
814    sourceDensity: number;
815
816    /**
817     * PixelMap expected format.
818     * @since 9
819     * @syscap SystemCapability.Multimedia.Image.Core
820     */
821    sourcePixelFormat?: PixelMapFormat;
822
823    /**
824     * PixelMap size.
825     * @since 9
826     * @syscap SystemCapability.Multimedia.Image.Core
827     */
828    sourceSize?: Size;
829  }
830
831  /**
832   * Create pixelmap by data buffer.
833   * @since 8
834   * @syscap SystemCapability.Multimedia.Image.Core
835   */
836  function createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: AsyncCallback<PixelMap>): void;
837
838  /**
839   * Create pixelmap by data buffer.
840   * @since 8
841   * @syscap SystemCapability.Multimedia.Image.Core
842   */
843  function createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise<PixelMap>;
844
845  /**
846   * Creates an ImageSource instance based on the URI.
847   * @since 6
848   * @syscap SystemCapability.Multimedia.Image.ImageSource
849   * @param uri Image source URI.
850   * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise.
851   */
852  function createImageSource(uri: string): ImageSource;
853
854  /**
855   * Creates an ImageSource instance based on the URI.
856   * @since 9
857   * @syscap SystemCapability.Multimedia.Image.ImageSource
858   * @param uri Image source URI.
859   * @param options The config of Image source.
860   * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise.
861   */
862  function createImageSource(uri: string, options: SourceOptions): ImageSource;
863
864  /**
865   * Creates an ImageSource instance based on the file descriptor.
866   * @since 7
867   * @syscap SystemCapability.Multimedia.Image.ImageSource
868   * @param fd ID of a file descriptor.
869   * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise.
870   */
871  function createImageSource(fd: number): ImageSource;
872
873  /**
874   * Creates an ImageSource instance based on the file descriptor.
875   * @since 9
876   * @syscap SystemCapability.Multimedia.Image.ImageSource
877   * @param fd ID of a file descriptor.
878   * @param options The config of Image source.
879   * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise.
880   */
881  function createImageSource(fd: number, options: SourceOptions): ImageSource;
882
883  /**
884   * Creates an ImageSource instance based on the buffer.
885   * @since 9
886   * @syscap SystemCapability.Multimedia.Image.ImageSource
887   * @param buf The buffer of the image.
888   * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise.
889   */
890  function createImageSource(buf: ArrayBuffer): ImageSource;
891
892  /**
893   * Creates an ImageSource instance based on the buffer.
894   * @since 9
895   * @syscap SystemCapability.Multimedia.Image.ImageSource
896   * @param buf The buffer of the image.
897   * @param options The config of Image source.
898   * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise.
899   */
900  function createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource;
901
902  /**
903   * Creates an ImageSource instance based on the buffer in incremental.
904   * @since 9
905   * @syscap SystemCapability.Multimedia.Image.ImageSource
906   * @param buf The buffer of the image.
907   * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise.
908   */
909  function CreateIncrementalSource(buf: ArrayBuffer): ImageSource;
910
911  /**
912   * Creates an ImageSource instance based on the buffer in incremental.
913   * @since 9
914   * @syscap SystemCapability.Multimedia.Image.ImageSource
915   * @param buf The buffer of the image.
916   * @param options The config of source.
917   * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise.
918   */
919  function CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource;
920
921  /**
922   * Creates an ImagePacker instance.
923   * @since 6
924   * @syscap SystemCapability.Multimedia.Image.ImagePacker
925   * @returns Returns the ImagePacker instance if the operation is successful; returns null otherwise.
926   */
927  function createImagePacker(): ImagePacker;
928
929  /**
930   * Creates an ImageReceiver instance.
931   * @since 9
932   * @syscap SystemCapability.Multimedia.Image.ImageReceiver
933   * @param width The default width in pixels of the Images that this receiver will produce.
934   * @param height The default height in pixels of the Images that this receiver will produce.
935   * @param format The format of the Image that this receiver will produce. This must be one of the
936   *            {@link ImageFormat} constants.
937   * @param capacity The maximum number of images the user will want to access simultaneously.
938   * @returns Returns the ImageReceiver instance if the operation is successful; returns null otherwise.
939   */
940  function createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver;
941
942  /**
943   * Creates an ImageCreator instance.
944   * @since 9
945   * @syscap SystemCapability.Multimedia.Image.ImageCreator
946   * @param width The default width in pixels of the Images that this creator will produce.
947   * @param height The default height in pixels of the Images that this creator will produce.
948   * @param format The format of the Image that this creator will produce. This must be one of the
949   *            {@link ImageFormat} constants.
950   * @param capacity The maximum number of images the user will want to access simultaneously.
951   * @returns Returns the ImageCreator instance if the operation is successful; returns null otherwise.
952   */
953  function createImageCreator(width: number, height: number, format: number, capacity: number): ImageCreator;
954
955  /**
956   * PixelMap instance.
957   * @since 7
958   * @syscap SystemCapability.Multimedia.Image.Core
959   */
960  interface PixelMap {
961    /**
962     * Whether the image pixel map can be edited.
963     * @since 7
964     * @syscap SystemCapability.Multimedia.Image.Core
965     */
966    readonly isEditable: boolean;
967
968    /**
969     * Reads image pixel map data and writes the data to an ArrayBuffer. This method uses
970     * a promise to return the result.
971     * @since 7
972     * @syscap SystemCapability.Multimedia.Image.Core
973     * @param dst A buffer to which the image pixel map data will be written.
974     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
975     */
976    readPixelsToBuffer(dst: ArrayBuffer): Promise<void>;
977
978    /**
979     * Reads image pixel map data and writes the data to an ArrayBuffer. This method uses
980     * a callback to return the result.
981     * @since 7
982     * @syscap SystemCapability.Multimedia.Image.Core
983     * @param dst A buffer to which the image pixel map data will be written.
984     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
985     */
986    readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback<void>): void;
987
988    /**
989     * Reads image pixel map data in an area. This method uses a promise to return the data read.
990     * @since 7
991     * @syscap SystemCapability.Multimedia.Image.Core
992     * @param area Area from which the image pixel map data will be read.
993     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
994     */
995    readPixels(area: PositionArea): Promise<void>;
996
997    /**
998     * Reads image pixel map data in an area. This method uses a callback to return the data read.
999     * @since 7
1000     * @syscap SystemCapability.Multimedia.Image.Core
1001     * @param area Area from which the image pixel map data will be read.
1002     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
1003     */
1004    readPixels(area: PositionArea, callback: AsyncCallback<void>): void;
1005
1006    /**
1007     * Writes image pixel map data to the specified area. This method uses a promise to return
1008     * the operation result.
1009     * @since 7
1010     * @syscap SystemCapability.Multimedia.Image.Core
1011     * @param area Area to which the image pixel map data will be written.
1012     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
1013     */
1014    writePixels(area: PositionArea): Promise<void>;
1015
1016    /**
1017     * Writes image pixel map data to the specified area. This method uses a callback to return
1018     * the operation result.
1019     * @since 7
1020     * @syscap SystemCapability.Multimedia.Image.Core
1021     * @param area Area to which the image pixel map data will be written.
1022     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
1023     */
1024    writePixels(area: PositionArea, callback: AsyncCallback<void>): void;
1025
1026    /**
1027     * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. This method
1028     * uses a promise to return the result.
1029     * @since 7
1030     * @syscap SystemCapability.Multimedia.Image.Core
1031     * @param src A buffer from which the image data will be read.
1032     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
1033     */
1034    writeBufferToPixels(src: ArrayBuffer): Promise<void>;
1035
1036    /**
1037     * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. This method
1038     * uses a callback to return the result.
1039     * @since 7
1040     * @syscap SystemCapability.Multimedia.Image.Core
1041     * @param src A buffer from which the image data will be read.
1042     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
1043     */
1044    writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback<void>): void;
1045
1046    /**
1047     * Obtains pixel map information about this image. This method uses a promise to return the information.
1048     * @since 7
1049     * @syscap SystemCapability.Multimedia.Image.Core
1050     * @returns A Promise instance used to return the image pixel map information. If the operation fails, an error message is returned.
1051     */
1052    getImageInfo(): Promise<ImageInfo>;
1053
1054    /**
1055     * Obtains pixel map information about this image. This method uses a callback to return the information.
1056     * @since 7
1057     * @syscap SystemCapability.Multimedia.Image.Core
1058     * @param callback Callback used to return the image pixel map information. If the operation fails, an error message is returned.
1059     */
1060    getImageInfo(callback: AsyncCallback<ImageInfo>): void;
1061
1062    /**
1063     * Obtains the number of bytes in each line of the image pixel map.
1064     * @since 7
1065     * @syscap SystemCapability.Multimedia.Image.Core
1066     * @returns Number of bytes in each line.
1067     */
1068    getBytesNumberPerRow(): number;
1069
1070    /**
1071     * Obtains the total number of bytes of the image pixel map.
1072     * @since 7
1073     * @syscap SystemCapability.Multimedia.Image.Core
1074     * @returns Total number of bytes.
1075     */
1076    getPixelBytesNumber(): number;
1077
1078    /**
1079     * Obtains the density of the image pixel map.
1080     * @since 9
1081     * @syscap SystemCapability.Multimedia.Image.Core
1082     * @returns The number of density.
1083     */
1084    getDensity():number;
1085
1086    /**
1087     * Set the transparent rate of pixel map. This method uses a callback to return the operation result.
1088     * @since 9
1089     * @syscap SystemCapability.Multimedia.Image.Core
1090     * @param rate The value of transparent rate.
1091     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
1092     */
1093    opacity(rate: number, callback: AsyncCallback<void>): void;
1094
1095    /**
1096     * Set the transparent rate of pixel map. This method uses a promise to return the result.
1097     * @since 9
1098     * @syscap SystemCapability.Multimedia.Image.Core
1099     * @param rate The value of transparent rate.
1100     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
1101     */
1102    opacity(rate: number): Promise<void>;
1103
1104    /**
1105     * Obtains new pixel map with alpha information. This method uses a promise to return the information.
1106     * @since 9
1107     * @syscap SystemCapability.Multimedia.Image.Core
1108     * @returns A Promise instance used to return the new image pixel map. If the operation fails, an error message is returned.
1109     */
1110    createAlphaPixelmap(): Promise<PixelMap>;
1111
1112    /**
1113     * Obtains new pixel map with alpha information. This method uses a callback to return the information.
1114     * @since 9
1115     * @syscap SystemCapability.Multimedia.Image.Core
1116     * @param callback Callback used to return the new image pixel map. If the operation fails, an error message is returned.
1117     */
1118    createAlphaPixelmap(callback: AsyncCallback<PixelMap>): void;
1119
1120    /**
1121     * Image zoom in width and height. This method uses a callback to return the operation result.
1122     * @since 9
1123     * @syscap SystemCapability.Multimedia.Image.Core
1124     * @param x The zoom value of width.
1125	 * @param y The zoom value of height.
1126     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
1127     */
1128    scale(x: number, y: number, callback: AsyncCallback<void>): void;
1129
1130    /**
1131     * Image zoom in width and height. This method uses a promise to return the result.
1132     * @since 9
1133     * @syscap SystemCapability.Multimedia.Image.Core
1134     * @param x The zoom value of width.
1135	 * @param y The zoom value of height.
1136     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
1137     */
1138    scale(x: number, y: number): Promise<void>;
1139
1140    /**
1141     * Image position transformation. This method uses a callback to return the operation result.
1142     * @since 9
1143     * @syscap SystemCapability.Multimedia.Image.Core
1144     * @param x The position value of width.
1145	 * @param y The position value of height.
1146     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
1147     */
1148    translate(x: number, y: number, callback: AsyncCallback<void>): void;
1149
1150    /**
1151     * Image position transformation. This method uses a promise to return the result.
1152     * @since 9
1153     * @syscap SystemCapability.Multimedia.Image.Core
1154     * @param x The position value of width.
1155	 * @param y The position value of height.
1156     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
1157     */
1158    translate(x: number, y: number): Promise<void>;
1159
1160    /**
1161     * Image rotation. This method uses a callback to return the operation result.
1162     * @since 9
1163     * @syscap SystemCapability.Multimedia.Image.Core
1164     * @param angle The rotation angle.
1165     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
1166     */
1167    rotate(angle: number, callback: AsyncCallback<void>): void;
1168
1169    /**
1170     * Image rotation. This method uses a promise to return the result.
1171     * @since 9
1172     * @syscap SystemCapability.Multimedia.Image.Core
1173     * @param angle The rotation angle.
1174     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
1175     */
1176    rotate(angle: number): Promise<void>;
1177
1178    /**
1179     * Image flipping. This method uses a callback to return the operation result.
1180     * @since 9
1181     * @syscap SystemCapability.Multimedia.Image.Core
1182     * @param horizontal Is flip in horizontal.
1183     * @param vertical Is flip in vertical.
1184     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
1185     */
1186    flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback<void>): void;
1187
1188    /**
1189     * Image flipping. This method uses a promise to return the result.
1190     * @since 9
1191     * @syscap SystemCapability.Multimedia.Image.Core
1192     * @param horizontal Is flip in horizontal.
1193     * @param vertical Is flip in vertical.
1194     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
1195     */
1196    flip(horizontal: boolean, vertical: boolean): Promise<void>;
1197
1198    /**
1199     * Crop the image. This method uses a callback to return the operation result.
1200     * @since 9
1201     * @syscap SystemCapability.Multimedia.Image.Core
1202     * @param region The region to crop.
1203     * @param callback Callback used to return the operation result. If the operation fails, an error message is returned.
1204     */
1205    crop(region: Region, callback: AsyncCallback<void>): void;
1206
1207    /**
1208     * Crop the image. This method uses a promise to return the result.
1209     * @since 9
1210     * @syscap SystemCapability.Multimedia.Image.Core
1211     * @param region The region to crop.
1212     * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned.
1213     */
1214    crop(region: Region): Promise<void>;
1215
1216    /**
1217     * Get color space of pixel map.
1218     *
1219     * @returns { colorSpaceManager.ColorSpaceManager } If the operation fails, an error message is returned.
1220     * @syscap SystemCapability.Multimedia.Image.Core
1221     * @since 10
1222     */
1223    getColorSpace(): colorSpaceManager.ColorSpaceManager;
1224
1225    /**
1226         * Marshalling pixelmap and write into MessageSequence.
1227         *
1228         * @param { rpc.MessageSequence } sequence rpc.MessageSequence parameter.
1229         * @syscap SystemCapability.Multimedia.Image.Core
1230         * @throws { BusinessError } 62980115 - If the input parameter invalid.
1231         * @throws { BusinessError } 62980097 - If the ipc error.
1232         * @since 10
1233         */
1234    marshalling(sequence: rpc.MessageSequence): void;
1235
1236    /**
1237     * Creates a PixelMap object based on MessageSequence parameter. This method uses a callback to
1238     * return the object.
1239     *
1240     * @param { rpc.MessageSequence } sequence rpc.MessageSequence parameter.
1241     * @param { AsyncCallback<PixelMap> } callback Callback used to return the PixelMap object.
1242     * @syscap SystemCapability.Multimedia.Image.Core
1243     * @throws { BusinessError } 62980115 - If the input parameter invalid.
1244     * @throws { BusinessError } 62980097 - If the ipc error.
1245     * @throws { BusinessError } 62980096 - If fail to create async work.
1246     * @since 10
1247     */
1248    unmarshalling(sequence: rpc.MessageSequence, callback: AsyncCallback<PixelMap>): void;
1249
1250    /**
1251     * Set color space of pixel map.
1252     *
1253     * @param { colorSpaceManager.ColorSpaceManager } colorSpace The color space for pixel map.
1254     * @returns { void } If the operation fails, an error message is returned.
1255     * @syscap SystemCapability.Multimedia.Image.Core
1256     * @since 10
1257     */
1258    setColorSpace(colorSpace: colorSpaceManager.ColorSpaceManager): void;
1259
1260    /**
1261     * Releases this PixelMap object. This method uses a callback to return the result.
1262     * @since 7
1263     * @syscap SystemCapability.Multimedia.Image.Core
1264     * @param callback Callback invoked for instance release. If the operation fails, an error message is returned.
1265     */
1266    release(callback: AsyncCallback<void>): void;
1267
1268    /**
1269     * Releases this PixelMap object. This method uses a promise to return the result.
1270     * @since 7
1271     * @syscap SystemCapability.Multimedia.Image.Core
1272     * @returns A Promise instance used to return the instance release result. If the operation fails, an error message is returned.
1273     */
1274    release(): Promise<void>;
1275  }
1276
1277  /**
1278   * ImageSource instance.
1279   * @since 6
1280   * @syscap SystemCapability.Multimedia.Image.ImageSource
1281   */
1282  interface ImageSource {
1283    /**
1284     * Obtains information about an image with the specified sequence number and uses a callback
1285     * to return the result.
1286     * @since 6
1287     * @syscap SystemCapability.Multimedia.Image.ImageSource
1288     * @param index Sequence number of an image.
1289     * @param callback Callback used to return the image information.
1290     */
1291    getImageInfo(index: number, callback: AsyncCallback<ImageInfo>): void;
1292
1293    /**
1294     * Obtains information about this image and uses a callback to return the result.
1295     * @since 6
1296     * @syscap SystemCapability.Multimedia.Image.ImageSource
1297     * @param callback Callback used to return the image information.
1298     */
1299    getImageInfo(callback: AsyncCallback<ImageInfo>): void;
1300
1301    /**
1302     * Get image information from image source.
1303     * @since 6
1304     * @syscap SystemCapability.Multimedia.Image.ImageSource
1305     * @param index Sequence number of an image. If this parameter is not specified, the default value 0 is used.
1306     * @returns A Promise instance used to return the image information.
1307     */
1308    getImageInfo(index?: number): Promise<ImageInfo>;
1309
1310    /**
1311     * Creates a PixelMap object based on image decoding parameters. This method uses a promise to
1312     * return the object.
1313     * @since 7
1314     * @syscap SystemCapability.Multimedia.Image.ImageSource
1315     * @param options Image decoding parameters.
1316     * @returns A Promise instance used to return the PixelMap object.
1317     */
1318    createPixelMap(options?: DecodingOptions): Promise<PixelMap>;
1319
1320    /**
1321     * Creates a PixelMap object. This method uses a callback to return the object.
1322     * @since 7
1323     * @syscap SystemCapability.Multimedia.Image.ImageSource
1324     * @param callback Callback used to return the PixelMap object.
1325     */
1326    createPixelMap(callback: AsyncCallback<PixelMap>): void;
1327
1328    /**
1329     * Creates a PixelMap object based on image decoding parameters. This method uses a callback to
1330     * return the object.
1331     * @since 7
1332     * @syscap SystemCapability.Multimedia.Image.ImageSource
1333     * @param options Image decoding parameters.
1334     * @param callback Callback used to return the PixelMap object.
1335     */
1336    createPixelMap(options: DecodingOptions, callback: AsyncCallback<PixelMap>): void;
1337
1338    /**
1339     * Creates a PixelMap array based on image decoding parameters. This method uses a promise to
1340     * return the array.
1341     * @since 10
1342     * @syscap SystemCapability.Multimedia.Image.ImageSource
1343     * @param options Image decoding parameters.
1344     * @returns A Promise instance used to return the PixelMap array.
1345     */
1346    createPixelMapList(options?: DecodingOptions): Promise<Array<PixelMap>>;
1347
1348    /**
1349     * Creates a PixelMap array based on image decoding parameters. This method uses a callback to
1350     * return the array.
1351     * @since 10
1352     * @syscap SystemCapability.Multimedia.Image.ImageSource
1353     * @param options Image decoding parameters.
1354     * @param callback Callback used to return the PixelMap array.
1355     */
1356    createPixelMapList(options: DecodingOptions, callback: AsyncCallback<Array<PixelMap>>): void;
1357
1358    /**
1359     * Obtains the array of delay time in an image. This method uses a promise to return the array.
1360     * @since 10
1361     * @syscap SystemCapability.Multimedia.Image.ImageSource
1362     * @returns A Promise instance used to return the array.
1363     */
1364    getDelayTime(): Promise<Array<number>>;
1365
1366    /**
1367     * Obtains the array of delay time in an image. This method uses a callback to to return the array.
1368     * @since 10
1369     * @syscap SystemCapability.Multimedia.Image.ImageSource
1370     * @param callback Callback used to return the array.
1371     */
1372    getDelayTime(callback: AsyncCallback<Array<number>>): void;
1373
1374    /**
1375     * Obtains the count of frame in an image. This method uses a promise to return the number.
1376     * @since 10
1377     * @syscap SystemCapability.Multimedia.Image.ImageSource
1378     * @returns A Promise instance used to return the number.
1379     */
1380    getFrameCount(): Promise<number>;
1381
1382    /**
1383     * Obtains the count of frame in an image. This method uses a callback to to return the number.
1384     * @since 10
1385     * @syscap SystemCapability.Multimedia.Image.ImageSource
1386     * @param callback Callback used to return the number.
1387     */
1388    getFrameCount(callback: AsyncCallback<number>): void;
1389
1390    /**
1391     * Obtains the value of a property in an image with the specified index. This method uses a
1392     * promise to return the property value in a string.
1393     * @since 7
1394     * @syscap SystemCapability.Multimedia.Image.ImageSource
1395     * @param key Name of the property whose value is to be obtained.
1396     * @param options Index of the image.
1397     * @returns A Promise instance used to return the property value. If the operation fails, the default value is returned.
1398     */
1399    getImageProperty(key: string, options?: GetImagePropertyOptions): Promise<string>;
1400
1401    /**
1402     * Obtains the value of a property in this image. This method uses a callback to return the
1403     * property value in a string.
1404     * @since 7
1405     * @syscap SystemCapability.Multimedia.Image.ImageSource
1406     * @param key Name of the property whose value is to be obtained.
1407     * @param callback Callback used to return the property value. If the operation fails, an error message is returned.
1408     */
1409    getImageProperty(key: string, callback: AsyncCallback<string>): void;
1410
1411    /**
1412     * Obtains the value of a property in an image with the specified index. This method uses
1413     * a callback to return the property value in a string.
1414     * @since 7
1415     * @syscap SystemCapability.Multimedia.Image.ImageSource
1416     * @param key Name of the property whose value is to be obtained.
1417     * @param options Index of the image.
1418     * @param callback Callback used to return the property value. If the operation fails, the default value is returned.
1419     */
1420    getImageProperty(key: string, options: GetImagePropertyOptions, callback: AsyncCallback<string>): void;
1421
1422    /**
1423     * Modify the value of a property in an image with the specified key. This method uses a
1424     * promise to return the property value in a string.
1425     * @since 9
1426     * @syscap SystemCapability.Multimedia.Image.ImageSource
1427     * @param key Name of the property whose value is to be modified.
1428     * @param value The value to be set to property.
1429     * @returns A Promise instance used to return the property value.
1430     */
1431    modifyImageProperty(key: string, value: string): Promise<void>;
1432
1433    /**
1434     * Modify the value of a property in an image with the specified key. This method uses a callback to return the
1435     * property value in a string.
1436     * @since 9
1437     * @syscap SystemCapability.Multimedia.Image.ImageSource
1438     * @param key Name of the property whose value is to be obtained.
1439     * @param value The value to be set to property.
1440     * @param callback Callback to return the operation result.
1441     */
1442    modifyImageProperty(key: string, value: string, callback: AsyncCallback<void>): void;
1443
1444    /**
1445     * Update the data in the incremental ImageSource.
1446     * @since 9
1447     * @syscap SystemCapability.Multimedia.Image.ImageSource
1448     * @param buf The data to be updated.
1449     * @param isFinished If is it finished.
1450     * @param value The offset of data.
1451     * @param length The length fo buf.
1452     * @returns A Promise instance used to return the property value.
1453     */
1454    updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number): Promise<void>;
1455
1456    /**
1457     * Update the data in the incremental ImageSource.
1458     * @since 9
1459     * @syscap SystemCapability.Multimedia.Image.ImageSource
1460     * @param buf The data to be updated.
1461     * @param isFinished If is it finished.
1462     * @param value The offset of data.
1463     * @param length The length fo buf.
1464     * @param callback Callback to return the operation result.
1465     */
1466    updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback<void>): void;
1467
1468    /**
1469     * Releases an ImageSource instance and uses a callback to return the result.
1470     * @since 6
1471     * @syscap SystemCapability.Multimedia.Image.ImageSource
1472     * @param callback Callback to return the operation result.
1473     */
1474    release(callback: AsyncCallback<void>): void;
1475
1476    /**
1477     * Releases an ImageSource instance and uses a promise to return the result.
1478     * @since 6
1479     * @syscap SystemCapability.Multimedia.Image.ImageSource
1480     * @returns A Promise instance used to return the operation result.
1481     */
1482    release(): Promise<void>;
1483
1484    /**
1485     * Supported image formats.
1486     * @since 6
1487     * @syscap SystemCapability.Multimedia.Image.ImageSource
1488     */
1489    readonly supportedFormats: Array<string>;
1490  }
1491
1492  /**
1493   * ImagePacker instance.
1494   * @since 6
1495   * @syscap SystemCapability.Multimedia.Image.ImagePacker
1496   */
1497  interface ImagePacker {
1498    /**
1499     * Compresses or packs an image and uses a callback to return the result.
1500     * @since 6
1501     * @syscap SystemCapability.Multimedia.Image.ImagePacker
1502     * @param source Image to be processed.
1503     * @param option Option for image packing.
1504     * @param callback Callback used to return the packed data.
1505     */
1506    packing(source: ImageSource, option: PackingOption, callback: AsyncCallback<ArrayBuffer>): void;
1507
1508    /**
1509     * Compresses or packs an image and uses a promise to return the result.
1510     * @since 6
1511     * @syscap SystemCapability.Multimedia.Image.ImagePacker
1512     * @param source Image to be processed.
1513     * @param option Option for image packing.
1514     * @returns A Promise instance used to return the compressed or packed data.
1515     */
1516    packing(source: ImageSource, option: PackingOption): Promise<ArrayBuffer>;
1517
1518    /**
1519     * Compresses or packs an image and uses a callback to return the result.
1520     * @since 8
1521     * @syscap SystemCapability.Multimedia.Image.ImagePacker
1522     * @param source PixelMap to be processed.
1523     * @param option Option for image packing.
1524     * @param callback Callback used to return the packed data.
1525     */
1526     packing(source: PixelMap, option: PackingOption, callback: AsyncCallback<ArrayBuffer>): void;
1527
1528     /**
1529      * Compresses or packs an image and uses a promise to return the result.
1530      * @since 8
1531      * @syscap SystemCapability.Multimedia.Image.ImagePacker
1532      * @param source PixelMap to be processed.
1533      * @param option Option for image packing.
1534      * @returns A Promise instance used to return the compressed or packed data.
1535      */
1536     packing(source: PixelMap, option: PackingOption): Promise<ArrayBuffer>;
1537
1538    /**
1539     * Releases an ImagePacker instance and uses a callback to return the result.
1540     * @since 6
1541     * @syscap SystemCapability.Multimedia.Image.ImagePacker
1542     * @param callback Callback to return the operation result.
1543     */
1544    release(callback: AsyncCallback<void>): void;
1545
1546    /**
1547     * Releases an ImagePacker instance and uses a promise to return the result.
1548     * @since 6
1549     * @syscap SystemCapability.Multimedia.Image.ImagePacker
1550     * @returns A Promise instance used to return the operation result.
1551     */
1552    release(): Promise<void>;
1553
1554    /**
1555     * Supported image formats.
1556     * @since 6
1557     * @syscap SystemCapability.Multimedia.Image.ImagePacker
1558     */
1559    readonly supportedFormats: Array<string>;
1560  }
1561
1562  /**
1563   * Provides basic image operations, including obtaining image information, and reading and writing image data.
1564   * @since 9
1565   * @syscap SystemCapability.Multimedia.Image.Core
1566   */
1567  interface Image {
1568    /**
1569     * Sets or gets the image area to crop, default is size.
1570     * @since 9
1571     * @syscap SystemCapability.Multimedia.Image.Core
1572     */
1573    clipRect: Region;
1574
1575    /**
1576     * Image size.
1577     * @since 9
1578     * @syscap SystemCapability.Multimedia.Image.Core
1579     */
1580    readonly size: Size;
1581
1582    /**
1583     * Image format.
1584     * @since 9
1585     * @syscap SystemCapability.Multimedia.Image.Core
1586     */
1587    readonly format: number;
1588
1589    /**
1590     * Get component buffer from image and uses a callback to return the result.
1591     * @since 9
1592     * @syscap SystemCapability.Multimedia.Image.Core
1593     * @param componentType The component type of image.
1594     * @param callback Callback used to return the component buffer.
1595     */
1596    getComponent(componentType: ComponentType, callback: AsyncCallback<Component>): void;
1597
1598    /**
1599     * Get component buffer from image and uses a promise to return the result.
1600     * @since 9
1601     * @syscap SystemCapability.Multimedia.Image.Core
1602     * @param componentType The component type of image.
1603     * @returns A Promise instance used to return the component buffer.
1604     */
1605    getComponent(componentType: ComponentType): Promise<Component>;
1606
1607    /**
1608     * Release current image to receive another and uses a callback to return the result.
1609     * @since 9
1610     * @syscap SystemCapability.Multimedia.Image.Core
1611     * @param callback Callback to return the operation result.
1612     */
1613    release(callback: AsyncCallback<void>): void;
1614
1615    /**
1616     * Release current image to receive another and uses a promise to return the result.
1617     * @since 9
1618     * @syscap SystemCapability.Multimedia.Image.Core
1619     * @returns A Promise instance used to return the operation result.
1620     */
1621    release(): Promise<void>;
1622  }
1623
1624  /**
1625   * Image receiver object.
1626   * @since 9
1627   * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1628   */
1629  interface ImageReceiver {
1630    /**
1631     * Image size.
1632     * @since 9
1633     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1634     */
1635    readonly size: Size;
1636
1637    /**
1638     * Image capacity.
1639     * @since 9
1640     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1641     */
1642    readonly capacity: number;
1643
1644    /**
1645     * Image format.
1646     * @since 9
1647     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1648     */
1649    readonly format: ImageFormat;
1650
1651    /**
1652     * Get an id which indicates a surface and can be used to set to Camera or other component can receive a surface
1653     * and uses a callback to return the result.
1654     * @since 9
1655     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1656     * @param callback Callback used to return the surface id.
1657     */
1658    getReceivingSurfaceId(callback: AsyncCallback<string>): void;
1659
1660    /**
1661     * Get an id which indicates a surface and can be used to set to Camera or other component can receive a surface
1662     * and uses a promise to return the result.
1663     * @since 9
1664     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1665     * @returns A Promise instance used to return the surface id.
1666     */
1667    getReceivingSurfaceId(): Promise<string>;
1668
1669    /**
1670     * Get lasted image from receiver and uses a callback to return the result.
1671     * @since 9
1672     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1673     * @param callback Callback used to return the latest image.
1674     */
1675    readLatestImage(callback: AsyncCallback<Image>): void;
1676
1677    /**
1678     * Get lasted image from receiver and uses a promise to return the result.
1679     * @since 9
1680     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1681     * @returns A Promise instance used to return the latest image.
1682     */
1683    readLatestImage(): Promise<Image>;
1684
1685    /**
1686     * Get next image from receiver and uses a callback to return the result.
1687     * @since 9
1688     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1689     * @param callback Callback used to return the next image.
1690     */
1691    readNextImage(callback: AsyncCallback<Image>): void;
1692
1693    /**
1694     * Get next image from receiver and uses a promise to return the result.
1695     * @since 9
1696     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1697     * @returns A Promise instance used to return the next image.
1698     */
1699    readNextImage(): Promise<Image>;
1700
1701    /**
1702     * Subscribe callback when receiving an image
1703     * @since 9
1704     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1705     * @param type Callback used to return the next image.
1706     * @param callback Callback used to return image.
1707     */
1708    on(type: 'imageArrival', callback: AsyncCallback<void>): void;
1709
1710    /**
1711     * Release image receiver instance and uses a callback to return the result.
1712     * @since 9
1713     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1714     * @param callback Callback to return the operation result.
1715     */
1716    release(callback: AsyncCallback<void>): void;
1717
1718    /**
1719     * Release image receiver instance and uses a promise to return the result.
1720     * @since 9
1721     * @syscap SystemCapability.Multimedia.Image.ImageReceiver
1722     * @returns A Promise instance used to return the operation result.
1723     */
1724    release(): Promise<void>;
1725  }
1726
1727  /**
1728   * Image creator object.
1729   * @since 9
1730   * @syscap SystemCapability.Multimedia.Image.ImageCreator
1731   */
1732  interface ImageCreator {
1733    /**
1734     * Image capacity.
1735     * @since 9
1736     * @syscap SystemCapability.Multimedia.Image.ImageCreator
1737     */
1738    readonly capacity: number;
1739
1740    /**
1741     * Image format.
1742     * @since 9
1743     * @syscap SystemCapability.Multimedia.Image.ImageCreator
1744     */
1745    readonly format: ImageFormat;
1746
1747    /**
1748     * Apply for new graphic buffer from free queue and use a callback to return the result.
1749     * @since 9
1750     * @syscap SystemCapability.Multimedia.Image.ImageCreator
1751     * @param callback Callback to return the operation result.
1752     */
1753    dequeueImage(callback: AsyncCallback<Image>): void;
1754
1755    /**
1756     * Apply for new graphic buffer from free queue and uses a promise to return the result.
1757     * @since 9
1758     * @syscap SystemCapability.Multimedia.Image.ImageCreator
1759     * @returns A Promise instance used to return the operation result.
1760     */
1761    dequeueImage(): Promise<Image>;
1762
1763    /**
1764     * Queue buffer to dirty queue and uses a callback to return the result.
1765     * @since 9
1766     * @syscap SystemCapability.Multimedia.Image.ImageCreator
1767     * @param callback Callback to return the operation result.
1768     */
1769    queueImage(interface: Image, callback: AsyncCallback<void>): void;
1770
1771    /**
1772     * Queue buffer to dirty queue and uses a promise to return the result.
1773     * @since 9
1774     * @syscap SystemCapability.Multimedia.Image.ImageCreator
1775     * @returns A Promise instance used to return the operation result.
1776     */
1777    queueImage(interface: Image): Promise<void>;
1778
1779    /**
1780     * Subscribe callback when releasing buffer
1781     * @since 9
1782     * @syscap SystemCapability.Multimedia.Image.ImageCreator
1783     * @param type Callback used to return the operation result.
1784     * @param callback Callback used to return the operation result.
1785     */
1786    on(type: 'imageRelease', callback: AsyncCallback<void>): void;
1787
1788    /**
1789     * Releases buffer in bufferqueue instance and uses a callback to return the result.
1790     * @since 9
1791     * @syscap SystemCapability.Multimedia.Image.ImageCreator
1792     * @param callback Callback to return the operation result.
1793     */
1794    release(callback: AsyncCallback<void>): void;
1795
1796    /**
1797     * Releases buffer in bufferqueue instance and uses a promise to return the result.
1798     * @since 9
1799     * @syscap SystemCapability.Multimedia.Image.ImageCreator
1800     * @returns A Promise instance used to return the operation result.
1801     */
1802    release(): Promise<void>;
1803  }
1804}
1805
1806export default image;
1807