Draw an image on the Canvas.
Syntax

[C#]

XRect DrawImage(XImage inImage, double inWidth, double inHeight, DrawOptions inOptions);
XRect DrawImage(XImage inImage, DrawOptions inOptions);
XRect DrawImage(XImage inImage, XPoint inPos, DrawOptions inOptions);
XRect DrawImage(XImage inImage, XRect inRect, DrawOptions inOptions);

[Visual Basic]

Function DrawImage(inImage As XImage, inWidth As Double, inHeight As Double, inOptions As DrawOptions) As XRect
Function DrawImage(inImage As XImage, inOptions As DrawOptions) As XRect
Function DrawImage(inImage As XImage, inPos As XPoint, inOptions As DrawOptions) As XRect
Function DrawImage(inImage As XImage, inRect As XRect, inOptions As DrawOptions) As XRect
Params
Name Description
inImage The image to draw.
inWidth The image width.
inHeight The image height.
inOptions The draw options.
inPos The image position.
inRect The image rectangle, when different than natural image rectangle.
return The drawn area.
Notes

Draw an image on the canvas. The image will be positioned according to the parameters specified here: inRect, inPos. If no such parameter is specified the image will be positioned according to HAlign and VAlign. Is no size is specified the image will be sized using ImageFit.

See Also

XImage

DrawOptions

Example

Here we create an image and add it to the canvas. The Canvas is automatically sized to display the image.

[C#]

Canvas canvas = new Canvas();
XImage image = XImage.FromFile(Server.MapPath("rez/boat.gif"));
canvas.DrawImage(image, new DrawOptions());
canvas.SaveAs(Server.MapPath("Canvas_DrawImage_75.png"));


[Visual Basic]

Dim canvas As New Canvas()
Dim image As XImage = XImage.FromFile(Server.MapPath("rez/boat.gif"))
canvas.DrawImage(image, New DrawOptions())
canvas.SaveAs(Server.MapPath("Canvas_DrawImage_75.png"))



Canvas_DrawImage_75.png