This was the solution found by me:
private void guardarImagemDiscoDoPreviewButton_Click(object sender, RoutedEventArgs e)
{
//Save As Dialog ...
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "imagem";
dlg.DefaultExt = ".jpg";
dlg.Filter = "Imagem JPEG|*.jpg";
Nullable<bool> result = dlg.ShowDialog();
//Converter source da imagem num byte array
byte[] ImageData = getJPGFromImageControl(previewImage.Source as BitmapImage);
//Gravar a imagem no disco
using (Image image = Image.FromStream(new MemoryStream(ImageData)))
{
image.Save(dlg.FileName, ImageFormat.Jpeg); // Ou Png ...
}
}
public byte[] getJPGFromImageControl(BitmapImage imageC)
{
MemoryStream memStream = new MemoryStream();
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(imageC));
encoder.Save(memStream);
return memStream.ToArray();
}
In this case the Image control has the name foresight.