In WPF, the System.Windows.Clipboard.getImage() function returns a BitmapSource object. As a newbie in WPF coming from a WinForms background, its not clear to me how to save this image to a file. What are the steps I must take?
In WPF, the System.Windows.Clipboard.getImage() function returns a BitmapSource object. As a newbie in WPF
Share
You need to use an encoder (subclass of
BitmapEncoder). For instance, to save it to the PNG format, you do something like that :By the way, note that there’s a bug in
Clipboard.GetImage. It shouldn’t be a problem if you just save the image to a file, but it will be if you want to display it.EDIT : the bug mentioned above seems to be fixed in 4.0