ImageGear for C and C++ on Windows v20.0 - Updated
IG_load_thumbnail_mem
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.

Declaration:

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

Arguments:

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

Sample:

None

Example:

 
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
    fclose(fd);
}
// 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 
if(lpWhereFile)
{
    free(lpWhereFile);
}

//...

// Destroy images
if(IG_image_is_valid(hIGear1))
{
    IG_image_delete(hIGear1);
}
if(IG_image_is_valid(hIGear2))
{
    IG_image_delete(hIGear2);
}

Remarks:

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.