Output format for decoded images: PNG, Jpeg, Tiff or Multipage-Tiff.

Namespace:  SautinSoft
Assembly:  SautinSoft.JBIG2 (in SautinSoft.JBIG2.dll) Version: 1.0.6.25 (1.0.6.25)

Syntax

      
 C#  Visual Basic 
public enum OutputImageFormat
Public Enumeration OutputImageFormat

Members

MemberDescription
Png
Decode JB2 to PNG.
Jpeg
Decode JB2 to Jpeg.
Tiff
Decode JB2 to Tiff.
MultipageTiff
Decode JB2 to Multipage-Tiff.

Examples

CopyHow to decode JB2 to PNG using C#
using System;
using System.IO;
using System.Collections.Generic;
using SautinSoft;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Decode JB2 file to PNG file
            string jb2File = Path.GetFullPath(Environment.CurrentDirectory+ @"..\..\..\..\..\..\Testing Files\1.jb2");
            byte[] jb2Data = File.ReadAllBytes(jb2File);

            SautinSoft.JBIG2 jbDecoder = new SautinSoft.JBIG2();
            // List with decoded page(s) as PNG image(s)
            List<byte[]> pngData = jbDecoder.DecodeToImages(jb2Data, false, JBIG2.OutputImageFormat.Png);

            for (int i = 0; i < pngData.Count; i++)
            {
                string pngFile = String.Format(@"{0}\page {1}.png", Path.GetDirectoryName(jb2File), i + 1);
                File.WriteAllBytes(pngFile, pngData[i]);
                System.Diagnostics.Process.Start(pngFile);
            }

        }
    }
}
CopyHow to decode JB2 to PNG using VB.Net
Imports System.IO
Imports System.Text
Imports System.Collections.Generic
Imports SautinSoft


Namespace SampleConvert
    Friend Class sample
        Shared Sub Main(ByVal args() As String)
            ' Decode JB2 file to PNG file
            Dim jb2File As String = Path.GetFullPath(Environment.CurrentDirectory & "..\..\..\..\..\..\Testing Files\1.jb2")
            Dim jb2Data() As Byte = File.ReadAllBytes(jb2File)

            Dim jbDecoder As New SautinSoft.JBIG2()
            ' List with decoded page(s) as PNG image(s)
            Dim pngData As List(Of Byte()) = jbDecoder.DecodeToImages(jb2Data, False, JBIG2.OutputImageFormat.Png)

            For i As Integer = 0 To pngData.Count - 1
                Dim pngFile As String = String.Format("{0}\page {1}.png", Path.GetDirectoryName(jb2File), i + 1)
                File.WriteAllBytes(pngFile, pngData(i))
                System.Diagnostics.Process.Start(pngFile)
            Next i
        End Sub
    End Class
End Namespace

See Also