ImageGear for C and C++ on Linux v18.8 - Updated
IG_tile_count_get_mem
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Info Functions > IG_tile_count_get_mem

This function gets the number of tiles constituting a page for file formats that support tiled pages for the image files located in the memory buffer.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_tile_count_get_mem(
   LPVOID lpImage,
   AT_UINT nImageSize,
   UINT nPageNum,
   LPUINT lpTileCountH,
   LPUINT lpTileCountV
);

Arguments:

Name Type Description
lpImage LPVOID Pointer to the start of the image file in memory.
nImageSize AT_UINT Size of image file in memory.
nPageNum UINT Page number for which to get the count of tiles.
lpTileCountH LPUINT Pointer to a UINT variable to receive the number of tiles horizontally (number of tiles in a row).
lpTileCountV LPUINT Pointer to a UINT variable to receive the number of tiles vertically (number of tiles in a column).

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 nTileRows;            // Will receive number of tile rows
UINT nTileCols;            // Will receive number of tile cols
AT_ERRCOUNT nErrcount;        // Returned count of errors

// Open a file and get its size
FILE* fp = NULL;
fopen_s(&fp, "picture_tiled.tif", "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_tile_count_get_mem(lpBuffer, nBufferSize, 1, &nTileRows, &nTileCols );
    fclose(fp);

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

Remarks:

Use this function when the file image is in memory.

The function returns 0 for both lpTileCountH and lpTileCountV if the image file format does not support tiled images.