VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
In This Topic
Codecs: How to convert JPEG2000 to TIFF?
In This Topic
VintaSoft Imaging .NET SDK allows to convert JPEG2000 file to a TIFF document using class DocumentConverter, ImageCollection or Jpeg2000File. Usage of DocumentConverter class provides the best performance because DocumentConverter class uses multi-threading.

Here is C#/VB.NET code that shows how to convert JPEG2000 image to TIFF image using DocumentConverter class:
/// <summary>
/// Converts JPEG2000 file to a TIFF file using Vintasoft.Imaging.DocumentConverter class.
/// </summary>
public static void ConvertJpeg2000ToTiff_DocumentConverter(string jpeg2000Filename, string tiffFilename)
{
    Vintasoft.Imaging.DocumentConverter.Convert(jpeg2000Filename, tiffFilename);
}
''' <summary>
''' Converts JPEG2000 file to a TIFF file using Vintasoft.Imaging.DocumentConverter class.
''' </summary>
Public Shared Sub ConvertJpeg2000ToTiff_DocumentConverter(jpeg2000Filename As String, tiffFilename As String)
    Vintasoft.Imaging.DocumentConverter.Convert(jpeg2000Filename, tiffFilename)
End Sub


Here is C#/VB.NET code that shows how to convert JPEG2000 image to TIFF image using ImageCollection class:
public static void ConvertJpeg2000ToTiff_ImageCollection(string jpeg2000Filename, string tiffFilename)
{
    // create image collection
    using (Vintasoft.Imaging.ImageCollection imageCollection =
        new Vintasoft.Imaging.ImageCollection())
    {
        // add JPEG2000 file to collection
        imageCollection.Add(jpeg2000Filename);
        // create Tiff encoder
        using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder tiffEncoder =
            new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder())
        {
            // set Tiff compression to ZIP
            tiffEncoder.Settings.Compression =
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip;
            // add pages of JPEG2000 file to TIFF file using Tiff encoder
            imageCollection.SaveSync(tiffFilename, tiffEncoder);
        }
    }
}
Public Shared Sub ConvertJpeg2000ToTiff_ImageCollection(jpeg2000Filename As String, tiffFilename As String)
    ' create image collection
    Using imageCollection As New Vintasoft.Imaging.ImageCollection()
        ' add JPEG2000 file to collection
        imageCollection.Add(jpeg2000Filename)
        ' create Tiff encoder
        Using tiffEncoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder()
            ' set Tiff compression to ZIP
            tiffEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip
            ' add pages of JPEG2000 file to TIFF file using Tiff encoder
            imageCollection.SaveSync(tiffFilename, tiffEncoder)
        End Using
    End Using
End Sub


Here is C#/VB.NET code that shows how to convert JPEG2000 image to TIFF image using Jpeg2000File class:
public static void ConvertJpeg2000ToTiff_Jpeg2000File(string jpeg2000Filename, string tiffFilename)
{
    using (System.IO.FileStream stream = new System.IO.FileStream(
        jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
    {
        if (!Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File.IsValidFormat(stream))
            throw new System.ApplicationException();

        using (Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File file = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(stream))
        {
            using (Vintasoft.Imaging.VintasoftImage image = file.Page.GetImage())
            {
                using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder tiffEncoder = 
                    new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder())
                {
                    image.Save(tiffFilename, tiffEncoder);
                }
            }
        }
    }
}
Public Shared Sub ConvertJpeg2000ToTiff_Jpeg2000File(jpeg2000Filename As String, tiffFilename As String)
    Using stream As New System.IO.FileStream(jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)
        If Not Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File.IsValidFormat(stream) Then
            Throw New System.ApplicationException()
        End If

        Using file As New Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(stream)
            Using image As Vintasoft.Imaging.VintasoftImage = file.Page.GetImage()
                Using tiffEncoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder()
                    image.Save(tiffFilename, tiffEncoder)
                End Using
            End Using
        End Using
    End Using
End Sub