OVERLAYCALLBACK Function
#include "l_bitmap.h"
L_INT pEXT_CALLBACK YourFunction(pOverlayCallbackData, pUserData)
pFILEOVERLAYCALLBACKDATA pOverlayCallbackData; |
/* pointer to a structure */ |
/* 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: |
|
Topics: |
Example
L_INT EXT_FUNCTION MyOverlayCallback(pFILEOVERLAYCALLBACKDATA pOverlayCallbackData, L_VOID* pUserData)
{
L_TCHAR szBuffer[800];
L_TCHAR szOverlayFileName[_MAX_PATH];
FILEINFO FileInfo;
L_INT nRet;
// 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);
if(pOverlayCallbackData->bInfo)
{
// info, we only need to fill in the nInfoXXX members of the structure
ZeroMemory(&FileInfo, sizeof(FILEINFO));
nRet = L_FileInfo(szOverlayFileName, &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,
0,
ORDER_BGRORGRAY,
NULL,
NULL);
}
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;
OVERLAYCALLBACK pfnOldCallback;
L_VOID* pOldUserData;
L_UINT uOldFlags;
BITMAPHANDLE Bitmap;
ZeroMemory(&Bitmap, 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, 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;
}