Specifies a callback function for handling input data that is in an undetermined format. This function can be used for loading raw FAX data (CCITT Group 3 or Group 4), raw run-length-encoded data (4-bit or 8-bit), raw Bitfield compressed data, raw PackBits compressed data or raw uncompressed data.
#include "l_bitmap.h"
L_LTFIL_API LOADINFOCALLBACK L_SetLoadInfoCallback(pfnCallback, pUserData)
Your callback function that supplies the information that LEADTOOLS needs when loading an image from a file. The callback function must adhere to the syntax specified in LOADINFOCALLBACK Function.
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.
Pointer to the previous function used to supply information about the file. You can assign this return value to a variable, then use the variable to restore the normal behavior.
To load a raw fax file, you must provide a LOADINFOCALLBACK by calling L_SetLoadInfoCallback. If you recognize the file and you know the height and width of the file, set LOADINFO.Width and LOADINFO.Height to a positive value. To automatically detect the width and height of the fax file, set LOADINFO.Width and LOADINFO.Height to -1.
To load raw uncompressed data, you must provide a LOADINFOCALLBACK by calling L_SetLoadInfoCallback. Set the LOADINFO.Format field to FILE_RAW. Valid values must also be set for the following LOADINFO fields: Width, Height, BitsPerPixel, Offset (byte location in file where raw data begins). If each line of RAW data is padded so that the number of bytes is a multiple of 4 (as is the case with raw Windows BMP data), include LOADINFO_PAD4 in the LOADINFO.Flags field. Include an orientation flag in the LOADINFO.Flags field to load with the proper orientation. For example, raw Windows BMP data is stored with a BOTTOM_LEFT orientation. If the orientation is unknown, include the TOP_LEFT flag. If the raw data is 8 bits per pixel or less, then the image is palettized and a palette must be generated. If this is the case, include the LOADINFO_PALETTE flag, and fill in the first (2BitsPerPixel) entries of the rgbQuad field.
If the color order is ORDER_RGB then include this flag. If the ORDER_RGB flag is not included, the data will be loaded as ORDER_BGR.
To supply the needed information, refer to the LOADINFO structure description.
Note: More options are available in the LOADFILEOPTION structure.
Win32, x64, Linux.
For complete sample code, refer to the UTIL.C module of the DEMO example.
typedef struct _MYDATA
{
L_INT nWidth;
L_INT nHeight;
} MYDATA;
L_INT EXT_CALLBACK LoadInfoCallBack(L_HFILE fd,
pLOADINFO pInfo,
L_VOID * pUserData );
L_INT SetLoadInfoCallbackExample(HWND hWnd,pBITMAPHANDLE LEADBitmap)
{
L_INT nRet;
LOADINFOCALLBACK pfnSavedCallback; /* Temporary copy of the current callback */
L_VOID * pSavedUserData; /* Temporary copy of the current user data */
MYDATA MyData;
MyData.nWidth = LEADBitmap->Width;
MyData.nHeight = LEADBitmap->Height;
/* Set the callback function for loading unknown files.*/
pSavedUserData = L_GetLoadInfoCallbackData(); /* get the current user data */
pfnSavedCallback = L_SetLoadInfoCallback(LoadInfoCallBack, (L_VOID *)&MyData);
/* Make the current image look OK as a 1-bit image */
nRet = L_HalfToneBitmap(LEADBitmap, HT_VIEW, 45, 0, NULL, 0);
if(nRet != SUCCESS)
return nRet;
/* Save the image as raw FAX. */
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("TMP.TIF")), LEADBitmap, FILE_FAX_G3_2D, 1, 0, NULL);
if(nRet != SUCCESS)
return nRet;
/* Free the bitmap */
if(LEADBitmap->Flags.Allocated)
L_FreeBitmap(LEADBitmap);
/* Load the bitmap that we just saved.
Format information will be supplied by the LOADINFOCALLBACK function. */
nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("TMP.TIF")), LEADBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet != SUCCESS)
return nRet;
/* Return the LOADINFOCALLBACK function to its saved value */
L_SetLoadInfoCallback(pfnSavedCallback, pSavedUserData);
/* Get a new palette as the paint palette because we are now using 1-bit */
SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);
return SUCCESS;
}
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