Saves the canvas image as raw data.
Syntax

[C#]

byte[] GetAs(string inType);
byte[] GetAs(string inType, XExport inExport);

[Visual Basic]

Function GetAs(inType As String) As Byte()
Function GetAs(inType As String, inExport As XExport) As Byte()
Params
Name Description
inType The export type.
inExport The export options.
return The data held as an array of bytes.
Notes

Use this method to export the Canvas to an array of data. When no export options are specified, the Export property is used.

See Also

SaveAs

Example

[C#]Canvas canvas = new Canvas(200, 200);
DrawOptions drawOpts = new DrawOptions();
drawOpts.PaintColor = new XColor(Color.Green);
drawOpts.PenColor = new XColor(Color.Red);
drawOpts.ShapeDrawing = DrawOptions.ShapeDrawingType.Both;
for (int i = 0; i <= 4; i++) {
  for (int j = 0; j <= 4; j++) {
    int r = (i * 50) + (j * 10);
    drawOpts.Transform.Reset();
    drawOpts.Transform.Rotate(r, 15, 15);
    drawOpts.Transform.Translate(j * 40, i * 40);
    canvas.DrawRect(30, 30, drawOpts);
  }
}
canvas.Export.UseAlpha = true;
Response.ContentType = "image/png";
Response.BinaryWrite(canvas.GetAs("getas.png"));


[Visual Basic]Dim canvas As New Canvas(200, 200)
Dim drawOpts As New DrawOptions()
drawOpts.PaintColor = New XColor(Color.Green)
drawOpts.PenColor = New XColor(Color.Red)
drawOpts.ShapeDrawing = DrawOptions.ShapeDrawingType.Both
For i As Integer = 0 To 4
  For j As Integer = 0 To 4
    Dim r As Integer = (i * 50) + (j * 10)
    drawOpts.Transform.Reset()
    drawOpts.Transform.Rotate(r, 15, 15)
    drawOpts.Transform.Translate(j * 40, i * 40)
    canvas.DrawRect(30, 30, drawOpts)
  Next
Next
canvas.Export.UseAlpha = True
Response.ContentType = "image/png"
Dim canvas As New Canvas(200, 200)
Dim drawOpts As New DrawOptions(DrawOptions.ShapeDrawingType.Both)
drawOpts.PenColor = New XColor(Color.Red)
drawOpts.PaintColor = New XColor(Color.Red)
canvas.DrawRect(New XRect(0, 0, 100, 100), drawOpts)
drawOpts.PenColor = New XColor(Color.Green)
drawOpts.PaintColor = New XColor(Color.Green)
canvas.DrawRect(New XRect(100, 0, 100, 100), drawOpts)
drawOpts.PenColor = New XColor(Color.Blue)
drawOpts.PaintColor = New XColor(Color.Blue)
canvas.DrawRect(New XRect(0, 100, 100, 100), drawOpts)
drawOpts.PenColor = New XColor(Color.Yellow)
drawOpts.PaintColor = New XColor(Color.Yellow)
canvas.DrawRect(New XRect(100, 100, 100, 100), drawOpts)
canvas.SaveAs(Server.MapPath("getcolor.gif"))
Dim theImage As New Canvas(Server.MapPath("getcolor.gif"))
Dim theColor As New XColor()
theColor = theImage.GetColor(New XPoint(50, 50))
Response.Write("Top Left Color is " & theColor.[String] & "<br>" & vbCr & vbLf)
theColor = theImage.GetColor(New XPoint(150, 50))
Response.Write("Top Right Color is " & theColor.[String] & "<br>" & vbCr & vbLf)
theColor = theImage.GetColor(New XPoint(50, 150))
Response.Write("Bottom Left Color is " & theColor.[String] & "<br>" & vbCr & vbLf)
theColor = theImage.GetColor(New XPoint(150, 150))
Response.Write("Bottom Left Color is " & theColor.[String] & "<br>" & vbCr & vbLf)


A sample output file is shown below.


getas.png