diff --git a/api/@ohos.multimedia.image.d.ts b/api/@ohos.multimedia.image.d.ts index a18e101c5955f77188ea5f108440c33110958b31..c231f17a4d59be22ea205fdd70c6bc79e642f8ca 100644 --- a/api/@ohos.multimedia.image.d.ts +++ b/api/@ohos.multimedia.image.d.ts @@ -18,18 +18,16 @@ import { AsyncCallback } from './basic'; /** * @name image * @since 6 - * @SysCap SystemCapability.Multimedia.Image + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image'; - * @devices phone, tablet, tv, wearable, car */ declare namespace image { /** * Enumerates pixel map formats. * @since 7 - * @SysCap SystemCapability.Multimedia.Image + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' - * @devices phone, tablet, tv, wearable, car */ enum PixelMapFormat { /** @@ -58,16 +56,14 @@ declare namespace image { /** * Height * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ height: number; /** * Width * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ width: number; } @@ -75,9 +71,8 @@ declare namespace image { /** * Enumerates exchangeable image file format (Exif) information types of an image. * @since 7 - * @SysCap SystemCapability.Multimedia.Image + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' - * @devices phone, tablet, tv, wearable, car */ enum PropertyKey { /** @@ -121,6 +116,52 @@ declare namespace image { GPS_LONGITUDE_REF = "GPSLongitudeRef" } + /** + * Enum for image formats. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + */ + enum ImageFormat { + /** + * YCBCR422 semi-planar format. + */ + YCBCR_422_SP = 1000, + + /** + * JPEG encoding format. + */ + JPEG = 2000 + } + + /** + * The componet type of image. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + */ + enum ComponentType { + /** + * Luma info. + */ + YUV_Y = 1, + + /** + * Chrominance info. + */ + YUV_U = 2, + + /** + * Chroma info. + */ + YUV_V = 3, + + /** + * Jpeg type. + */ + JPEG = 4, + } + /** * Describes region information. */ @@ -128,24 +169,21 @@ declare namespace image { /** * Image size. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ size: Size; /** * x-coordinate at the upper left corner of the image. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ x: number; /** * y-coordinate at the upper left corner of the image. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ y: number; } @@ -157,32 +195,28 @@ declare namespace image { /** * Image data that will be read or written. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ pixels: ArrayBuffer; /** * Offset for data reading. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ offset: number; /** * Number of bytes to read. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ stride: number; /** * Region to read. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ region: Region; } @@ -194,8 +228,7 @@ declare namespace image { /** * Indicates image dimensions specified by a {@link Size} interface. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ size: Size; } @@ -207,8 +240,7 @@ declare namespace image { /** * Multipurpose Internet Mail Extensions (MIME) format of the target image, for example, image/jpeg. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ format: string; @@ -216,8 +248,7 @@ declare namespace image { * Quality of the target image. The value is an integer ranging from 0 to 100. A larger value indicates better * image quality but larger space occupied. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ quality: number; } @@ -229,16 +260,14 @@ declare namespace image { /** * Index of an image. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ index?: number; /** * Default property value. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ defaultValue?: string; } @@ -250,32 +279,28 @@ declare namespace image { /** * Number of image frames. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ index?: number; /** * Sampling ratio of the image pixel map. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ sampleSize?: number; /** * Rotation angle of the image pixel map. The value ranges from 0 to 360. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ rotate?: number; /** * Whether the image pixel map is editable. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ editable?: boolean; @@ -283,33 +308,63 @@ declare namespace image { * Width and height of the image pixel map. The value (0, 0) indicates that the pixels are decoded * based on the original image size. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ desiredSize?: Size; /** * Cropping region of the image pixel map. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ desiredRegion?: Region; /** * Data format of the image pixel map. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image */ desiredPixelFormat?: PixelMapFormat; } + /** + * Describes image color components. + * @since 8 + */ + interface Component { + /** + * Component type. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + */ + readonly componentType: ComponentType; + + /** + * Row stride. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + */ + readonly rowStride: number; + + /** + * Pixel stride. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + */ + readonly pixelStride: number; + + /** + * Component buffer. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + */ + readonly byteBuffer: ArrayBuffer; + } + /** * Creates an ImageSource instance based on the URI. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param uri Image source URI. * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. @@ -319,8 +374,7 @@ declare namespace image { /** * Creates an ImageSource instance based on the file descriptor. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param fd ID of a file descriptor. * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. @@ -330,19 +384,31 @@ declare namespace image { /** * Creates an ImagePacker instance. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @return Returns the ImagePacker instance if the operation is successful; returns null otherwise. */ function createImagePacker(): ImagePacker; + /** + * Creates an ImageReceiver instance. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param width The default width in pixels of the Images that this receiver will produce. + * @param height The default height in pixels of the Images that this receiver will produce. + * @param format The format of the Image that this receiver will produce. This must be one of the + * {@link ImageFormat} constants. Note that not all formats are supported, like ImageFormat.NV21. + * @param capacity The maximum number of images the user will want to access simultaneously. + * @return Returns the ImageReceiver instance if the operation is successful; returns null otherwise. + */ + function createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver; + interface PixelMap { /** * Whether the image pixel map can be edited. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' */ readonly isEditable: boolean; @@ -351,8 +417,7 @@ declare namespace image { * Reads image pixel map data and writes the data to an ArrayBuffer. This method uses * a promise to return the result. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param dst A buffer to which the image pixel map data will be written. * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. @@ -363,8 +428,7 @@ declare namespace image { * Reads image pixel map data and writes the data to an ArrayBuffer. This method uses * a callback to return the result. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param dst A buffer to which the image pixel map data will be written. * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. @@ -374,8 +438,7 @@ declare namespace image { /** * Reads image pixel map data in an area. This method uses a promise to return the data read. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param area Area from which the image pixel map data will be read. * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. @@ -385,8 +448,7 @@ declare namespace image { /** * Reads image pixel map data in an area. This method uses a callback to return the data read. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param area Area from which the image pixel map data will be read. * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. @@ -397,8 +459,7 @@ declare namespace image { * Writes image pixel map data to the specified area. This method uses a promise to return * the operation result. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param area Area to which the image pixel map data will be written. * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. @@ -409,8 +470,7 @@ declare namespace image { * Writes image pixel map data to the specified area. This method uses a callback to return * the operation result. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param area Area to which the image pixel map data will be written. * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. @@ -421,8 +481,7 @@ declare namespace image { * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. This method * uses a promise to return the result. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param src A buffer from which the image data will be read. * @return A Promise instance used to return the operation result. If the operation fails, an error message is returned. @@ -433,8 +492,7 @@ declare namespace image { * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. This method * uses a callback to return the result. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param src A buffer from which the image data will be read. * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. @@ -444,8 +502,7 @@ declare namespace image { /** * Obtains pixel map information about this image. This method uses a promise to return the information. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @return A Promise instance used to return the image pixel map information. If the operation fails, an error message is returned. */ @@ -454,8 +511,7 @@ declare namespace image { /** * Obtains pixel map information about this image. This method uses a callback to return the information. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param callback Callback used to return the image pixel map information. If the operation fails, an error message is returned. */ @@ -464,8 +520,7 @@ declare namespace image { /** * Obtains the number of bytes in each line of the image pixel map. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @return Number of bytes in each line. */ @@ -474,8 +529,7 @@ declare namespace image { /** * Obtains the total number of bytes of the image pixel map. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @return Total number of bytes. */ @@ -484,8 +538,7 @@ declare namespace image { /** * Releases this PixelMap object. This method uses a callback to return the result. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param callback Callback invoked for instance release. If the operation fails, an error message is returned. */ @@ -494,8 +547,7 @@ declare namespace image { /** * Releases this PixelMap object. This method uses a promise to return the result. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @return A Promise instance used to return the instance release result. If the operation fails, an error message is returned. */ @@ -507,8 +559,7 @@ declare namespace image { * Obtains information about an image with the specified sequence number and uses a callback * to return the result. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param index Sequence number of an image. * @param callback Callback used to return the image information. @@ -518,8 +569,7 @@ declare namespace image { /** * Obtains information about this image and uses a callback to return the result. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param callback Callback used to return the image information. */ @@ -528,8 +578,7 @@ declare namespace image { /** * Get image information from image source. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param index Sequence number of an image. If this parameter is not specified, the default value 0 is used. * @return A Promise instance used to return the image information. @@ -540,8 +589,7 @@ declare namespace image { * Creates a PixelMap object based on image decoding parameters. This method uses a promise to * return the object. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param options Image decoding parameters. * @return A Promise instance used to return the PixelMap object. @@ -551,8 +599,7 @@ declare namespace image { /** * Creates a PixelMap object. This method uses a callback to return the object. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param callback Callback used to return the PixelMap object. */ @@ -562,8 +609,7 @@ declare namespace image { * Creates a PixelMap object based on image decoding parameters. This method uses a callback to * return the object. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param options Image decoding parameters. * @param callback Callback used to return the PixelMap object. @@ -574,8 +620,7 @@ declare namespace image { * Obtains the value of a property in an image with the specified index. This method uses a * promise to return the property value in a string. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param key Name of the property whose value is to be obtained. * @param options Index of the image. @@ -587,8 +632,7 @@ declare namespace image { * Obtains the value of a property in this image. This method uses a callback to return the * property value in a string. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param key Name of the property whose value is to be obtained. * @param callback Callback used to return the property value. If the operation fails, an error message is returned. @@ -599,8 +643,7 @@ declare namespace image { * Obtains the value of a property in an image with the specified index. This method uses * a callback to return the property value in a string. * @since 7 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param key Name of the property whose value is to be obtained. * @param options Index of the image. @@ -611,8 +654,7 @@ declare namespace image { /** * Releases an ImageSource instance and uses a callback to return the result. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param callback Callback to return the operation result. */ @@ -621,8 +663,7 @@ declare namespace image { /** * Releases an ImageSource instance and uses a promise to return the result. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @return A Promise instance used to return the operation result. */ @@ -631,8 +672,7 @@ declare namespace image { /** * Supported image formats. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' */ readonly supportedFormats: Array; @@ -642,8 +682,7 @@ declare namespace image { /** * Compresses or packs an image and uses a callback to return the result. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param source Image to be processed. * @param option Option for image packing. @@ -654,8 +693,7 @@ declare namespace image { /** * Compresses or packs an image and uses a promise to return the result. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param source Image to be processed. * @param option Option for image packing. @@ -663,11 +701,32 @@ declare namespace image { */ packing(source: ImageSource, option: PackingOption): Promise; + /** + * Compresses or packs an image and uses a callback to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param source PixelMap to be processed. + * @param option Option for image packing. + * @param callback Callback used to return the packed data. + */ + packing(source: PixelMap, option: PackingOption, callback: AsyncCallback): void; + + /** + * Compresses or packs an image and uses a promise to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param source PixelMap to be processed. + * @param option Option for image packing. + * @return A Promise instance used to return the compressed or packed data. + */ + packing(source: PixelMap, option: PackingOption): Promise; + /** * Releases an ImagePacker instance and uses a callback to return the result. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @param callback Callback to return the operation result. */ @@ -676,8 +735,7 @@ declare namespace image { /** * Releases an ImagePacker instance and uses a promise to return the result. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' * @return A Promise instance used to return the operation result. */ @@ -686,12 +744,193 @@ declare namespace image { /** * Supported image formats. * @since 6 - * @SysCap SystemCapability.Multimedia.Image - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Multimedia.Image * @import import image from '@ohos.multimedia.image' */ readonly supportedFormats: Array; } + + /** + * Provides basic image operations, including obtaining image information, and reading and writing image data. + * @since 8 + */ + interface Image { + /** + * Sets or gets the image area to crop, default is size. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + */ + clipRect: Region; + + /** + * Image size. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + */ + readonly size: Size; + + /** + * Image format. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + */ + readonly format: number; + + /** + * Get component buffer from image and uses a callback to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param componentType The componet type of image. + * @param callback Callback used to return the component buffer. + */ + getComponent(componentType: ComponentType, callback: AsyncCallback): void; + + /** + * Get component buffer from image and uses a promise to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param componentType The componet type of image. + * @return A Promise instance used to return the component buffer. + */ + getComponent(componentType: ComponentType): Promise; + + /** + * Release current image to receive another and uses a callback to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param callback Callback to return the operation result. + */ + release(callback: AsyncCallback): void; + + /** + * Release current image to receive another and uses a promise to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @return A Promise instance used to return the operation result. + */ + release(): Promise; + } + + /** + * Image receiver object. + * @since 8 + */ + interface ImageReceiver { + /** + * Image size. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + */ + readonly size: Size; + + /** + * Image capacity. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + */ + readonly capacity: number; + + /** + * Image format. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + */ + readonly format: ImageFormat; + + /** + * get an id which indicates a surface and can be used to set to Camera or other component can receive a surface + * and uses a callback to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param callback Callback used to return the surface id. + */ + getReceivingSurfaceId(callback: AsyncCallback): void; + + /** + * get an id which indicates a surface and can be used to set to Camera or other component can receive a surface + * and uses a promise to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @return A Promise instance used to return the surface id. + */ + getReceivingSurfaceId(): Promise; + + /** + * Get lasted image from receiver and uses a callback to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param callback Callback used to return the latest image. + */ + readLatestImage(callback: AsyncCallback): void; + + /** + * Get lasted image from receiver and uses a promise to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @return A Promise instance used to return the latest image. + */ + readLatestImage(): Promise; + + /** + * Get next image from receiver and uses a callback to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param callback Callback used to return the next image. + */ + readNextImage(callback: AsyncCallback): void; + + /** + * Get next image from receiver and uses a promise to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @return A Promise instance used to return the next image. + */ + readNextImage(): Promise; + + /** + * Subscribe callback when receiving an image + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param type Callback used to return the next image. + * @param callback Callback used to return image. + */ + on(type: 'imageArrival', callback: AsyncCallback): void; + + /** + * Release image receiver instance and uses a callback to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @param callback Callback to return the operation result. + */ + release(callback: AsyncCallback): void; + + /** + * Release image receiver instance and uses a promise to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Image + * @import import image from '@ohos.multimedia.image' + * @return A Promise instance used to return the operation result. + */ + release(): Promise; + } } export default image; \ No newline at end of file