Draws a graphic held as a stream of data onto the canvas.

 

   
Syntax
 
     

[Visual Basic]
Function DrawStream(inStream As Stream, inType As String, inParams As String) As System.Drawing.Rectangle

[C#]
System.Drawing.Rectangle DrawStream(Stream inStream, string inType, string inParams);

 

   
Params
 
     
Name   Description
inStream The .NET stream holding the data to be drawn.
inType See the Type Image Manipulation parameter for ways of specifying types.
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
 
     

This works in exactly the same way as the DrawFile method but allows you to draw an image that is only available as a .NET stream.

You typically use a sample filename to specify the file type. However in most cases the type can be worked out even if an empty string is passed in.

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 DrawFile function.
Canvas DrawData function.

 

   
Example
 
     

[Visual Basic]
Dim fl As HttpPostedFile
fl = Request.Files("filefield")
Dim params As String
params = "Fit=True VAlign=middle HAlign=middle"

Dim ca As New Canvas
ca.Width = 300 ' constrain width
ca.DrawStream(fl.InputStream, fl.FileName, params)
ca.SaveAs(Server.MapPath("upload.jpg"), "")

[C#]
HttpPostedFile fl = Request.Files("filefield");
string params = "Fit=True VAlign=middle HAlign=middle";

Canvas ca = new Canvas();
ca.Width = 300; // constrain width;
ca.DrawStream(fl.InputStream, fl.FileName, params);
ca.SaveAs(Server.MapPath("upload.jpg"), "");

The above takes a graphic file uploaded using an html upload. It constrains the width of the graphic and draws the data onto a canvas. Finally it saves the image out as a jpeg into the virtual directory of the web server.The following is an example of the html needed for the submitting form.

[HTML]
<form method="post" action="upload.aspx" name="submit" enctype="multipart/form-data">
  Choose a file to upload:<br>
  <input type="file" name="filefield" size="40"><br>
  <input type="submit" name="submit" value="submit"><br>
</form>