VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging Namespace / ImageCollection Class / SaveSync Method / SaveSync(Stream,EncoderBase) Method
Stream where the image collection should be saved.
Encoder to the save images.
Example



In This Topic
    SaveSync(Stream,EncoderBase) Method
    In This Topic
    Saves synchronously all images from this collection to specified stream using the specified Vintasoft.Imaging.Codecs.Encoders.EncoderBase.
    Syntax
    'Declaration
     
    Public Overloads Sub SaveSync( _
       ByVal stream As Stream, _
       ByVal encoder As EncoderBase _
    ) 
    public void SaveSync( 
       Stream stream,
       EncoderBase encoder
    )
    public: void SaveSync( 
       Stream* stream,
       EncoderBase* encoder
    ) 
    public:
    void SaveSync( 
       Stream^ stream,
       EncoderBase^ encoder
    ) 

    Parameters

    stream
    Stream where the image collection should be saved.
    encoder
    Encoder to the save images.
    Exceptions
    ExceptionDescription
    Thrown if stream is null.
    Thrown if image collection does not contain images or another saving process is executing at this moment.
    Thrown if error occurs at saving the image.
    Remarks
    This method works synchronously.

    Supported image formats: JBIG2, PDF, TIFF.

    This method
    • saves images to the stream specified by stream using encoder
    • stream is overwritten if it is not empty
    • saving process can be canceled, saving of images can be suppressed
    • sources of images in the image collection are not changed, i.e. images[i].SourceInfo.Stream is not changed
    if
    • stream != images[0]..SourceInfo.Stream
    • SaveAndSwitchSource is false
    • encoder.CreateNewFile is true

    This method
    • adds images to existing stream specified by stream using encoder
    • saving process can be canceled, saving of images can be suppressed
    • sources of images in the image collection are not changed, i.e. images[i].SourceInfo.Stream is not changed
    if
    • stream != images[0]..SourceInfo.Stream
    • SaveAndSwitchSource is false
    • encoder.CreateNewFile is false

    This method
    • saves images to the new stream specified by stream using encoder
    • stream is overwritten if it is not empty
    • saving process cannot be canceled, saving of images cannot be suppressed
    • sources of images in the image collection are changed, i.e. images[i].SourceInfo.Stream is changed to stream
    if
    This method
    • changes images in the source stream if some images of source file are changed in the image collection
    • removes images from the source stream if some images of source file are removed from the image collection
    • adds images to the source stream if some images of NOT from the source file are added to the image collection
    • reindex images in the source stream if images are reindexed in the image collection
    • saving process cannot be canceled, saving of images cannot be suppressed
    • sources of images in the image collection is changed, i.e. images[i].SourceInfo.Stream is changed to stream
    if
    This method
    • throw an exception
    if
    ImageSaving event will occur before saving of each image. In this event you can get information about the image, suppress image saving or cancel image saving process.
    ImageSaved event will occur after saving of each image. In this event you can get information about progress of images saving process or cancel image saving process.
    Example
    This example illustrates how to save the image collection synchronously.
    ' open a stream
    Dim stream As New System.IO.FileStream("new-file-name.tif", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite)
    ' create an encoder
    Using encoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder()
        ' specify that image collection should be switched to a stream
        encoder.SaveAndSwitchSource = True
        ' save image collection to a TIFF file
        imageViewer1.Images.SaveSync(stream, encoder)
        ' close a stream
        stream.Close()
    End Using
    // open a stream
    System.IO.FileStream stream = new System.IO.FileStream(
        "new-file-name.tif", 
        System.IO.FileMode.OpenOrCreate, 
        System.IO.FileAccess.ReadWrite);
    // create an encoder
    using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder encoder =
        new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder())
    {
        // specify that image collection should be switched to a stream
        encoder.SaveAndSwitchSource = true;
        // save image collection to a TIFF file
        imageViewer1.Images.SaveSync(stream, encoder);
        // close a stream
        stream.Close();
    }
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also