LEADTOOLS Raster Imaging C++ Class Library Help > Getting Started > Using Callback Functions |
In the LEADTOOLS C++ Class Library, the callback functions that are available through the LEADTOOLS C DLL are implemented as overidable virtual functions in the various classes. Using the LEADTOOLS C DLL, a callback function is a function that you write and that LEADTOOLS calls. With the LEADTOOLS C++ 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 C DLL, many functions let you pass a parameter that specifies a callback function. However, in the LEADTOOLS C++ 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 C++ Class Library virtual callback functions let you perform the following:
File-to-buffer compression and decompression
File-to-buffer image loading
Redirected I/O functions for memory-to-memory compression and decompression
On-the-fly resizing
Painting while loading
Seeing if the user wants to interrupt the process
Updating a status bar
Providing help for dialogs
For a list of the possible callback functions, refer to Overridables.