Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_BrowseDir

Show in webframe

#include "l_bitmap.h"

L_LTTMB_API L_INT L_BrowseDir( pszPath, pszFilter, pThumbOptions, bStopOnError, bIncludeSubDirs, bExpandMultipage, lSizeDisk, lSizeMem, pfnBrowseDirCB, pUserData)

L_TCHAR *pszPath;

/* directory to browse */ 

L_TCHAR *pszFilter;

/* file filter, ex *.jpg */ 

pTHUMBOPTIONS pThumbOptions;

/* pointer to a thumbnail options structure */

L_BOOL bStopOnError;

/* stop on error flag */ 

L_BOOL bIncludeSubDirs;

/* True/False to recurse sub directories */ 

L_BOOL bExpandMultipage;

/* True/False to expand multi-page files */ 

L_SSIZE_T lSizeDisk;

/* maximum size of file to load */ 

L_SSIZE_T lSizeMem;

/* maximum size of image to load */ 

BROWSEDIRCALLBACK pfnBrowseDirCB;

/* required callback function */ 

L_VOID* pUserData;

/* pointer to more parameters for the callback */ 

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

Parameter

Description

pszPath

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

pszFilter

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

pThumbOptions

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

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.

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.

bExpandMultipage

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

 

Value

Meaning

 

TRUE

Expand multi-page files, loading each page from a multi-page file.

 

FALSE

Do not expand multi-page files.

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.

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.

pfnBrowseDirCB

Callback function required for handling each of the generated thumbnails. You must specify a callback in order to process the thumbnails.The callback function must adhere to the function prototype described in BROWSEDIRCALLBACK Function.

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.

Returns

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 nThumbHeight or nThumbWidth, the image will not be resized. The whole image will be returned in the BROWSEDIRCALLBACK function.

If -1 is specified for either the nThumbHeight or nThumbWidth, the image will not be loaded at all. The BROWSEDIRCALLBACK function will be called for each file, but will only receive file information, not a valid image.

Required DLLs and Libraries

LTIMG
LTFIL
LTTMB

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:

L_CreateThumbnailFromFile,

L_LoadBitmap, L_ReadFileStamp,

 

L_SetLoadResolution,

 

L_SetPCDResolution, L_SetWMFResolution,

 

BROWSEDIRCALLBACK
For Vector files: L_2DGetViewMode L_2DSetViewMode,, L_2DGetViewPort, L_2DSetViewPort

Topics:

Thumbnail Browser

Example

This example will browse a folder and generate thumbnails for all supported images that are found.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


L_INT EXT_CALLBACK BrowseDirCallback(pBITMAPHANDLE pBitmap, 
                        L_TCHAR* pszFilename, 
                        pFILEINFO pFileInfo, 
                        L_INT nStatusCode, 
                        L_INT nPercent, 
                        L_VOID* pUserData)
{
   L_TCHAR buf[200];
   UNREFERENCED_PARAMETER(pUserData);
   UNREFERENCED_PARAMETER(nPercent);
   UNREFERENCED_PARAMETER(pFileInfo);
   UNREFERENCED_PARAMETER(pBitmap);

   if(nStatusCode == SUCCESS)/* successful thumbnail generation */
   {
      /* Do something with the thumbnail, i.e. insert into ImageList Control */
      /* ... */
   }
   else if(nStatusCode == BROWSE_LOADING)/* in the process of loading an image */
      return SUCCESS;
   else if(nStatusCode == BROWSE_SKIPPED)/* skipped a large file */
   {
      /* report error to user */
      wsprintf(buf, TEXT("Skipped File: %s !"), pszFilename);
      MessageBox(NULL, buf, TEXT("Skipped"), MB_OK);
   }
   else/* error during thumbnail generation */
   {
      /* report error to user */
      wsprintf(buf, TEXT("Error: %d - Generating Thumbnail!\n%s\nPress OK to Continue!"), nStatusCode, pszFilename);
      if(MessageBox(NULL, buf, TEXT("Error"), MB_OKCANCEL|MB_ICONERROR) == IDCANCEL)
         return(ERROR_USER_ABORT);
   }
   return SUCCESS;
}

 L_INT BrowseDirExample(L_VOID)
{
   L_INT nRet;
   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  */
   nRet = L_BrowseDir( MAKE_IMAGE_PATH(L_TEXT("")),
                       TEXT("*.jpg"),
                       &Opt,
                       FALSE, /* don't stop on error                      */
                       FALSE, /* do not recurse subdirectories            */
                       FALSE, /* do not expand multi-page files            */
                       0,     /* no limit on file size                    */
                       4000*1024,/* set limit on image size to 4MB        */
                       BrowseDirCallback,/* callback  */
                       NULL );/* no user data                             */
   return nRet;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.