Reputation: 463
I am developing a paint like application in metro style with C#/XAML. I want to save whatever content is drawn on canvas as image. I have checked this solutions but it didn't helped me.
Save canvas to bitmap http://blogs.msdn.com/b/saveenr/archive/2008/09/18/wpf-xaml-saving-a-window-or-canvas-as-a-png-bitmap.aspx
So how can I save the canvas content as image ? Please help me with sample coding.
Upvotes: 2
Views: 4566
Reputation: 15042
The accepted answer from Sascha is no longer true for Windows 8.1. There is a new RenderTargetBitmap class that allows Rendered XAML to be converted to a bitmap.
However I can't seem to render that XAML is Collapsed or otherwise not currently on screen. Any help with that would be appreciated!
Upvotes: 1
Reputation: 10347
It seems it is currently not supported out of the box like we were used to do it with WPF:
While when doing HTML5/Javascript Metro apps you can do this:
Upvotes: 0
Reputation: 31724
One workaround is to use Direct2D with DirectWrite. It is a bit involved, but I might make a library available at some point.
Upvotes: 0
Reputation: 10609
The standard approach in other xaml frameworks such as Silverlight and WP7 was to use WriteableBitmap, however the version in WinRT doesn't have a constructor that takes a xaml element which leads me to believe that it's currently impossible against the latest API.
Sorry I couldn't be more help/
Upvotes: 0