From 7b9ef7591cc7a9e8bbbc6a7dbb6a545fc666917a Mon Sep 17 00:00:00 2001 From: wanzixuan Date: Fri, 25 Jul 2025 16:47:42 +0800 Subject: [PATCH] Modify overload functions for image Signed-off-by: wanzixuan --- api/@ohos.multimedia.image.d.ts | 356 +++++++++++++++++++++++++++++--- 1 file changed, 322 insertions(+), 34 deletions(-) diff --git a/api/@ohos.multimedia.image.d.ts b/api/@ohos.multimedia.image.d.ts index e9e9f36629..e23dd5759c 100644 --- a/api/@ohos.multimedia.image.d.ts +++ b/api/@ohos.multimedia.image.d.ts @@ -5086,6 +5086,12 @@ declare namespace image { */ function createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise; + /** + * @since 20 + * @arkts 1.2 + */ + overload createPixelMapSync { createPixelMapSyncWithColorsOptions, createPixelMapSyncWithOptions }; + /** * Create pixelmap by data buffer. * @@ -5096,8 +5102,22 @@ declare namespace image { * 2.Incorrect parameter types. 3.Parameter verification failed. * @syscap SystemCapability.Multimedia.Image.Core * @crossplatform - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 20 + * @arkts 1.2 + */ + function createPixelMapSyncWithColorsOptions(colors: ArrayBuffer, options: InitializationOptions): PixelMap; + + /** + * Create pixelmap by data buffer. + * + * @param { ArrayBuffer } colors The image color buffer. + * @param { InitializationOptions } options Initialization options for pixelmap. + * @returns { PixelMap } Returns the instance if the operation is successful;Otherwise, return undefined. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @since 12 */ function createPixelMapSync(colors: ArrayBuffer, options: InitializationOptions): PixelMap; @@ -5148,8 +5168,21 @@ declare namespace image { * 2.Incorrect parameter types. 3.Parameter verification failed. * @syscap SystemCapability.Multimedia.Image.Core * @crossplatform - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 20 + * @arkts 1.2 + */ +function createPixelMapSyncWithOptions(options: InitializationOptions): PixelMap; + + /** + * Create an empty pixelmap. + * + * @param { InitializationOptions } options Initialization options for pixelmap. + * @returns { PixelMap } Returns the instance if the operation is successful;Otherwise, return undefined. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @since 12 */ function createPixelMapSync(options: InitializationOptions): PixelMap; @@ -5277,6 +5310,22 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise; + + /** + * Creates a PixelMap object from surface id. + * + * @param { string } surfaceId - surface id. + * @param { Region } region - The region to surface. + * @returns { PixelMap } Returns the instance if the operation is successful;Otherwise, an exception will be thrown. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. + * @throws { BusinessError } 62980105 - Failed to get the data. + * @throws { BusinessError } 62980178 - Failed to create the PixelMap. + * @syscap SystemCapability.Multimedia.Image.Core + * @since 20 + * @arkts 1.2 + */ + function createPixelMapFromSurfaceSyncWithSurfaceIdRegion(surfaceId: string, region: Region): PixelMap; /** * Creates a PixelMap object from surface id. @@ -5289,8 +5338,7 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise; + /** + * @since 20 + * @arkts 1.2 + */ + overload createPixelMapFromSurfaceSync { createPixelMapFromSurfaceSyncWithSurfaceId, createPixelMapFromSurfaceSyncWithSurfaceIdRegion }; + /** * Creates a PixelMap object from surface id. * @@ -5318,8 +5372,22 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise } A Promise instance used to return the new image pixel map. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + createAlphaPixelmapReturnsPromise(): Promise; + /** * Obtains new pixel map with alpha information. This method uses a promise to return the information. * @@ -6535,11 +6623,23 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise; + /** + * Obtains new pixel map with alpha information. This method uses a callback to return the information. + * + * @param { AsyncCallback } callback Callback used to return the new image pixel map. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + createAlphaPixelmapWithCallback(callback: AsyncCallback): void; + /** * Obtains new pixel map with alpha information. This method uses a callback to return the information. * @@ -6572,8 +6672,7 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise): void; @@ -6590,6 +6689,29 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise } callback Callback used to return the operation result. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + scaleWithCallback(x: double, y: double, callback: AsyncCallback): void; + /** * Image zoom in width and height. This method uses a callback to return the operation result. * @@ -6630,11 +6752,25 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise): void; + /** + * Image zoom in width and height. This method uses a promise to return the result. + * + * @param { double } x The zoom value of width. + * @param { double } y The zoom value of height. + * @returns { Promise } A Promise instance used to return the operation result. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + scaleReturnsPromise(x: double, y: double): Promise; + /** * Image zoom in width and height. This method uses a promise to return the result. * @@ -6675,11 +6811,16 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise; + /** + * @since 20 + * @arkts 1.2 + */ + overload scaleSync { scaleSyncWithXY, scaleSyncWithXYLevel }; + /** * Image zoom in width and height. * @@ -6691,8 +6832,23 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise; + + /** + * Image zoom in width and height width with anti-aliasing. This method uses a promise to return the result. + * + * @param { double } x The zoom value of width. + * @param { double } y The zoom value of height. + * @param { AntiAliasingLevel } level The anti-aliasing algorithm to be used. + * @returns { Promise } A Promise instance used to return the operation result. If the operation fails, an error message is returned. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. 3.Parameter verification failed. + * @throws { BusinessError } 501 - Resource Unavailable. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 12 */ scale(x: double, y: double, level: AntiAliasingLevel): Promise; @@ -6727,8 +6901,24 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise } callback Callback used to return the operation result. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + rotateWithCallback(angle: double, callback: AsyncCallback): void; + /** * Image rotation. This method uses a callback to return the operation result. * @@ -6906,11 +7116,24 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise): void; + /** + * Image rotation. This method uses a promise to return the result. + * + * @param { double } angle The rotation angle. + * @returns { Promise } A Promise instance used to return the operation result. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + rotateReturnsPromise(angle: double): Promise; + /** * Image rotation. This method uses a promise to return the result. * @@ -6947,8 +7170,7 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise; @@ -6967,6 +7189,27 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise } callback Callback used to return the operation result. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + flipWithCallback(horizontal: boolean, vertical: boolean, callback: AsyncCallback): void; + /** * Image flipping. This method uses a callback to return the operation result. * @@ -7007,11 +7250,25 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise): void; + /** + * Image flipping. This method uses a promise to return the result. + * + * @param { boolean } horizontal Is flip in horizontal. + * @param { boolean } vertical Is flip in vertical. + * @returns { Promise } A Promise instance used to return the operation result. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + flipReturnsPromise(horizontal: boolean, vertical: boolean): Promise; + /** * Image flipping. This method uses a promise to return the result. * @@ -7052,8 +7309,7 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise; @@ -7073,6 +7329,26 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise } callback Callback used to return the operation result. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 12 + * @arkts 1.2 + */ + cropWithCallback(region: Region, callback: AsyncCallback): void; + /** * Crop the image. This method uses a callback to return the operation result. * @@ -7109,11 +7385,24 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise): void; + /** + * Crop the image. This method uses a promise to return the result. + * + * @param { Region } region The region to crop. + * @returns { Promise } A Promise instance used to return the operation result. If the operation fails, an error message is returned. + * @syscap SystemCapability.Multimedia.Image.Core + * @crossplatform + * @form + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + cropReturnsPromise(region: Region): Promise; + /** * Crop the image. This method uses a promise to return the result. * @@ -7150,8 +7439,7 @@ function createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise; -- Gitee