ImageGear for C and C++ on Linux v20.0 - Updated
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Info Functions > IG_page_count_get_mem

This function obtains the number of pages in the memory image file.


Copy Code
AT_ERRCOUNT ACCUAPI IG_page_count_get_mem(
   LPVOID lpImage,
   AT_UINT nImageSize,
   LPUINT lpPageCount


Name Type Description
lpImage LPVOID Pointer to start of file image in memory.
nImageSize AT_UINT Size of image in memory.
lpPageCount LPUINT Pointer to a UINT variable to receive page count.

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++.


Copy Code
char* lpBuffer;            // Memory buffer with the image
AT_UINT nBufferSize;    // Size of the memory buffer
UINT nPageCount;        // Will receive number of pages
AT_ERRCOUNT nErrcount;        // Returned count of errors

// Open a file and get its size
FILE* fp = NULL;
fopen_s(&fp, "picture.bmp", "rb");
if(fp != NULL)
    fseek(fp, 0, SEEK_END);
    nBufferSize = (AT_UINT)ftell(fp);
    fseek(fp, 0, SEEK_SET);
    // Allocate memory and read the image into the memory buffer
    lpBuffer = (char*)malloc(nBufferSize);
    fread(lpBuffer, 1, nBufferSize, fp);
    // File is no longer needed - close it
    // Get image info
    nErrcount = IG_page_count_get_mem(lpBuffer, nBufferSize, &nPageCount);

    // ...
    // Delete memory buffer


See also functions IG_page_count_get_FD and IG_page_count_get.

Is this page helpful?
Yes No
Thanks for your feedback.