Кодеки: Как конвертировать JPEG2000 в TIFF?
В этом разделе
VintaSoft Imaging .NET SDK позволяет сконвертировать JPEG2000 файл в TIFF файл с помощью класса
DocumentConverter,
ImageCollection или
Jpeg2000File. Использование класса
DocumentConverter обеспечивает наилучшую производительность, поскольку класс
DocumentConverter использует многопоточность.
Вот C#/VB.NET код, который демонстрирует, как преобразовать JPEG2000 изображение в TIFF изображение с помощью класса
DocumentConverter:
/// <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
Вот C#/VB.NET код, который демонстрирует, как преобразовать JPEG2000 изображение в TIFF изображение с помощью класса
ImageCollection:
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
Вот C#/VB.NET код, который демонстрирует, как преобразовать JPEG2000 изображение в TIFF изображение с помощью класса
Jpeg2000File:
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