OVERLAYCALLBACK

#include "l_bitmap.h"

L_INT pEXT_CALLBACK YourFunction(pOverlayCallbackData, pUserData)

pFILEOVERLAYCALLBACKDATA pOverlayCallbackData;

pointer to a structure

L_VOID* pUserData;

pointer to additional parameters

Gets the overlay bitmap and other information from the user when loading a file containing an overlay.

Parameter

Description

pOverlayCallbackData

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

pUserData

A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of the calling function.).

Returns

SUCCESS

The function was successful.

< SUCCESS

An error occurred. 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 L_SetOverlayCallback.

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.

See Also

Functions:

L_SetOverlayCallback, L_LoadBitmap, L_GetOverlayCallback

Topics:

Raster Image Functions: Loading Files

Example

For a short example, refer to L_StartCompressBuffer. For complete sample code, refer to the COMPCB example.

L_INT EXT_CALLBACK MyOverlayCallback(pFILEOVERLAYCALLBACKDATA pOverlayCallbackData, L_VOID* pUserData) 
{ 
   UNREFERENCED_PARAMETER(pUserData); 
   L_TCHAR szBuffer[800]; 
   L_TCHAR szOverlayFileName[_MAX_PATH]; 
   FILEINFO FileInfo; 
   L_INT nRet; 
 
   ZeroMemory(&FileInfo, sizeof(FILEINFO)); 
   FileInfo.uStructSize = sizeof(FILEINFO); 
 
   // 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, MAKE_IMAGE_PATH(TEXT("Temp\\overlay_%d.tmp")), pOverlayCallbackData->nPageNumber); 
 
   if(pOverlayCallbackData->bInfo) 
   { 
      // info, we only need to fill in the nInfoXXX members of the structure 
      ZeroMemory(&FileInfo, sizeof(FILEINFO)); 
      FileInfo.uStructSize = sizeof(FILEINFO); 
      nRet = L_FileInfo(szOverlayFileName, &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 = L_LoadBitmap( 
         szOverlayFileName, 
         pOverlayCallbackData->pLoadBitmap, 
         sizeof(BITMAPHANDLE), 
         0, 
         ORDER_BGRORGRAY, 
         NULL, 
         NULL); 
   } 
 
   return nRet; 
} 
L_INT OverlayCallbackExample() 
{ 
   L_TCHAR* pszPtokaFileName = MAKE_IMAGE_PATH(TEXT("SUPPLEMENT_ON_CHECK.tmp")); 
   L_TCHAR* pszTiffFileName = MAKE_IMAGE_PATH(TEXT("test.tif")); 
   L_INT nRet; 
   OVERLAYCALLBACK pfnOldCallback; 
   L_VOID* pOldUserData; 
   L_UINT uOldFlags; 
   BITMAPHANDLE Bitmap; 
 
   ZeroMemory(&Bitmap, sizeof(BITMAPHANDLE)); 
   Bitmap.uStructSize = sizeof(BITMAPHANDLE); 
   nRet = SUCCESS; 
 
   // set the overlay callback 
 
   // first, save the old overlay callback 
   nRet = L_GetOverlayCallback(&pfnOldCallback, &pOldUserData, &uOldFlags); 
   if(nRet == SUCCESS) 
   { 
      // set the new one 
      nRet = L_SetOverlayCallback(MyOverlayCallback, NULL, OVERLAY_CALLLOAD); 
      if(nRet == SUCCESS) 
      { 
 
         // load the PTOKA file from memory 
         nRet = L_LoadBitmap(pszPtokaFileName, &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, NULL, NULL); 
 
         // stop the overlay by resetting the old callback. 
         nRet = L_SetOverlayCallback(pfnOldCallback, pOldUserData, uOldFlags); 
      } 
   } 
 
   // save the bitmap as TIFF 
   nRet = L_SaveBitmap(pszTiffFileName, &Bitmap, FILE_TIF, 1, 0, NULL); 
 
   // free the bitmap 
   if(Bitmap.Flags.Allocated) 
      L_FreeBitmap(&Bitmap); 
 
   return nRet; 
} 

Help Version 20.0.2018.7.30
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help