LBase::OverlayCallBack

#include "ltwrappr.h"

virtual L_INT LBase::OverlayCallBack(pOverlayCallbackData)

pFILEOVERLAYCALLBACKDATA pOverlayCallbackData;

/* pointer to a structure */

Override this function to get the overlay bitmap and other information from the user when loading a file containing an overlay.

Parameter

Description

pOverlayCallbackData

Pointer to a FILEOVERLAYCALLBACKDATA structure that contains information for the callback. Some members of this structure are for input, some are for output. For more information, refer to FILEOVERLAYCALLBACKDATA.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

When loading a file containing an overlay, typically PTOCA files, LEADTOOLS will call this function to let the user provide the overlay bitmap. Typically, the overlay bitmap is in a different file on the disk. The callback can be called before or after LEADTOOLS tries to load the overlay bitmap. For more information, refer to LBase::EnableOverlayCallBack.

When this function is called, you should fill the appropriate fields in the FILEOVERLAYCALLBACKDATA structure to set up the overlay bitmap and its information. For more information, refer to the FILEOVERLAYCALLBACKDATA structure

Required DLLs and Libraries

LTKRN

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

See Also

Elements:

LBase::IsOverlayCallBackEnabled, LBase::EnableOverlayCallBack, LFile::LoadBitmap, Class Members

Example

class LUserBitmap : public LBitmap  
{
   public: 
      LUserBitmap();
      virtual L_INT  OverlayCallBack(pFILEOVERLAYCALLBACKDATA pOverlayCallbackData); 
      virtual ~LUserBitmap();
      LMemoryFile MyBitmap; 
};

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LUserBitmap::LUserBitmap()
{
}

LUserBitmap::~LUserBitmap()
{

}

L_INT LUserBitmap::OverlayCallBack(pFILEOVERLAYCALLBACKDATA pOverlayCallbackData) 
{
   L_TCHAR szBuffer[800]; 
   L_TCHAR szOverlayFileName[_MAX_PATH]; 
   FILEINFO FileInfo; 
   L_INT nRet; 
   LBitmap MyBitmap; 
   // show overlay information
   wsprintf(szBuffer, TEXT("File: %s\nPageNumber: %d\nInfo: %d"),
      pOverlayCallbackData->pszFilename, 
      pOverlayCallbackData->nPageNumber, 
      pOverlayCallbackData->bInfo); 
   MessageBox(NULL, szBuffer, TEXT("Overlay Callback"), 0); 

   // construct the overlay file name (assume its c:\temp\overlay_#.tmp where # is the page number) 
   wsprintf(szOverlayFileName, TEXT("c:\\temp\\overlay_%d.tmp"), pOverlayCallbackData->nPageNumber); 
   MyBitmap.SetFileName(szOverlayFileName); 
   if(pOverlayCallbackData->bInfo) 
   {
      // info, we only need to fill in the nInfoXXX members of the structure
      ZeroMemory(&FileInfo, sizeof(FILEINFO)); 
      nRet = MyBitmap.File()->GetInfo(&FileInfo, sizeof(FILEINFO) ,0, NULL); 

      if(nRet == SUCCESS) 
      {
         pOverlayCallbackData->nInfoWidth = FileInfo.Width; 
         pOverlayCallbackData->nInfoHeight = FileInfo.Height; 
         pOverlayCallbackData->nInfoXResolution = FileInfo.XResolution; 
         pOverlayCallbackData->nInfoYResolution = FileInfo.YResolution; 
      }
   }
   else
   {
      // we need to load the overlay bitmap into the pLoadBitmap member
      nRet = MyBitmap.File()->LoadBitmap(0, 
         ORDER_BGRORGRAY, 
         NULL, 
         NULL); 
      *pOverlayCallbackData->pLoadBitmap = *MyBitmap.GetHandle();
   }

   return nRet; 

}
L_INT OverlayTest(L_VOID) 
{
   L_TCHAR* pszPtokaFileName = TEXT("c:\\temp\\SUPPLEMENT ON CHECK.tmp");
   L_TCHAR* pszTiffFileName = TEXT("c:\\temp\\test.tif");

   L_INT nRet; 
   LUserBitmap Bitmap; 

   nRet = SUCCESS; 

   // load the PTOCA file from memory
   Bitmap.EnableOverlayCallBack(TRUE); 
   nRet = Bitmap.Load(pszPtokaFileName, 0, ORDER_BGRORGRAY, NULL, NULL); 
   Bitmap.EnableOverlayCallBack (FALSE); 
   
   // save the bitmap as TIFF
   nRet = Bitmap.Save(pszTiffFileName, FILE_TIF, 1, 0, NULL); 

   // free the bitmap
   if(Bitmap.IsAllocated())
      Bitmap.Free();

   return nRet; 
}