Using Callback Functions

A callback function is a function that you write and that LEADTOOLS calls. With a callback function you can add processing, and in some cases, you can direct the input or output of a LEADTOOLS engine such as the decompression engine. Generally, the engine is in a loop. In cases where you can direct the output, with each time through the loop, it fills a buffer with data and calls your function to process the data.

Callback functions are also commonly used to update status bars or to see if the user wants to interrupt the process. The L_SetStatusCallBack function enables you to do that with many functions that do not declare a callback in the parameter list.

To retrieve the current status callback function, and any associated user-defined data, call L_GetStatusCallBack.

In addition, many of the LEADTOOLS functions let you pass a parameter that specifies a callback function. These callback functions are more flexible than the one specified with L_SetStatusCallBack. There are some variations in how the idea is implemented, and you must refer to the individual function descriptions to see how they are used.

LEADTOOLS API callback functions let you perform the following:

image\sqrblit.gif File-to-buffer compression and decompression

image\sqrblit.gif File-to-buffer image loading

image\sqrblit.gif Redirected I/O functions for memory-to-memory compression and decompression

image\sqrblit.gif On-the-fly resizing

image\sqrblit.gif Painting while loading

image\sqrblit.gif Seeing if the user wants to interrupt the process

image\sqrblit.gif Updating a status bar

image\sqrblit.gif Providing help for dialogs

For a list of the possible callback functions, refer to Callbacks.