diff --git a/api/@ohos.multimedia.image.d.ts b/api/@ohos.multimedia.image.d.ts index 384a7f93ec361715f3b8b7a6ce43edc8c6ea84f5..17ec79142ed591e0d7857796a99dee567bbd9605 100644 --- a/api/@ohos.multimedia.image.d.ts +++ b/api/@ohos.multimedia.image.d.ts @@ -158,6 +158,62 @@ declare namespace image { JPEG = 2000 } + /** + * Enumerates alpha types. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + enum AlphaType { + /** + * Indicates an unknown alpha type. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + UNKNOWN = 0, + + /** + * Indicates that the image has no alpha channel, or all pixels in the image are fully opaque. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + OPAQUE = 1, + + /** + * Indicates that RGB components of each pixel in the image are premultiplied by alpha. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + PREMUL = 2, + + /** + * Indicates that RGB components of each pixel in the image are independent of alpha and are not premultiplied by alpha. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + UNPREMUL = 3 + } + + /** + * Enum for image scale mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + enum ScaleMode { + /** + * Indicates the effect that fits the image into the target size. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + FIT_TARGET_SIZE = 0, + + /** + * Indicates the effect that scales an image to fill the target image area and center-crops the part outside the area. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + CENTER_CROP = 1, + } + /** * The componet type of image. * @since 9 @@ -431,6 +487,20 @@ declare namespace image { * @syscap SystemCapability.Multimedia.Image.Core */ editable?: boolean; + + /** + * PixelMap expected alpha type. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + alphaType?: AlphaType; + + /** + * PixelMap expected scaling effect. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.Core + */ + scaleMode?: ScaleMode; } /** @@ -465,6 +535,24 @@ declare namespace image { */ function createImageSource(fd: number): ImageSource; + /** + * Creates an ImageSource instance based on the buffer. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The buffer of the iamge. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function createImageSource(buf: ArrayBuffer): ImageSource; + + /** + * Creates an ImageSource instance based on the buffer in incremental. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The buffer of the iamge. + * @return Returns the ImageSource instance if the operation is successful; returns null otherwise. + */ + function CreateIncrementalSource(buf: ArrayBuffer): ImageSource; + /** * Creates an ImagePacker instance. * @since 6 @@ -696,7 +784,7 @@ declare namespace image { * @param options Index of the image. * @return A Promise instance used to return the property value. If the operation fails, the default value is returned. */ - getImageProperty(key:string, options?: GetImagePropertyOptions): Promise; + getImageProperty(key: string, options?: GetImagePropertyOptions): Promise; /** * Obtains the value of a property in this image. This method uses a callback to return the @@ -706,7 +794,7 @@ declare namespace 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. */ - getImageProperty(key:string, callback: AsyncCallback): void; + getImageProperty(key: string, callback: AsyncCallback): void; /** * Obtains the value of a property in an image with the specified index. This method uses @@ -717,7 +805,53 @@ declare namespace image { * @param options Index of the image. * @param callback Callback used to return the property value. If the operation fails, the default value is returned. */ - getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback): void; + getImageProperty(key: string, options: GetImagePropertyOptions, callback: AsyncCallback): void; + + /** + * Modify the value of a property in an image with the specified key. This method uses a + * promise to return the property value in a string. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param key Name of the property whose value is to be modified. + * @param value The value to be set to property. + * @return A Promise instance used to return the property value. + */ + modifyImageProperty(key: string, value: string): Promise; + + /** + * Modify the value of a property in an image with the specified key. This method uses a callback to return the + * property value in a string. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param key Name of the property whose value is to be obtained. + * @param value The value to be set to property. + * @param callback Callback to return the operation result. + */ + modifyImageProperty(key: string, value: string, callback: AsyncCallback): void; + + /** + * Update the data in the incremental ImageSource. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The data to be updated. + * @param isFinished If is it finished. + * @param value The offset of data. + * @param length The lenght fo buf. + * @return A Promise instance used to return the property value. + */ + updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number): Promise; + + /** + * Update the data in the incremental ImageSource. + * @since 9 + * @syscap SystemCapability.Multimedia.Image.ImageSource + * @param buf The data to be updated. + * @param isFinished If is it finished. + * @param value The offset of data. + * @param length The lenght fo buf. + * @param callback Callback to return the operation result. + */ + updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback): void; /** * Releases an ImageSource instance and uses a callback to return the result.