Decodes JB2 document (byte array) into a set of images.

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

Syntax

      
 C#  Visual Basic 
public List<byte[]> DecodeToImages(
	byte[] data,
	bool embedded,
	JBIG2..::.OutputImageFormat outputImageFormat
)
Public Function DecodeToImages ( _
	data As Byte(), _
	embedded As Boolean, _
	outputImageFormat As JBIG2..::.OutputImageFormat _
) As List(Of Byte())

Parameters

data
array< Byte >[]()[]
JB2 document as a byte array.
embedded
Boolean
Embedded.
outputImageFormat
JBIG2..::.OutputImageFormat
Output image format.

Return Value

A List<[byte]> with decoded page(s). Each page represented as a byte array.

Examples

CopyHow to decode JB2 to Jpeg 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 Jpeg 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 Jpeg image(s)
            List<byte[]> jpegData = jbDecoder.DecodeToImages(jb2Data, false, JBIG2.OutputImageFormat.Jpeg);

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

        }
    }
}
CopyHow to decode JB2 to Jpeg 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 Jpeg 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 Jpeg image(s)
            Dim jpegData As List(Of Byte()) = jbDecoder.DecodeToImages(jb2Data, False, JBIG2.OutputImageFormat.Jpeg)

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

See Also