VintaSoft Imaging .NET SDK 12.3: Documentation for .NET developer
Vintasoft.Imaging Namespace / VintasoftImage Class / Save Methods / Save(String,EncoderBase) Method
Syntax Exceptions Remarks Example Requirements SeeAlso
In This Topic
    Save(String,EncoderBase) Method (VintasoftImage)
    In This Topic
    Saves this VintasoftImage object to the specified path using specified encoder.
    Syntax
    'Declaration
    
    Public Overloads Sub Save( _
    ByVal filename
    Filename where the image should be saved.
    As System.String, _
    ByVal encoder
    Encoder to save the image.
    As Vintasoft.Imaging.Codecs.Encoders.EncoderBase _
    )

    Parameters

    filename
    Filename where the image should be saved.
    encoder
    Encoder to save the image.
    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:

    • saves image to new BMP/GIF/JBIG2/JPEG/PCX/PDF/PNG/TIFF file if MultipageEncoderBase.CreateNewFile = true; file specified by filename is replaced if it exists
    • saves image to new JBIG2/PDF/TIFF file if MultipageEncoderBase.CreateNewFile = false and file specified by filename is not exist
    • adds image to new JBIG2/PDF/TIFF file if MultipageEncoderBase.CreateNewFile = false and file specified by filename is exist

    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 MultipageEncoderBase.CreateNewFile = false, file specified by filename is exist

    Example

    This C#/VB.NET code shows how to load image with XMP annotations from disk and save image as TIFF file with WANG annotations.

    
    ' 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);
    }
    
    
    This C#/VB.NET code 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:\original-image.tif")
        ' copy image to clipboard
        System.Windows.Forms.Clipboard.SetImage(Vintasoft.Imaging.VintasoftImageGdiExtensions.GetAsBitmap(image))
    
        ' process image in external image editor and place it back to the clipboard
        ' ...
    
        ' get image from the clipboard
        image.SetImage(Vintasoft.Imaging.VintasoftImageGdiExtensions.Create(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(Vintasoft.Imaging.VintasoftImageGdiExtensions.GetAsBitmap(image));
    
        // process image in external image editor and place it back to the clipboard
        // ...
    
        // get image from the clipboard
        image.SetImage(Vintasoft.Imaging.VintasoftImageGdiExtensions.Create(
            System.Windows.Forms.Clipboard.GetImage(), true));
    
        // save image to the file
        image.Save(@"c:\processed-image.jpg");
    }
    
    

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also