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

This function loads a thumbnail from the image located in a memory buffer.


Copy Code
AT_ERRCOUNT ACCUAPI IG_load_thumbnail_mem(
   LPVOID lpImage,
   AT_UINT nSize,
   LPHIGEAR lphIGear


Name Type Description
lpImage LPVOID Pointer to start of the image in memory.
nSize AT_UINT Size of image in memory.
lphIGear LPHIGEAR Pointer to HIGEAR variable to receive handle.

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
HIGEAR hIGear1 = 0;       /* handle ret'd by IG_load_mem  */
HIGEAR hIGear2 = 0;       /* ret'd by IG_load_thumbnail_mem  */
char far * lpWhereFile = NULL;    /* ptr to image file in mem   */
AT_UINT  nImageSize;   /* Size of image in memory */
AT_ERRCOUNT nErrcount;/* to test for errors         */

// Open a file and get its size
FILE* fd;
fopen_s(&fd, "picture.bmp", "rb");
if(fd != NULL)
    fseek(fd, 0, SEEK_END);
    nImageSize = (AT_UINT)ftell(fd);
    fseek(fd, 0, SEEK_SET);
    // Allocate memory and read the image into the memory buffer
    lpWhereFile = (char*)malloc(nImageSize);
    fread(lpWhereFile, 1, nImageSize, fd);
    // File is no longer needed - close it
// Load image from the memory
nErrcount = IG_load_mem(lpWhereFile, nImageSize, 1, 0, &hIGear1);
if ( nErrcount == 0 )
    nErrcount = IG_load_thumbnail_mem(lpWhereFile, nImageSize, &hIGear2); 
// delete memory 


// Destroy images


The handle of the resulting image is returned to the HIGEAR variable pointed to by argument lphIGear. See also functions IG_load_thumbnail, and IG_save_thumbnail_set.

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