LFile::BrowseDir

#include "ltwrappr.h"

virtual L_INT LFile::BrowseDir(pszPath, pszFilter, pThumbOptions, bStopOnError=FALSE, bIncludeSubDirs=FALSE, bExpandMultipage=FALSE, lSizeDisk=0, lSizeMem=0)

Browses the specified directory for supported images, and generates thumbnails for each image file that is found.

Parameters

L_TCHAR * pszPath

Character string containing the name of the directory to browse for images

L_TCHAR * pszFilter

Character string containing the file filter to use for browsing. Ex. *.jpg

pTHUMBOPTIONS pThumbOptions

Pointer to a structure containing the thumbnail creation options for the browser.

L_BOOL bStopOnError

Flag that indicates whether or not to stop generating thumbnails when an error occurs. Possible values are:

Value Meaning
TRUE Stop generating thumbnails if an error occurs.
FALSE Do not stop generating thumbnails if an error occurs.

L_BOOL bIncludeSubDirs

Flag that indicates whether or not to recurse subdirectories when looking for files. Possible values are:

Value Meaning
TRUE Recurse subdirectories.
FALSE Do not recurse subdirectories.

L_BOOL bExpandMultipage

Flag that indicates whether or not to expand multipage files. If True, each page from a multipage file will be loaded. Possible values are:

Value Meaning
TRUE Expand multipage files, loading each page from a multipage file.
FALSE Do not expand multipage files.

L_INT32 lSizeDisk

Maximum size of file to load. Use this to limit the size of images that the browse will attempt to load. Pass 0 for no limit.

L_INT32 lSizeMem

Maximum size of image in memory to load. Use this to limit the size of images that the browse will attempt to load. Pass 0 for no limit.

Returns

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

Comments

Use this function to browse a directory for image files that LEADTOOLS supports. Each supported file that is found will be loaded, and a thumbnail will be generated for the image. In the callback function, you can process the thumbnail in any manner your application requires. For example, you can add the thumbnails to the LEADTOOLS ImageList Control.

If 0 is specified for either pThumbOptions->nHeight or pThumbOptions->nWidth, the image will not be resized. The whole image will be returned in the LFile::BrowseDirCallBack function.

If -1 is specified for either the pThumbOptions->nHeight or pThumbOptions->nWidth, the image will not be loaded at all. The LFile::BrowseDirCallBack function will be called for each file, but will only receive file information, not a valid image.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

// define user LFile class to override CallBack 
class LMyBrowse : public LFile 
{ 
public: 
   HDC m_hDC; 
 
public: 
   LMyBrowse(); 
   virtual ~LMyBrowse(); 
   virtual L_INT BrowseDirCallBack( LBitmapBase * pLBitmap, 
                                    L_TCHAR * pszFilename, 
                                    pFILEINFO pFileInfo, 
                                    L_INT nStatus, 
                                    L_INT nPercent 
                                  ); 
}; 
 
LMyBrowse::LMyBrowse() 
{ 
   m_hDC = NULL; 
} 
 
LMyBrowse::~LMyBrowse() 
{ 
} 
 
L_INT LMyBrowse::BrowseDirCallBack(LBitmapBase * pLBitmap, 
                                   L_TCHAR * pszFilename, 
                                   pFILEINFO pFileInfo, 
                                   L_INT nStatus, L_INT nPercent) 
{ 
   UNREFERENCED_PARAMETER(pszFilename); 
   UNREFERENCED_PARAMETER(pFileInfo); 
   UNREFERENCED_PARAMETER(nPercent); 
 
   // we have a thumbnail, do something with it 
   if(nStatus == SUCCESS) 
   { 
      pLBitmap->Paint()->SetDC(m_hDC); 
      pLBitmap->Paint()->PaintDC(); 
   } 
   else if(nStatus == BROWSE_LOADING) 
   { 
      // imaging being loaded 
   } 
   return SUCCESS ; 
} 
 
// Test Function 
L_INT LFile__BrowseDirExample(HDC hDC) 
{ 
   L_INT nRet; 
   LBase::LoadLibraries(LT_ALL_LEADLIB); 
   LMyBrowse myBrowse; 
   THUMBOPTIONS Opt; 
 
   memset(&Opt, 0, sizeof(THUMBOPTIONS)); 
 
   Opt.uStructSize = sizeof(THUMBOPTIONS); 
   Opt.nWidth = 115; /* thumbnail width                          */ 
   Opt.nHeight = 115; /* thumbnail height                          */ 
   Opt.nBits = 24; /* 24-bit                                   */ 
   Opt.uCRFlags = 0; /* ignored, b/c we specified 24-bit         */ 
   Opt.bMaintainAspect = TRUE; /* maintain aspect when creating thumbnails */ 
   Opt.bForceSize = FALSE; /* don't force size                         */ 
   Opt.crBackColor = RGB(0,0,0); /* background color is ignored              */ 
   Opt.bLoadStamp = TRUE; /* try to load stamp if present in file     */ 
   Opt.bResample = TRUE; /* resample, for better quality thumbnails  */ 
 
   myBrowse.m_hDC = hDC; 
   nRet = myBrowse.BrowseDir(MAKE_IMAGE_PATH(TEXT("")), // path 
                             TEXT("*.*"),             // all files 
                             &Opt, 
                             FALSE,             // do not stop on errors 
                             FALSE,             // do not include sub-dirs 
                             FALSE,             // do not expand multipage files 
                             0,                 // no limit to file sizes 
                             4000*1024);        // limit image in memory to 4MB 
 
   if(nRet != SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.