#include "l_bitmap.h"

L_LTFIL_API L_INT L_ReadLoadResolutions(pszFile, pDimensions, pDimensionCount, pLoadOptions)

Examines a file to determine which resolutions it contains.


L_TCHAR* pszFile

Character string containing the name of the file to examine.

pDIMENSION pDimensions

Pointer to the array of DIMENSION structures to be updated with the available physical resolutions in the file. You can pass NULL if you only want to update the count variable.

L_INT* pDimensionCount

Address of the pDimensionCount variable to be updated with the number of available resolutions.


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


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


Certain file formats, for example FlashPix, PhotoCD, ECW, JPEG 2000 or JBIG / JBIG2, may can contain more than one copy of the same image, each at a different physical resolution (width and height in pixels). For PhotoCD files, the resolutions are fixed sizes, and you can also use an older function (L_GetPCDResolution) to examine them. For FlashPix and JBIG files, which can contain images of various sizes, you must use this function to examine them. For ECW files you can only resample images to dimensions smaller than the orginal values for width/height, you can use this function to get the original dimensions.

For the full list of formats that support multiple resolutions, see L_GetLoadResolution.

You must allocate the array to be updated. One way to do this is to declare an array of the maximum size (29 elements). Another way is to call this function twice the first time with NULL in the pDimensions parameter, so that you can get the number of elements and allocate storage of the appropriate size.

After you get the available resolutions, you can use the L_SetLoadResolution function to specify the one to be loaded.

Required DLLs and Libraries


Win32, x64, Linux.

See Also




This example shows how many physical resolutions are available, selects the smallest one, then loads the file.

L_INT ReadLoadResolutionsExample(L_TCHAR    * pszFilename, 
                                                 HWND         hWnd, 
                                                 pBITMAPHANDLE pBitmap) 
   L_INT nRet; 
   pDIMENSION pDimensions; /* Pointer to the array to be updated  */ 
   HGLOBAL hDimensions;    /* Handle to the buffer for the array  */ 
   L_INT DimensionCount;   /* Number of physical resolutions      */ 
   L_TCHAR szMessage[256]; /* MessageBox string                   */ 
   L_UINT32 uWidth;        /* Width variable to be updated        */ 
   L_UINT32 uHeight;       /* Height variable to be updated       */ 
   L_INT i;                /* Loop counter                        */ 
   FILEINFO FileInfo; 
   memset(&FileInfo, 0, sizeof(FILEINFO)); 
   FileInfo.uStructSize = sizeof(FILEINFO); 
   nRet = L_FileInfo(pszFilename, &FileInfo, sizeof(FILEINFO), 0, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Count the number of sizes */ 
   nRet = L_ReadLoadResolutions(pszFilename, NULL, &DimensionCount, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Allocate memory to hold the array of DIMENSION structures */ 
   hDimensions = GlobalAlloc(GMEM_MOVEABLE, sizeof(DIMENSION)* DimensionCount); 
   pDimensions = (pDIMENSION)GlobalLock( hDimensions ); 
   /* Fill the array */ 
   nRet = L_ReadLoadResolutions(pszFilename, pDimensions, &DimensionCount, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Display a message box that shows the available sizes */ 
   wsprintf (szMessage, TEXT("Available dimensions:\n")); 
   for(i = 0; i < DimensionCount; ++i) 
      wsprintf (szMessage, TEXT("%s\n%d x %d"), szMessage, pDimensions[i].nWidth, pDimensions[i].nHeight); 
   MessageBox( NULL, szMessage, TEXT("File Information"), MB_OK ); 
   /* Set the size to load, the smallest size in this case */ 
   nRet = L_SetLoadResolution(FileInfo.Format, pDimensions[0].nWidth, pDimensions[0].nHeight); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Free the memory that we allocated */ 
   GlobalUnlock (hDimensions); 
   GlobalFree (hDimensions); 
   /* Get the dimensions that we just set and display them */ 
   nRet = L_GetLoadResolution(FileInfo.Format, &uWidth, &uHeight, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   wsprintf (szMessage, TEXT("Size that will be loaded:\n\n%d x %d"), uWidth, uHeight); 
   MessageBox( NULL, szMessage, TEXT("File Information"), MB_OK ); 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap (pszFilename, pBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Update the paint palette to force a repaint */ 
   SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L); 
   return SUCCESS; 

Help Version 21.0.2021.4.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help