Click or drag to resize

AtalaImageViewerSave Method (Stream, ImageEncoder, ProgressEventHandler)

Saves the image into a stream using the provided encoder.

Namespace:  Atalasoft.Imaging.Wpf
Assembly:  Atalasoft.dotImage.Wpf (in Atalasoft.dotImage.Wpf.dll) Version: 11.4.0.9.0.377 (.NET 4.5.2, x86)
Syntax
public void Save(
	Stream stream,
	ImageEncoder encoder,
	ProgressEventHandler progress
)

Parameters

stream
Type: System.IOStream
A stream where the image will be saved.
encoder
Type: Atalasoft.Imaging.CodecImageEncoder
The ImageEncoder to use when saving the image.
progress
Type: Atalasoft.ImagingProgressEventHandler
A ProgressEventHandler used to provide progress during the save process. This can be null (Nothing in VB).
Exceptions
ExceptionCondition
Thrown if the stream or encoder argument is null (Nothing in VB).
Examples
 Private Sub OnSaveFile(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim dlg As Microsoft.Win32.SaveFileDialog = New Microsoft.Win32.SaveFileDialog()
    dlg.Filter = "PNG|*.png|HD Photo|*.wdp"
    If dlg.ShowDialog().Value Then
        Using fs As FileStream = New FileStream(dlg.FileName, FileMode.Create, FileAccess.Write)
            If dlg.FilterIndex = 1 Then
                Me.Viewer.Save(fs, New Atalasoft.Imaging.Codec.PngEncoder(), Nothing)
            Else
                Me.Viewer.Save(fs, New Atalasoft.Imaging.Codec.JpegXrEncoder(), Nothing)
            End If
        End Using
    End If
End Sub
 private void OnSaveFile(object sender, RoutedEventArgs e)
{
    Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
    dlg.Filter = "PNG|*.png|HD Photo|*.wdp";
    if (dlg.ShowDialog().Value)
    {
        using (FileStream fs = new FileStream(dlg.FileName, FileMode.Create, FileAccess.Write))
        {
            if (dlg.FilterIndex == 1)
                this.Viewer.Save(fs, new Atalasoft.Imaging.Codec.PngEncoder(), null);
            else
                this.Viewer.Save(fs, new Atalasoft.Imaging.Codec.JpegXrEncoder(), null);
        }
    }
}
See Also