GraphicsWrapper constructor.
Syntax

[C#]

GraphicsWrapper(Graphics inGraphics);

[Visual Basic]

Sub New(inGraphics As Graphics)
Params
Name Description
inGraphics The Graphics context to be wrapped.
Notes

This object wraps a System.Drawing Graphics context in a Canvas.

Due to the way that System.Drawing operates this object works with restrictions. Essentially the image is write only - you can draw using standard ImageGlue canvas methods but you cannot export or perform any draw operations which involve reading values from the canvas.

Use the Canvas property to gain access to the Canvas. Dispose the object or use the Unwrap method to unwrap the Graphics object.

You should not use the Graphics context while it is wrapped by a Canvas object.

Example

[C#]Bitmap bitmap = new Bitmap(Server.MapPath("rez/sunset.jpg"));
Graphics gr = Graphics.FromImage(bitmap);
using (GraphicsWrapper wrapper = new GraphicsWrapper(gr)) {
  wrapper.Canvas.DrawText("Hi there", new DrawOptions());
}
Pen pn = new Pen(Color.DarkGoldenrod, 8);
gr.DrawEllipse(pn, 10, 25, 125, 125);
pn.Color = Color.SteelBlue;
gr.DrawPie(pn, 10, 25, 125, 125, 45, 120);
bitmap.Save(Server.MapPath("GraphicsWrapper_106.jpg"));


[Visual Basic]Dim bitmap As New Bitmap(Server.MapPath("rez/sunset.jpg"))
Dim gr As Graphics = Graphics.FromImage(bitmap)
Using wrapper As New GraphicsWrapper(gr)
  wrapper.Canvas.DrawText("Hi there", New DrawOptions())
End Using
Dim pn As New Pen(Color.DarkGoldenrod, 8)
gr.DrawEllipse(pn, 10, 25, 125, 125)
pn.Color = Color.SteelBlue
gr.DrawPie(pn, 10, 25, 125, 125, 45, 120)
bitmap.Save(Server.MapPath("GraphicsWrapper_106.jpg"))


The code above wraps a Graphics object and uses the wrapper Canvas property to draw on the GDI context using ImageGlue calls. Do not use the Graphics object inside the using code block. The original and modified pictures are shown below.


sunset.jpg


GraphicsWrapper_106.jpg