Saves the canvas image as raw data.

 

   
Syntax
 
     

[Visual Basic]
Function GetAs(inType As String, inParams As String) As Byte()

[C#]
byte[] GetAs(string inType, string inParams);

 

   
Params
 
     
Name   Description
inType See the Type Image Manipulation parameter for ways of specifying types.
inParams A parameter string containing Image Export parameters.
return The data held as an array of bytes.

 

   
Notes
 
     

This works exactly the same way as the SaveAs method but instead of writing the image out to a file the function passes it back as raw data (an array of bytes).

You typically use a sample filename to specify the type of data required.

 

   
See Also
 
     

Canvas SaveAs method.
Gestalt Save method.

 

   
Example
 
     

[Visual Basic]
Dim ca As New Canvas
Dim myshape, myrot, mytra As String
Dim i, j As Integer
myshape = "Size=30,30 Operation=both PaintColor=green PenColor=red"
ca.Width = 200
ca.Height = 200
For i = 0 To 4
  For j = 0 To 4
    myrot = " Rotation=" + (i * 50).ToString() + (j * 10).ToString() + ",15,15"
    mytra = " Translate=" + (j * 40).ToString() + "," + (i * 40).ToString()
    ca.DrawShape("rect", myshape + myrot + mytra)
  Next
Next
Response.ContentType = "image/png"
Response.BinaryWrite(ca.GetAs("getas.png",""))

[C#]
Canvas ca = new Canvas();
string myshape = "Size=30,30 Operation=both PaintColor=green PenColor=red";
ca.Width = 200;
ca.Height = 200;
for (int i = 0; i <= 4; i++) {
  for (int j = 0; j <= 4; j++) {
    int r = (i * 50) + (j * 10);
    string myrot = " Rotation=" + r.ToString() + ",15,15";
    string mytra = " Translate=" + (j * 40).ToString() + "," + (i * 40).ToString();
    ca.DrawShape("rect", myshape + myrot + mytra);
  }
}
Response.ContentType = "image/png";
Response.BinaryWrite(ca.GetAs("getas.png",""));

A sample output file is shown below.

getas.png