ImageMan DLL Suite Version 8Submit feedback on this topic   

Working with Multi-Page Documents

In this day of competing fax and scanner applications, it's no wonder that several of the common file formats have grown to support multi-page documents. The most common of these are TIFF, FlashPix, DCX and GIF, but any file format could conceivably be extended to support multiple pages in the future. To accommodate this, ImageMan supports a set of functions which allows your application to determine the number of pages in a given file and to easily navigate between these pages: ImgPageCount, ImgSetPage, and ImgGetPage. The following example shows how to use this in your application:

 

ImgPageCount(hImage, &nPages);

if (nPages > 1) { //it's a multi-page file

LPBITMAPINFO lpbi;

RECT r;

// loop through the images and draw each one

for (i=0; i<nPages; i++) {

// set-page uses 0-based offset

ImgSetPage(hImage, i);

// returns info for current page

lpbi = ImgGetInfo(hImage);

r.left = r.top = 0;

r.right = lpbi->bmiHeader.biWidth-1;

r.bottom = lpbi->bmiHeader.biHeight-1;

// palette could be different

hPal = ImgGetPalette(hImage);

SelectPalette(hDC, hPal, FALSE);

RealizePalette(hDC);

ImgDrawImage(hImage, hDC, &r, NULL);

}

} else {

// just 1 page in file

}

 

Note that the ImgGetInfo function returns different information for each page of the image, and also that it could be necessary to call the ImgGetPalette function for each page. It's important to call these functions after each ImgSetPage call to ensure that you've got the right information for the current page.

Note

We should point out that setting up the palette for monochrome images is rather worthless in the general case. Since most multi-page files are monochrome (faxes and such), you probably won't need to mess with the palette functions before drawing. The code fragment above includes this merely to illustrate that it may be required.

 

 

 


© 1995-2004 Data Techniques, Inc. All rights reserved.