Jonathan.Peppers

How can I save a ImageSource, BitmapSource, or BitmapImage to a file.

I have an Image in which the source originally came from another file that contained serialized GDI+ System.Drawing.Bitmaps.

Now I need to save the image to a ".bmp", ".png" or some other format.

How can I do this with performance in mind I can obviously convert it back to a System.Drawing.Bitmap and call bitmap.Save(), but is there a better way



Re: Windows Presentation Foundation (WPF) Save an ImageSource/BitmapSource/BitmapImage to file

WPCoder

Take a look at the JpegBitmapEncoder class as an example of how to save a Bitmap to a jpeg. There are other encoders as well, such as PNG.





Re: Windows Presentation Foundation (WPF) Save an ImageSource/BitmapSource/BitmapImage to file

Jonathan.Peppers

Wow, can't believe I never knew about those classes.

Thanks!