Draws an image from a graphic file onto the Canvas.

 

   
Syntax
 
     

[Visual Basic]
Function Canvas.DrawFile(inFile As String, inParams As String) As System.Drawing.Rectangle

[C#]
System.Drawing.Rectangle Canvas.DrawFile(string inFile, string inParams);

 

   
Params
 
     
Name   Description
inFile The path to the file to be drawn.
inParams A parameter string containing Override parameters, Positioning parameters, Transform parameters and Image Manipulation parameters.
return

The Rect (before transformation) of the area drawn to.

 

   
Notes
 
     

Draws an image from a graphic file onto the Canvas.

If both the width and height of the Canvas have been specified the positioning of the image on the canvas will be determined by the Positioning and Transform parameters.

If the size of the canvas has not been completely determined the canvas will be Autosized.

 

   
See Also
 
     

Canvas DrawData function.
Canvas DrawStream function.

 

   
Example
 
     

[Visual Basic]
Dim ca As New Canvas
Dim inpath, outpath As String
inpath = Server.MapPath("rez/layers.psd")
outpath = Server.MapPath("drawfile.jpg")
ca.Color = System.Drawing.Color.Yellow
ca.Width = 200
ca.Height = 200
ca.DrawFile(inpath, "Image=4 Mode=transparent")
ca.SaveAs(outpath, "Quality=high")

[C#]
Canvas ca = new Canvas();
string inpath = Server.MapPath("rez/layers.psd");
string outpath = Server.MapPath("drawfile.jpg");
ca.Color = System.Drawing.Color.Yellow;
ca.Width = 200;
ca.Height = 200;
ca.DrawFile(inpath, "Image=4 Mode=transparent");
ca.SaveAs(outpath, "Quality=high");

The code looks for a Photoshop file called 'layers.psd'. It pulls out the fourth image (there is one composite image and three layers in the file) and draws it transparent onto a yellow background. Finally it saves out the image as a jpeg. The input and output is shown below.

layers.psd

drawfile.jpg