Saving Bitmap Images in WPF via C#
I display images in my WPF app using BitmapImage
.
However, I would like an easy way to save these (as JPG) to a different location (ideally into a Stream
or object that can be passed around).
Is it possible using BitmapImage
or do I have to 开发者_如何学编程use other means? If so what other means are there for either loading an Image
and saving as JPG or converting a BitmapImage
into this element to then save off?
Thanks
Something like:
public byte[] GetJPGFromImageControl(BitmapImage imageC)
{
MemoryStream memStream = new MemoryStream();
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(imageC));
encoder.Save(memStream);
return memStream.GetBuffer();
}
(from: WPF Image to byte[])
精彩评论