Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Native
Skip to main content

Interface ICanvas2

interface ICanvas2
Extends ICanvas ICanvas2 interface extends ICanvas and defines new methods for drawing image and applying image filters.

Methods

drawImage()

void drawImage(IImage* image, Point position, ImageFilterQuality filterQuality, IPaint? paint)
Draws the specified image at the given position on the canvas using the ImageFilterQuality quality and IPaint options. The image is rendered such that its top-left corner aligns with the provided Point position, and its full dimensions are drawn unless further clipped by the canvas or layers above in the hierarchy. The rendering can be customized using the provided ImageFilterQuality for scaling and sampling behavior, and IPaint for color, alpha (transparency), or blend effects. The ImageFilterQuality parameter controls the filtering quality used when resampling the image, affecting visual quality and performance tradeoffs.

Parameters

image
IImage* — Required The image to draw.
position
Point — Required The local coordinates where the image’s top-left corner will be drawn
filterQuality
ImageFilterQuality — Required The filter quality to use when scaling the image to control sharpness and performance.
paint
IPaint? — Optional The paint options to apply (e.g., alpha, blend mode). If null, no paint options would be applied.

drawImageRect()

void drawImageRect(IImage* image, ImageFilterQuality filterQuality, Rect* dst, Rect? src, IPaint? paint)
Draws the specified image by mapping a source rectangle from the image onto a destination rectangle on the canvas. The portion of the image defined by the Rect src is scaled and drawn to fit within the Rect dst on the canvas. This allows for cropping and scaling the image as needed. The rendering can be customized using the provided IPaint for color effects, alpha, or blend modes. The ImageFilterQuality parameter controls the filtering quality used when scaling or resampling the image, affecting visual quality and performance tradeoffs.

Parameters

image
IImage* — Required The image to draw.
filterQuality
ImageFilterQuality — Required The filtering quality to apply when scaling the image.
dst
Rect* — Required The destination rectangle on the canvas where the source will be mapped.
src
Rect? — Optional The source rectangle from the image to draw. Coordinates are relative to the image. If null, the complete image is used as the source.
paint
IPaint? — Optional The paint options to apply (e.g., alpha, blend mode). If null, no paint options would be applied

saveLayer()

u32 saveLayer(Rect* bounds, float alpha, IImageFilter? filter)
This method behaves the same as ICanvas::save, but in addition it allocates and redirects drawing to an offscreen rendering target. Only when the balancing call to ICanvas::restore is made that offscreen buffer is drawn back to the current target of the ICanvas (which can potentially be a previous layer if these calls are nested). It allows specifying an IImageFilter to apply image processing effects to the content being drawn in the layer. These are applied when the layer is drawn back into the canvas.

Parameters

bounds
Rect* — Required The maximum size the offscreen render target needs to be (in local coordinates).
alpha
float — Required The alpha value to apply to the layer when it is composited back to the canvas.
filter
IImageFilter? — Optional The image filter IImageFilter to apply to the contents of the layer. If null no image filter is applied.

Returns

u32 A save count identifier for restoring this layer state by passing it to ICanvas::restoreToCount.
Last modified on October 29, 2026