I’m trying to convert a visual to a Ximage(to print on pdf).
Currently I’m using this:
Dim img As XImage = XImage.FromFile(path.LocalPath)
But it requires me to save it on the harddrive
I would like to use this but I don’t know how to create a image from a visual(in memory) and load it in.
Dim img As XImage = XImage.FromGdiPlusImage(myVisualAsImage)
If you use the WPF build of PDFsharp, you can also use:
Several classes (including BitmapImage and WriteableBitmap) are derived from BitmapSource and can also be passed here.
See also:
http://ryancdavidson.com/blog/2009/09/getting-and-using-the-pixels-of-your-visual-in-wpf/