Using Callback Functions

In the LEADTOOLS Class Library, the callback functions that are available through the LEADTOOLS API are implemented as overidable virtual functions in the various classes. Using the LEADTOOLS API, a callback function is a function that you write and that LEADTOOLS calls. With the LEADTOOLS Class Library, the class object has a default implementation for the callback function. You can derive your own class from one of the LEADTOOLS base classes, and override the necessary callback function(s) in order to do your own processing. When you do this, 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 LBase::StatusCallBack virtual function enables you to do that with many class functions that do not have an associated virtual function.

 

In the LEADTOOLS API, many functions let you pass a parameter that specifies a callback function. However, in the LEADTOOLS Class Library, individual classes define virtual functions that you must override in derived classes. In either case, these callback functions are more flexible than LBase::StatusCallBack. 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 Class Library virtual 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 Overridables.