VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging Namespace / VintasoftImage Class / Save Method / Save(Stream,EncoderBase) Method
Stream where the image should be saved.
Encoder to save the image.
Example



In This Topic
    Save(Stream,EncoderBase) Method
    In This Topic
    Saves this VintasoftImage object to the specified stream using specified encoder.
    Syntax
    'Declaration
     
    Public Overloads Sub Save( _
       ByVal stream As Stream, _
       ByVal encoder As EncoderBase _
    ) 
    public void Save( 
       Stream stream,
       EncoderBase encoder
    )
    public: void Save( 
       Stream* stream,
       EncoderBase* encoder
    ) 
    public:
    void Save( 
       Stream^ stream,
       EncoderBase^ encoder
    ) 

    Parameters

    stream
    Stream where the image should be saved.
    encoder
    Encoder to save the image.
    Exceptions
    ExceptionDescription
    Thrown if stream or encoder is null.
    Thrown if error occurs at saving the image.
    Remarks
    Supported image formats: BMP, GIF, JBIG2, JPEG, PCX, PDF, PNG, TIFF.

    Suitable encoder is selected automatically from the extension of the filename, exception is thrown if encoder is not found for file extension specified in filename.

    If image is saving to new file (stream != SourceInfo.Stream) this method:
    If image is saving to the source file (stream == SourceInfo.Stream) this method:
    • saves image to the source BMP/GIF/JBIG2/JPEG/PCX/PDF/PNG/TIFF file if image is changed (IsChanged = true) and source file contains only one image
    • throws an exception if image is saved to the source BMP/GIF/JBIG2/JPEG/PCX/PDF/PNG/TIFF file and image is not changed (IsChanged = false)
    • adds image to the source JBIG2/PDF/TIFF file if Vintasoft.Imaging.Codecs.Encoders.MultipageEncoderBase.CreateNewFile = false, file specified by filename is exist
    Example
    This example shows how to load image from disk and save it to memory as JPEG stream.
    ' load image from file
    Using image As New Vintasoft.Imaging.VintasoftImage("c:\original-image.tif")
    	Dim memory As New System.IO.MemoryStream()
    	' create JPEG encoder
    	Dim encoder As New Vintasoft.Imaging.Codecs.Encoders.JpegEncoder(New Vintasoft.Imaging.Codecs.Encoders.JpegEncoderSettings(10))
    	' save annotations with image
    	encoder.AnnotationsFormat = Vintasoft.Imaging.AnnotationsFormat.VintasoftBinary
    	' save image to file
    	image.Save(memory, encoder)
    End Using
    // load image from file
    using (Vintasoft.Imaging.VintasoftImage image =
        new Vintasoft.Imaging.VintasoftImage(@"c:\original-image.tif"))
    {
        System.IO.MemoryStream memory = new System.IO.MemoryStream();
        // create JPEG encoder
        Vintasoft.Imaging.Codecs.Encoders.JpegEncoder encoder =
            new Vintasoft.Imaging.Codecs.Encoders.JpegEncoder(
                new Vintasoft.Imaging.Codecs.Encoders.JpegEncoderSettings(10));
        // save annotations with image
        encoder.AnnotationsFormat = Vintasoft.Imaging.AnnotationsFormat.VintasoftBinary;
        // save image to file
        image.Save(memory, encoder);
    }
    Requirements

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

    See Also