VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
In This Topic
TIFF: How to add image to TIFF file?
In This Topic
Image can be added to TIFF file by several ways.


Here is C#/VB.NET code that shows how to add image to TIFF file using TiffEncoder class:
public void AddImageToTiff(System.IO.Stream stream, Vintasoft.Imaging.VintasoftImage image)
{
    // add image TIFF file
    using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder encoder = 
        new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(false))
    {
        // use LZW compression
        encoder.Settings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Lzw;

        // add image to TIFF file
        encoder.SaveImage(image, stream);
    }
}
Public Sub AddImageToTiff(stream As System.IO.Stream, image As Vintasoft.Imaging.VintasoftImage)
    ' add image TIFF file
    Using encoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(False)
        ' use LZW compression
        encoder.Settings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Lzw

        ' add image to TIFF file
        encoder.SaveImage(image, stream)
    End Using
End Sub


Here is C#/VB.NET code that shows how to add image to TIFF file using TiffFile class:
public void AddImageToTiff(System.IO.Stream stream, Vintasoft.Imaging.VintasoftImage image)
{
    // open existing TIFF file
    using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile tiff = 
        new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(stream))
    {
        // use LZW compression
        tiff.Pages.EncoderSettings.Compression = 
            Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Lzw;

        // add image to TIFF file
        tiff.Pages.Add(image);

        // save changes
        tiff.SaveChanges();
    }
}
Public Sub AddImageToTiff(stream As System.IO.Stream, image As Vintasoft.Imaging.VintasoftImage)
    ' open existing TIFF file
    Using tiff As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(stream)
        ' use LZW compression
        tiff.Pages.EncoderSettings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Lzw

        ' add image to TIFF file
        tiff.Pages.Add(image)

        ' save changes
        tiff.SaveChanges()
    End Using
End Sub


Here is C#/VB.NET code that shows how to add image to TIFF file using VintasoftImage and TiffEncoder classes:
public void AddImageToTiff(System.IO.Stream stream, Vintasoft.Imaging.VintasoftImage image)
{
    // add image TIFF file
    using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder encoder = 
        new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(false))
    {
        // use LZW compression
        encoder.Settings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Lzw;

        // add image to TIFF file
        encoder.SaveImage(image, stream);
    }
}
Public Sub AddImageToTiff(stream As System.IO.Stream, image As Vintasoft.Imaging.VintasoftImage)
    ' add image TIFF file
    Using encoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(False)
        ' use LZW compression
        encoder.Settings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Lzw

        ' add image to TIFF file
        encoder.SaveImage(image, stream)
    End Using
End Sub