ImageGear for C and C++ on Linux v18.8 - Updated
IG_page_count_get_mem
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.

Declaration:

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

Arguments:

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

Example:

 
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
    fclose(fp);
    // Get image info
    nErrcount = IG_page_count_get_mem(lpBuffer, nBufferSize, &nPageCount);
    fclose(fp);

    // ...
    // Delete memory buffer
    free(lpBuffer);
}

Remarks:

See also functions IG_page_count_get_FD and IG_page_count_get.