Canvas constructor.
Syntax

[C#]

Canvas();
Canvas(bool inTransparent);
Canvas(double inWidth, double inHeight);
Canvas(double inWidth, double inHeight, XColor inColor);
Canvas(string inPath);
Canvas(string inPath, bool inTransparency);
Canvas(XColor inColor);
Canvas(XImage inImage);
Canvas(XImage inImage, bool inTransparency);

[Visual Basic]

Sub New()
Sub New(inTransparent As Boolean)
Sub New(inWidth As Double, inHeight As Double)
Sub New(inWidth As Double, inHeight As Double, inColor As XColor)
Sub New(inPath As String)
Sub New(inPath As String, inTransparency As Boolean)
Sub New(inColor As XColor)
Sub New(inImage As XImage)
Sub New(inImage As XImage, inTransparency As Boolean)
Params
Name Description
inTransparent Whether the background should be transparent.
inWidth The Canvas width.
inHeight The Canvas height.
inColor The Canvas color.
inPath The file path to the Canvas background image.
inTransparency Whether to preserve transparency when drawing the background.
inImage The Canvas background image.
Notes

Create an empty canvas by calling the default constructor. Alternatively you can specify the width, height or color. This has the effect of setting the Width, Height and Color properties.

If you wish to draw an image on your Canvas, and want the Canvas size to be exactly the image size, then use the constructor that accepts a file path or an image as a parameter. If you need the image to be transparent then use the override that also accepts the inTransparency parameter and set it to true.

Example

Here we create a Canvas and draw an image onto it. The Canvas size will be the same as the image.

[C#]

Canvas canvas = new Canvas(Server.MapPath("rez/main.jpg"), true);
canvas.SaveAs(Server.MapPath("Canvas_Create_98.png"));


[Visual Basic]

Dim canvas As New Canvas(Server.MapPath("rez/main.jpg"), True)
canvas.SaveAs(Server.MapPath("Canvas_Create_98.png"))



Canvas_Create_98.png