L_ReadLoadResolutions

#include "l_bitmap.h"

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

L_TCHAR* pszFile;

/* character string for the file name */

pDIMENSION pDimensions;

/* pointer to the array to be updated */

L_INT* pDimensionCount;

/* address of the count variable to be updated */

pLOADFILEOPTION pLoadOptions

/* pointer to optional extended load options */

Examines a FlashPix, PhotoCD, or JBIG file to determine which resolutions it contains.

Parameter

Description

pszFile

Character string containing the name of the file to examine.

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.

pDimensionCount

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

pLoadOptions

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

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

A FlashPix, PhotoCD, ECW, or JBIG file 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.

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

LTFIL

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 2000 / XP/Vista, Windows CE.

See Also

Functions:

L_GetLoadResolution, L_SetLoadResolution, L_GetPCDResolution, L_GetSaveResolution, L_SetSaveResolution
For Vector files: L_2DGetViewMode, L_2DSetViewMode, L_2DGetViewport, L_2DSetViewPort

Topics:

Raster Image Functions: Loading Files

 

Raster Image Functions: Getting and Setting File Information

 

Implementing PhotoCD and FlashPix Features

 

Implementing JBIG Features

Example

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 */
   if(pBitmap->Flags.Allocated)
      L_FreeBitmap(pBitmap);
   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;
}