From 0bbea5c1251e3a5d05d68941a9fbb32edf7301a8 Mon Sep 17 00:00:00 2001 From: yaoyuchi Date: Tue, 15 Feb 2022 21:09:20 +0800 Subject: [PATCH 1/2] canvas support drawPixelMap Signed-off-by: yaoyuchi --- api/@internal/component/ets/canvas.d.ts | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/api/@internal/component/ets/canvas.d.ts b/api/@internal/component/ets/canvas.d.ts index b6c2839360..ac1fe4bea5 100644 --- a/api/@internal/component/ets/canvas.d.ts +++ b/api/@internal/component/ets/canvas.d.ts @@ -701,6 +701,51 @@ declare class CanvasRenderer extends CanvasPath { */ getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap; + /** + * Draw an image on a canvas + * @param PixelMap Obtains the PixelMap of a specified area on the current canvas. + * @param dx x-axis coordinate of the upper left corner of the image on the target canvas. + * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. + * @since 8 + */ + drawPixelMap(pixelMap:PixelMap, dx:number, dy:number): void; + + /** + * Draw an image on a canvas + * @param PixelMap Obtains the PixelMap of a specified area on the current canvas. + * @param dx x-axis coordinate of the upper left corner of the image on the target canvas. + * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. + * @param dw Specifies the drawing width of the image on the target canvas. The width of the drawn image will be scaled. + * @param dh Specifies the drawing height of the image on the target canvas. The height of the drawn image will be scaled. + * @since 8 + */ + drawPixelMap(pixelMap:PixelMap, dx: number, dy: number, dw: number, dh: number): void; + + /** + *Draw an image on a canvas + * @param PixelMap Obtains the PixelMap of a specified area on the current canvas. + * @param sx x coordinate of the upper left corner of the rectangle (cropping) selection box of the image. + * @param sy y coordinate of the upper left corner of the rectangle (cropping) selection box of the image. + * @param sw Width of the rectangle (cropping) selection box of the image. + * @param sh Height of the rectangle (cropping) selection box of the image. + * @param dx x-axis coordinate of the upper left corner of the image on the target canvas. + * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. + * @param dw Specifies the drawing width of the image on the target canvas. The width of the drawn image will be scaled. + * @param dh Specifies the drawing height of the image on the target canvas. The height of the drawn image will be scaled. + * @since 8 + */ + drawPixelMap( + pixelMap:PixelMap, + sx: number, + sy: number, + sw: number, + sh: number, + dx: number, + dy: number, + dw: number, + dh: number, + ): void; + /** * Draws the specified ImageData object onto the canvas * @param imagedata ImageData object to be drawn. -- Gitee From 3dfbaa99bb4b538a9a4466b182083ff291f6cfa1 Mon Sep 17 00:00:00 2001 From: yaoyuchi Date: Thu, 17 Feb 2022 20:16:27 +0800 Subject: [PATCH 2/2] combile to one method Signed-off-by: yaoyuchi --- api/@internal/component/ets/canvas.d.ts | 51 ++----------------------- 1 file changed, 3 insertions(+), 48 deletions(-) diff --git a/api/@internal/component/ets/canvas.d.ts b/api/@internal/component/ets/canvas.d.ts index ac1fe4bea5..b5291da78a 100644 --- a/api/@internal/component/ets/canvas.d.ts +++ b/api/@internal/component/ets/canvas.d.ts @@ -496,7 +496,7 @@ declare class CanvasRenderer extends CanvasPath { * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. * @since 8 */ - drawImage(image: ImageBitmap, dx: number, dy: number): void; + drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number): void; /** * Draw an image on a canvas @@ -507,7 +507,7 @@ declare class CanvasRenderer extends CanvasPath { * @param dh Specifies the drawing height of the image on the target canvas. The height of the drawn image will be scaled. * @since 8 */ - drawImage(image: ImageBitmap, dx: number, dy: number, dw: number, dh: number): void; + drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number, dw: number, dh: number): void; /** *Draw an image on a canvas @@ -523,7 +523,7 @@ declare class CanvasRenderer extends CanvasPath { * @since 8 */ drawImage( - image: ImageBitmap, + image: ImageBitmap | PixelMap, sx: number, sy: number, sw: number, @@ -701,51 +701,6 @@ declare class CanvasRenderer extends CanvasPath { */ getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap; - /** - * Draw an image on a canvas - * @param PixelMap Obtains the PixelMap of a specified area on the current canvas. - * @param dx x-axis coordinate of the upper left corner of the image on the target canvas. - * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. - * @since 8 - */ - drawPixelMap(pixelMap:PixelMap, dx:number, dy:number): void; - - /** - * Draw an image on a canvas - * @param PixelMap Obtains the PixelMap of a specified area on the current canvas. - * @param dx x-axis coordinate of the upper left corner of the image on the target canvas. - * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. - * @param dw Specifies the drawing width of the image on the target canvas. The width of the drawn image will be scaled. - * @param dh Specifies the drawing height of the image on the target canvas. The height of the drawn image will be scaled. - * @since 8 - */ - drawPixelMap(pixelMap:PixelMap, dx: number, dy: number, dw: number, dh: number): void; - - /** - *Draw an image on a canvas - * @param PixelMap Obtains the PixelMap of a specified area on the current canvas. - * @param sx x coordinate of the upper left corner of the rectangle (cropping) selection box of the image. - * @param sy y coordinate of the upper left corner of the rectangle (cropping) selection box of the image. - * @param sw Width of the rectangle (cropping) selection box of the image. - * @param sh Height of the rectangle (cropping) selection box of the image. - * @param dx x-axis coordinate of the upper left corner of the image on the target canvas. - * @param dy y-axis coordinate of the upper left corner of the image on the target canvas. - * @param dw Specifies the drawing width of the image on the target canvas. The width of the drawn image will be scaled. - * @param dh Specifies the drawing height of the image on the target canvas. The height of the drawn image will be scaled. - * @since 8 - */ - drawPixelMap( - pixelMap:PixelMap, - sx: number, - sy: number, - sw: number, - sh: number, - dx: number, - dy: number, - dw: number, - dh: number, - ): void; - /** * Draws the specified ImageData object onto the canvas * @param imagedata ImageData object to be drawn. -- Gitee