Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Render InkCanvas to image file
// ***************************
// ***************************
// If I render the canvas directly the result includes the left menu area (and is blank).
// Got the idea from online to copy to a DrawingVisual and then render that.
DrawingVisual Drawing = new DrawingVisual();
// How come DrawingArea width is of type double?
// Does converting to int affect the render in any way?
int width = (int)DrawingArea.ActualWidth;
int height = (int)DrawingArea.ActualHeight;
using (DrawingContext DrawingContext = Drawing.RenderOpen())
VisualBrush Brush = new VisualBrush();
Brush.AutoLayoutContent = true;
Brush.Visual = DrawingArea;
DrawingContext.DrawRectangle(Brush, null, new Rect(0, 0, width, height));
// Read that "96 is the most common dpi for desktop displays."
RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.