#include "l_bitmap.h"

L_LTFIL_API L_INT L_CreateThumbnailFromFile(pszFile, pBitmap, uStructSize, pThumbOptions, pfnCallback, pUserData, pLoadOptions, pFileInfo)

Creates a thumbnail from the specified image file.


L_TCHAR* pszFile

Character string containing the name of the file to load.


Pointer to the bitmap handle for the loaded data.

L_UINT uStructSize

Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).


Pointer to a structure containing thumbnail generation options. Pass NULL to get the default options.


Optional callback function for additional processing.

If you do not provide a callback function, use NULL as the value of this parameter. If you do provide a callback function, use the function pointer as the value of this parameter. The callback function must adhere to the function prototype described in FILEREADCALLBACK Function.

L_VOID* pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID  *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

If the additional parameters are not needed, you can pass NULL in this parameter.


Pointer to optional extended load options. Pass NULL to use the default load options.


Pointer to a FILEINFO structure. This structure may contain file information used in loading an image, or it may be updated with information about the file being loaded.

If nothing is known about the file, pass NULL for this parameter, or declare a variable of type FILEINFO and set the FILEINFO. Flags to 0, then pass the address of the FILEINFO structure in this parameter. In this case, if the address of a FILEINFO structure is passed, the FILEINFO structure will be updated with the results of L_FileInfo.

If only the file type is known, set pFileInfo.Format to the file type and set pFileInfo.Flags to FILEINFO_FORMATVALID. This can also be done if L_FileInfo has been called previously, but values that affect the size of the image loaded have been changed (for example, by calling L_SetPCDResolution or L_SetWMFResolution). In this case the FILEINFO structure pointed to by pFileInfo will be updated with the results of L_FileInfo.

If L_FileInfo has been called prior to calling this function, and no changes have been made to the contents of the structure filled by L_FileInfo, then the address of the filled FILEINFO structure can be passed for this parameter. In this case, the FILEINFO.Flags member should be set to FILEINFO_INFOVALID. The L_FileInfo function will set the FILEINFO.Flags to FILEINFO_INFOVALID. In this case the load will be faster since this function does not have to query the file filters for the file type.

Note: Local variables are not initialized (since they are placed on the stack). So if you have a FILEINFO structure as a local variable, the value of its Flags parameter is undefined, possibly having FILEINFO_INFOVALID or FILEINFO_FORMATVALID set. That is why it is important to initialize FILEINFO.Flags before passing the address of the FILEINFO structure to the function.


Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.


This function is used internally by L_BrowseDir to create/load the thumbnails for each file that is enumerated. You can use this function to manually create the thumbnail for a specified image file.

Since the function allocates storage to hold the image, it is up to you to free this storage by calling L_FreeBitmap.

The default thumbnail options are:

pThumbOptions->nWidth = 80; 
pThumbOptions->nHeight = 80; 
pThumbOptions->nBits = 0; 
pThumbOptions->uCRFlags = 0; 
pThumbOptions->bMaintainAspect = TRUE; 
pThumbOptions->bForceSize = FALSE; 
pThumbOptions->crBackColor = RGB(0,0,0); 
pThumbOptions->bLoadStamp = TRUE; 
pThumbOptions->bResample = FALSE; 


Required DLLs and Libraries


Win32, x64, Linux.

See Also




L_INT CreateThumbnailFromFileExample(L_VOID) 
   BITMAPHANDLE LeadBitmap; 
   L_INT nRet; 
   //Create a thumbnail with default options, and no callback 
   nRet = L_CreateThumbnailFromFile(szFilename, &LeadBitmap, sizeof(BITMAPHANDLE), NULL, NULL, NULL, NULL, NULL); 
   if(nRet == SUCCESS) 
   //Create a thumbnail with some options, and no callback 
   memset(&opt, 0, sizeof(THUMBOPTIONS)); 
   opt.uStructSize = sizeof(THUMBOPTIONS); 
   opt.bLoadStamp = FALSE; 
   opt.nHeight = 40; 
   opt.nWidth = 80; 
   opt.bForceSize = TRUE; 
   opt.bMaintainAspect = TRUE; 
   opt.crBackColor = RGB(255,0,0); 
   nRet = L_CreateThumbnailFromFile(szFilename, &LeadBitmap, sizeof(BITMAPHANDLE), &opt, NULL, NULL, NULL, NULL); 
   if(nRet == SUCCESS) 
   return SUCCESS; 
Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help