LBitmapWindow::Load

#include "ltwrappr.h"

virtual L_INT LBitmapWindow::Load(nBitsPerPixel=0, nOrder=ORDER_BGRORGRAY, pLoadFileOption=NULL, pFileInfo=NULL)

virtual L_INT LBitmapWindow::Load(nBitsPerPixel, nOrder, nPage, pFileInfo=NULL)

virtual L_INT LBitmapWindow::Load(pszFileName, nBitsPerPixel=0, nOrder=ORDER_BGRORGRAY, pLoadFileOption=NULL, pFileInfo=NULL)

virtual L_INT LBitmapWindow::Load(pszFileName, nBitsPerPixel, nOrder, nPage, pFileInfo=NULL)

L_TCHAR * pszFileName;

/* name of the file to load */

L_INT nBitsPerPixel;

/* resulting bitmaps pixel depth */

L_INT nOrder;

/* color order for 16-, 24-, 32-, 48, and 64-bit bitmaps */

L_INT nPage;

/* the page number of the first image to be loaded */

LOADFILEOPTION pLoadFileOption;

/* pointer to optional extended load options */

pFILEINFO pFileInfo;

/* pointer to a structure */

Loads a bitmap image from disk into the class object. The image file can be in any supported image file format and bits per pixel, whether compressed or uncompressed.

Parameter

Description

pszFileName

Character string containing the name of the file to load.

nBitsPerPixel

Resulting bitmap pixel depth. The following are valid values:

 

Value

Meaning

 

0

Keep the original file's pixel depth (Do not convert).

 

1 to 8

The specified bits per pixel in the resultant bitmap

 

12

12 bits per pixel in the resultant bitmap.

 

16

16 bits per pixel in the resultant bitmap

 

24

24 bits per pixel in the resultant bitmap

 

32

32 bits per pixel in the resultant bitmap

 

48

48 bits per pixel in the resultant bitmap

 

64

64 bits per pixel in the resultant bitmap

nOrder

Color order for 16-, 24-, 32-, 48, and 64-bit bitmaps. If the resultant bitmap is less than 16 bits per pixel, this will have no effect since palletized images have no order. The following are valid values:

 

Value

Meaning

 

ORDER_RGB

[0] Red, green, and blue color order in memory

 

ORDER_BGR

[1] Blue, green, and red color order in memory

 

ORDER_GRAY

[2] 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in the Document/Medical toolkits.

 

ORDER_RGBORGRAY

[3] Load the image as red, green, blue OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical toolkits only.

 

ORDER_BGRORGRAY

[4] Load the image as blue, green, red OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical toolkits only.

nPage

The page number (for multipage files) that contains the first image to be loaded. If the file is not a multipage file, pass 0.

pLoadOptions

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

pFileInfo

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 LFile::GetInfo.

 

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 LFile::GetInfo has been called previously, but values that affect the size of the image loaded have been changed (for example, by calling LFileSettings::SetPCDResolution or LFileSettings::SetWMFResolution). In this case the FILEINFO structure pointed to by pFileInfo will be updated with the results of LFile::GetInfo.

 

If LFile::GetInfo has been called prior to calling this function, and no changes have been made to the contents of the structure filled by LFile::GetInfo, 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 LFile::GetInfo 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.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Call this function to load a bitmap image from disk into the class object.

If PaintWhileLoad is enabled for the bitmap window the loaded image will be painted as it is loaded. In this case, the mapped file object will not be used for the load operation. If PaintWhileLoad is disabled the mapped file object will be used for the load operation.

Support for 12 and 16-bit grayscale images is only available in the Document/Medical toolkits.

For supported formats, refer to Files To Be Included With Your Application.

Before calling this function, you may need to get or set file information, such as the page number of a multipage file or the resolution of a PCD file. Refer to Getting and Setting File Information.

The function will initialize the bitmap handle and allocate the storage necessary to hold the image. If the bits per pixel of the file is larger than 8 bits, the image data will be loaded in the same color order as the one passed to the function in nOrder.

The class object will free the bitmap when it is destroyed. If you wish to free the bitmap, use LBitmapBase::Free.

If the paint while load is enabled for the bitmap window, then the loaded image will be painted as it is loaded.

Warning: The function will return ERROR_INV_PARAMETER if nOrder was set to ORDER_GRAY and the image file was not 12 or 16 bits per pixel.

Note: If Document/Medical support is unlocked, and the format being loaded is FILE_LEAD1BIT, FILE_CCITT_GROUP3_1DIM, FILE_CCITT_GROUP3_2DIM, FILE_CCITT_GROUP4, FILE_ICA_G3_1D, FILE_ICA_G3_2D, FILE_ICA_G4, FILE_RAWICA_G3_1D, FILE_RAWICA_G3_2D, FILE_RAWICA_G4, FILE_FAX_G3_1D, FILE_FAX_G3_2D, FILE_FAX_G4, FILE_WFX_G3_1D, or FILE_WFX_G4, the image data will be loaded compressed. For more information, refer to Speeding Up 1-Bit Documents.

Note: For information on loading and saving large TIFF files faster, refer to Loading and Saving Large TIFF Files.

Required DLLs and Libraries

LTDIS
LTDLG
LTEFX
LTFIL
LTIMG
LTSCR
LTTWN

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

Win32, x64.

See Also

Functions:

Class Members, LBitmapBase::GetLoadStatus, LFileSettings::GetLoadResolution, LFileSettings::GetPCDResolution, LFileSettings::GetWMFResolution, LFileSettings::SetLoadResolution, LFileSettings::SetPCDResolution, LFileSettings::SetWMFResolution, LFileSettings::GetViewMode2D, LFileSettings::GetViewPort2D, LFileSettings::SetViewMode2D, LFileSettings::SetViewPort2D, LFileSettings::GetWMFResolution, LFileSettings::SetWMFResolution

Topics:

Raster Image Functions: Loading Files

 

Raster Image Functions: Redirecting Input and Output

 

Raster Image Functions: Input and Output

 

Loading and Saving Images

 

Using a PanWindow

 

Files and File Formats

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
/*This is an example for LAnimationWindow::Load(nBitsPerPixel, nColorOrder, nPage, pFileInfo=NULL):*/
L_INT LBitmapWindow__LoadFirstExample(HWND hWnd) 
{
   L_INT nRet;
   LAnimationWindow AnimationWindow; 
   AnimationWindow.SetFileName(MAKE_IMAGE_PATH(TEXT("eye.gif")));
   nRet = AnimationWindow.Load(8, ORDER_BGR, 1);
   if (nRet ==SUCCESS)
   {
      AnimationWindow.CreateWnd(hWnd,0, WS_VISIBLE|WS_CHILD|WS_BORDER,0,0,300,300);
      nRet =AnimationWindow.PlayAnimation();
      if(nRet !=SUCCESS)
         return nRet;
      while (AnimationWindow.IsPlaying())
      {
         if (AnimationWindow.DoEvents())
            break; 
      }
   }
   else
      return nRet;
   return SUCCESS;
} 
/*This is an example for LAnimationWindow::Load(nBitsPerPixel=0, nColorOrder=ORDER_BGR, pLoadFileOption=NULL, pFileInfo=NULL):*/
L_INT LBitmapWindow__LoadSecondExample(HWND hWnd) 
{
   L_INT nRet;
   LAnimationWindow AnimationWindow;
   AnimationWindow.SetFileName(MAKE_IMAGE_PATH(TEXT("eye.gif")));
   
   nRet = AnimationWindow.Load(8, ORDER_BGR, NULL); 
   if (nRet==SUCCESS)
   {
      AnimationWindow.CreateWnd(hWnd,0, WS_VISIBLE|WS_CHILD|WS_BORDER,0,0,300,300);
      nRet =AnimationWindow.PlayAnimation();
      if(nRet !=SUCCESS)
         return nRet;
      while (AnimationWindow.IsPlaying())
      {
         if (AnimationWindow.DoEvents())
            break; 
      }
   }
   else
      return nRet;
   return SUCCESS;
} 
/*This is an example for LAnimationWindow::Load(pszFileName, nBitsPerPixel, nColorOrder, nPage, pFileInfo=NULL):*/
L_INT LBitmapWindow__LoadThirdExample(HWND hWnd) 
{
   L_INT nRet;
   LAnimationWindow AnimationWindow;
   
   nRet = AnimationWindow.Load(MAKE_IMAGE_PATH(TEXT("eye.gif")), 8, ORDER_BGR, 5);
   if (nRet ==SUCCESS)
   {
      AnimationWindow.CreateWnd(hWnd,0, WS_VISIBLE|WS_CHILD|WS_BORDER,0,0,300,300);
      nRet =AnimationWindow.PlayAnimation();
      if(nRet !=SUCCESS)
         return nRet;
      while (AnimationWindow.IsPlaying())
      {
         if (AnimationWindow.DoEvents())
            break; 
      }
   }
   else 
      return nRet;
   return SUCCESS;
} 
/*This is an example for LAnimationWindow::Load(pszFileName, nBitsPerPixel=0, nColorOrder=ORDER_BGR, pLoadFileOption=NULL, pFileInfo=NULL):*/
L_INT LBitmapWindow__LoadForthExample(HWND hWnd) 
{
   L_INT nRet;  
   LAnimationWindow AnimationWindow;
   nRet = AnimationWindow.Load(MAKE_IMAGE_PATH(TEXT("eye.gif")), 8, ORDER_BGR, NULL); 
   if (nRet ==SUCCESS)
   {
      AnimationWindow.CreateWnd(hWnd,0, WS_VISIBLE|WS_CHILD|WS_BORDER,0,0,300,300);
      nRet =AnimationWindow.PlayAnimation();
      if(nRet !=SUCCESS)
         return nRet;
      while (AnimationWindow.IsPlaying())
      {
         if (AnimationWindow.DoEvents())
            break; 
      }
   }
   else
      return nRet;
   return SUCCESS;
}