[VB.NET/C#] Convert Multipage TIFF to Multipage JBIG2

Example requests & Code samples for GdPicture Toolkits.
Post Reply
User avatar
Loïc
Site Admin
Posts: 5570
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

[VB.NET/C#] Convert Multipage TIFF to Multipage JBIG2

Post by Loïc » Sat Jan 15, 2011 3:29 pm

Hi,

Here a quick way to convert multipage TIFF image to a multipage JBIG2 image with GdPicture SDK (including the latest V10 major release).

Using VB.NET

Code: Select all

Dim oGdPictureImaging As New GdPictureImaging

Dim TiffID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("c:\multipage.tif")
Dim Jbig2ID As Integer = 0
For i As Integer = 1 To oGdPictureImaging.TiffGetPageCount(TiffID)
	If i = 1 Then
		Jbig2ID = oGdPictureImaging.CreateClonedGdPictureImageI(TiffID)
		oGdPictureImaging.JBIG2SaveAsMultiPageFile(Jbig2ID, "c:\multipage.jb2")
	Else
		oGdPictureImaging.TiffSelectPage(TiffID, i)
		oGdPictureImaging.JBIG2AddToMultiPageFile(Jbig2ID, TiffID)
	End If
Next
oGdPictureImaging.JBIG2CloseMultiPageFile(Jbig2ID)
oGdPictureImaging.ReleaseGdPictureImage(TiffID)
oGdPictureImaging.ReleaseGdPictureImage(Jbig2ID)

MessageBox.Show("done")
Or using C#

Code: Select all

GdPictureImaging oGdPictureImaging = new GdPictureImaging();

int TiffID = oGdPictureImaging.CreateGdPictureImageFromFile("c:\\multipage.tif");
int Jbig2ID = 0;
for (int i = 1; i <= oGdPictureImaging.TiffGetPageCount(TiffID); i++) {
	if (i == 1) {
		Jbig2ID = oGdPictureImaging.CreateClonedGdPictureImageI(TiffID);
		oGdPictureImaging.JBIG2SaveAsMultiPageFile(Jbig2ID, "c:\\multipage.jb2");
	} else {
		oGdPictureImaging.TiffSelectPage(TiffID, i);
		oGdPictureImaging.JBIG2AddToMultiPageFile(Jbig2ID, TiffID);
	}
}
oGdPictureImaging.JBIG2CloseMultiPageFile(Jbig2ID);
oGdPictureImaging.ReleaseGdPictureImage(TiffID);
oGdPictureImaging.ReleaseGdPictureImage(Jbig2ID);

MessageBox.Show("done");

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest