diff --git a/api/common/full/viewmodel.d.ts b/api/common/full/viewmodel.d.ts index 1dad55169e55f2d3d911a4e5fdbb9c7c1aa2f7e8..91e57e8a969a13fa6c65ddc69ff6780a12184398 100644 --- a/api/common/full/viewmodel.d.ts +++ b/api/common/full/viewmodel.d.ts @@ -16,6 +16,7 @@ import { Image, ImageData } from "./global"; import { WebGLContextAttributes, WebGLRenderingContext } from "../../webgl/webgl"; import { WebGL2RenderingContext } from "../../webgl/webgl2"; +import { PixelMap } from "../../@ohos.multimedia.image"; /** * Defines the foucs param. @@ -1151,6 +1152,42 @@ export interface OffscreenCanvasRenderingContext2D { dh: number, ): void; + /** + * Draw an Image object. + * @param image An element drawn to the context. + * @param dx The top left corner of the image is the X-axis coordinates on the target canvas. + * @param dy The top left corner of the image is the Y-axis coordinates on the target canvas. + * @param dw Image The width drawn on the target canvas. + * @param dh Image The height drawn on the target canvas. + * @since 9 + */ + drawImage(image: PixelMap, dx: number, dy: number, dw: number, dh: number): void; + + /** + * Draw an Image object. + * @param image An element drawn to the context. + * @param dx The top left corner of the image is the X-axis coordinates on the target canvas. + * @param dy The top left corner of the image is the Y-axis coordinates on the target canvas. + * @param dw Image The width drawn on the target canvas. + * @param dh Image The height drawn on the target canvas. + * @param sx The upper-left X-axis coordinates of the image's rectangular (clipped) selection box that need to be drawn into the target context. + * @param sy The upper-left Y-axis coordinates of the image's rectangular (clipped) selection box that need to be drawn into the target context. + * @param sw The width of the image's rectangular (clipped) selection box that needs to be drawn into the target context. + * @param sh The height of the image's rectangular (clipped) selection box that needs to be drawn into the target context. + * @since 9 + */ + drawImage( + image: PixelMap, + sx: number, + sy: number, + sw: number, + sh: number, + dx: number, + dy: number, + dw: number, + dh: number, + ): void; + /** * Creates a drawing path. * @since 7 @@ -1298,6 +1335,17 @@ export interface OffscreenCanvasRenderingContext2D { */ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + /** + * Get an PixelMap object. + * @param sx The upper-left x-coordinate of the rectangular area of the image data to be extracted. + * @param sy The upper-left y coordinate of the rectangular region of the image data to be extracted. + * @param sw The width of the rectangular area of the image data to be extracted. + * @param sh The height of the rectangular area of the image data to be extracted. + * @returns getPixelMap An getPixelMap object that contains the rectangular ImageData given by the canvas. + * @since 9 + */ + getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap + /** * Draws the specified ImageData object to the canvas. * @param imagedata An array object containing pixel values. @@ -1992,6 +2040,42 @@ export interface CanvasRenderingContext2D { dHeight: number, ): void; +/** + * Draws an image. + * @param image Image resource. + * @param dx X-coordinate of the upper left corner of the drawing area on the canvas. + * @param dy Y-coordinate of the upper left corner of the drawing area on the canvas. + * @param dWidth Width of the drawing area. + * @param dHeight Height of the drawing area. + * @since 9 + */ + drawImage(image: PixelMap, dx: number, dy: number, dWidth: number, dHeight: number): void; + + /** + * Draws an image. + * @param image Image resource. + * @param sx X-coordinate of the upper left corner of the rectangle used to crop the source image. + * @param sy Y-coordinate of the upper left corner of the rectangle used to crop the source image. + * @param sWidth Target width of the image to crop. + * @param sHeight Target height of the image to crop. + * @param dx X-coordinate of the upper left corner of the drawing area on the canvas. + * @param dy Y-coordinate of the upper left corner of the drawing area on the canvas. + * @param dWidth Width of the drawing area. + * @param dHeight Height of the drawing area. + * @since 9 + */ + drawImage( + image: PixelMap, + sx: number, + sy: number, + sWidth: number, + sHeight: number, + dx: number, + dy: number, + dWidth: number, + dHeight: number, + ): void; + /** * Restores the saved drawing context. * @since 4 @@ -2031,6 +2115,17 @@ export interface CanvasRenderingContext2D { */ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + /** + * Get an PixelMap object. + * @param sx The upper-left x-coordinate of the rectangular area of the image data to be extracted. + * @param sy The upper-left y coordinate of the rectangular region of the image data to be extracted. + * @param sw The width of the rectangular area of the image data to be extracted. + * @param sh The height of the rectangular area of the image data to be extracted. + * @returns getPixelMap An getPixelMap object that contains the rectangular ImageData given by the canvas. + * @since 9 + */ + getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap + /** * Puts the ImageData onto a rectangular area on the canvas. * @param imageData ImageData object with pixels to put onto the canvas.