![]() |
|
exporting bitmap - Printable Version +- AB4D Forum (https://forum.ab4d.com) +-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4) +--- Forum: ViewerSvg and Ab2d.ReaderSvg (https://forum.ab4d.com/forumdisplay.php?fid=6) +--- Thread: exporting bitmap (/showthread.php?tid=86) |
exporting bitmap - gobler - 03-17-2011 ViewerSvg has a feature to export a Canvas as a PNG file. I expected an equivalent method to be available on ReaderSvg, but I do not see one. When I use the Export Image feature in ViewerSvg, the resulting bitmap is much smaller than what's rendered in the view. Is there a way to control this? Thanks. RE: exporting bitmap - abenedik - 03-17-2011 Rendering any WPF Visual element can be done with WPF's RenderTargetBitmap. The following two methods can be used to render the element to a bitmap and to save the image to disk. Code: public static BitmapSource RenderImage(FrameworkElement objectToRender, int width, int height, Brush backgroundBrush)Note that the width and height that are passed to RenderImage method do not scale the element to be that size - its ActualWidtha and ActualHeight is used in the output image. To render the element to a custom size a VisualBrush can be used - check the following: http://stackoverflow.com/questions/222756/scaling-wpf-content-before-rendering-to-bitmap |