ImageGear for C and C++ on Windows v19.10 - Updated
IG_fltr_pagecount_FD_format
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Filter Functions > IG_fltr_pagecount_FD_format

This function obtains the number of pages in the open multi-page file.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_fltr_pagecount_FD_format(
   AT_MODE nFormat,
   AT_INT fd,
   LONG lOffset,
   LPUINT lpPageCount
);

Arguments:

Name Type Description
nFormat AT_MODE A constant indicating the file format of the input file. See enumIGFormats for possible values. Set to IG_FORMAT_UNKNOWN to let ImageGear detect the file format.
fd AT_INT Handle of the open file containing the image. This handle can be obtained from Microsoft Windows functions such as CreateFile(), and cast to AT_INT for passing to the function parameter. FILE pointers returned by functions such as fopen(), and file handles returned by functions such as _sopen_s() are not supported.
lOffset LONG Offset to the image in the file.
lpPageCount LPUINT Return: Number of pages in an image.

Return Value:

Returns 0 if successful. Otherwise, returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Sample:

None

Example:

 
Copy Code
UINT nPageCount;
AT_ERRCOUNT nErrCount;

HANDLE      fd;        //File Descriptor
fd = CreateFile(_T("picture.tif"), GENERIC_READ,
        0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(fd != INVALID_HANDLE_VALUE)
{
    nErrCount = IG_fltr_pagecount_FD_format(IG_FORMAT_TIF, (AT_INT)fd, 0, &nPageCount);
    CloseHandle(fd);
}

Remarks:

This function is similar to the IG_page_count_get_FD function, but has an additional parameter, nFormat, which specifies the file format of the input file.

If nFormat = IG_FORMAT_UNKNOWN then ImageGear attempts to detect the file format automatically, and then loads the image. Otherwise, ImageGear skips the file format detection and gets the page count using the specified format filter.