1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.DefaultExt = ".bmp";
dlg.Filter = "Bitmap Windows ou OS/2(*.bmp)|*.bmp|Format JPEG(*.jpg)|*.jpg|Format GIF(*.gif)|*.gif|Portable Network Graphic(*.png)|*.png";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
string filename = dlg.FileName;
FileStream stream = new FileStream(filename, FileMode.Create);
RenderTargetBitmap rtb = new RenderTargetBitmap((int)IVSImage.Source.Width, (int)IVSImage.Source.Height, 96, 96, PixelFormats.Pbgra32);
rtb.Render(IVSImage);
JpegBitmapEncoder bmpencoder = new JpegBitmapEncoder();
bmpencoder.Frames.Add(BitmapFrame.Create(rtb));
bmpencoder.Save(stream);
stream.Close();
} |