From f7f6b0f9fe9cd7e8995e3a83989168e779a1497a Mon Sep 17 00:00:00 2001 From: zhang-xiaobo1997 Date: Wed, 30 Mar 2022 15:27:41 +0800 Subject: [PATCH 1/3] modify for new api Signed-off-by: zhang-xiaobo1997 --- api/@ohos.multimedia.image.d.ts | 134 ++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/api/@ohos.multimedia.image.d.ts b/api/@ohos.multimedia.image.d.ts index 384a7f93ec..773f44d75c 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 @@ -719,6 +807,52 @@ declare namespace image { */ 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. * @since 6 -- Gitee From 4947ed916fa1c12cccfae07c7c3bfb25e61908ea Mon Sep 17 00:00:00 2001 From: zhang-xiaobo1997 Date: Wed, 30 Mar 2022 17:12:07 +0800 Subject: [PATCH 2/3] modify for dts Signed-off-by: zhang-xiaobo1997 --- api/@ohos.multimedia.image.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/@ohos.multimedia.image.d.ts b/api/@ohos.multimedia.image.d.ts index 773f44d75c..81030491a7 100644 --- a/api/@ohos.multimedia.image.d.ts +++ b/api/@ohos.multimedia.image.d.ts @@ -784,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 @@ -794,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 @@ -805,7 +805,7 @@ 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 @@ -816,7 +816,7 @@ declare namespace image { * @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; + 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 @@ -827,7 +827,7 @@ declare namespace image { * @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; + modifyImageProperty(key: string, value: string, callback: AsyncCallback): void; /** * Update the data in the incremental ImageSource. @@ -839,7 +839,7 @@ declare namespace image { * @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; + updateData(buf: ArrayBuffer, isFinished:boolean, value: number, length: number): Promise; /** * Update the data in the incremental ImageSource. @@ -851,7 +851,7 @@ declare namespace image { * @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; + updateData(buf: ArrayBuffer, isFinished:boolean, value: number, length: number, callback: AsyncCallback): void; /** * Releases an ImageSource instance and uses a callback to return the result. -- Gitee From 35678deaa05d7c8ab5e048958e50c057a472e47c Mon Sep 17 00:00:00 2001 From: zhang-xiaobo1997 Date: Wed, 30 Mar 2022 17:21:21 +0800 Subject: [PATCH 3/3] modify for dts Signed-off-by: zhang-xiaobo1997 --- api/@ohos.multimedia.image.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@ohos.multimedia.image.d.ts b/api/@ohos.multimedia.image.d.ts index 81030491a7..17ec79142e 100644 --- a/api/@ohos.multimedia.image.d.ts +++ b/api/@ohos.multimedia.image.d.ts @@ -839,7 +839,7 @@ declare namespace image { * @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; + updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number): Promise; /** * Update the data in the incremental ImageSource. @@ -851,7 +851,7 @@ declare namespace image { * @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; + updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback): void; /** * Releases an ImageSource instance and uses a callback to return the result. -- Gitee