views:

83

answers:

1

Hey

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

+1  A: 

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: http://stackoverflow.com/questions/553611/wpf-image-to-byte)

Iain
Thankyou this worked a treat
Chris