In this example, the entire Strokes collection from an Ink object associated with an InkOverlay object is drawn on to a bitmap image that has been loaded from a file.
Calling the Draw method does not display the image and the strokes. Instead, it merges the stroke rendering data with the bitmap image data in preparation for display. The bitmap image (now modified with stroke renderering data) is made visible by calling the DrawImage method of the Graphics object associated with a Panel object.
' get the Bitmap object loaded from a file
' scale the image to match the panel size
Dim bgImage As Bitmap = New Bitmap(New Bitmap(imageFileName), Me.panelForDraw.Size)
' place (draw) the stroke collection on the bitmap
' Access to the Ink.Strokes property returns a copy of the Strokes object.
' This copy must be implicitly (via using statement) or explicitly
' disposed of in order to avoid a memory leak.
Using allStrokes As Strokes = mInkOverlay.Ink.Strokes
mInkOverlay.Renderer.Draw(bgImage, allStrokes)
End Using
' now display the bitmap (with the strokes) on the panel
Using g As Graphics = Me.panelForDraw.CreateGraphics()
g.DrawImage(bgImage, 0, 0)
End Using
bgImage.Dispose()
// get the Bitmap object loaded from a file
// scale the image to match the panel size
Bitmap bgImage = new Bitmap(new Bitmap(imageFileName), this.panelForDraw.Size);
// place (draw) the stroke collection on the bitmap
// Access to the Ink.Strokes property returns a copy of the Strokes object.
// This copy must be implicitly (via using statement) or explicitly
// disposed of in order to avoid a memory leak.
using (Strokes allStrokes = mInkOverlay.Ink.Strokes)
{
mInkOverlay.Renderer.Draw(bgImage, allStrokes);
}
// now display the bitmap (with the strokes) on the panel
using (Graphics g = this.panelForDraw.CreateGraphics())
{
g.DrawImage(bgImage,0,0);
}
bgImage.Dispose();