#include "l_bitmap.h"
L_INT pEXT_CALLBACK YourFunction(pOverlayCallbackData, pUserData)
Gets the overlay bitmap and other information from the user when loading a file containing an overlay.
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.
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).
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< SUCCESS | An error occurred. Return Codes |
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
For an 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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document