VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging Namespace / VintasoftImage Class / Save Method / Save(String,EncoderBase,EventHandler<ProgressEventArgs>) Method
Filename where the image should be saved.
Encoder to save the image.
Delegate of the image saving progress. Can be set to null (Nothing in Visual Basic).
Example



In This Topic
    Save(String,EncoderBase,EventHandler<ProgressEventArgs>) Method
    In This Topic
    Saves this VintasoftImage object to the specified path using specified encoder.
    Syntax
    'Declaration
     
    Public Overloads Sub Save( _
       ByVal filename As String, _
       ByVal encoder As EncoderBase, _
       ByVal savingProgress As EventHandler(Of ProgressEventArgs) _
    ) 

    Parameters

    filename
    Filename where the image should be saved.
    encoder
    Encoder to save the image.
    savingProgress
    Delegate of the image saving progress. Can be set to null (Nothing in Visual Basic).
    Exceptions
    ExceptionDescription
    Thrown if filename 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 (filename != SourceInfo.Filename) this method:
    If image is saving to the source file (filename == SourceInfo.Filename) 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 with XMP annotations from disk and save image as TIFF file with WANG annotations. This example shows how to load image from disk and save it as JPEG file with 10% quality.
    ' load image from file
    Using image As New Vintasoft.Imaging.VintasoftImage("c:\imageWithXmpAnnotations.tif")
        ' create TIFF encoder
        Dim encoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(False)
        ' save annotations in WANG format
        encoder.AnnotationsFormat = Vintasoft.Imaging.AnnotationsFormat.Wang
        ' save image to file
        image.Save("c:\imageWithWangAnnotations.tif", encoder)
    End Using
    // load image from file
    using (Vintasoft.Imaging.VintasoftImage image =
        new Vintasoft.Imaging.VintasoftImage(@"c:\imageWithXmpAnnotations.tif"))
    {
        // create TIFF encoder
        Vintasoft.Imaging.Codecs.Encoders.TiffEncoder encoder =
            new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(false);
        // save annotations in WANG format
        encoder.AnnotationsFormat = Vintasoft.Imaging.AnnotationsFormat.Wang;
        // save image to file
        image.Save(@"c:\imageWithWangAnnotations.tif", encoder);
    }
    ' load image from file
    Using image As New Vintasoft.Imaging.VintasoftImage("c:\original-image.tif")
        ' copy image to clipboard
        System.Windows.Forms.Clipboard.SetImage(image.GetAsBitmap())
                
        ' process image in external image editor and place it back to the clipboard
        ' ...
                
        ' get image from the clipboard
        image.SetImage(New Vintasoft.Imaging.VintasoftImage(System.Windows.Forms.Clipboard.GetImage(), True))
                
        ' save image to the file
        image.Save("c:\processed-image.jpg")
    End Using
    // load image from file
    using (Vintasoft.Imaging.VintasoftImage image =
        new Vintasoft.Imaging.VintasoftImage(@"c:\original-image.tif"))
    {
        // copy image to clipboard
        System.Windows.Forms.Clipboard.SetImage(image.GetAsBitmap());
                
        // process image in external image editor and place it back to the clipboard
        // ...
                
        // get image from the clipboard
        image.SetImage(new Vintasoft.Imaging.VintasoftImage(
            System.Windows.Forms.Clipboard.GetImage(), true));
                
        // save image to the file
        image.Save(@"c:\processed-image.jpg");
    }
    Requirements

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

    See Also