Speeding Up 1-Bit Documents

With a LEADTOOLS Document or Medical toolkit, you can improve the load and display performance of 1-bit images that are commonly used for document storage and FAX transmission.

LEADTOOLS achieves this speed improvement by letting you load an image in its RLE-compressed format, where you can work with it as if it were a fully-expanded bitmap. This not only speeds the throughput and storage, but also speeds up the display of large images that are scaled to fit a window. The display improvement is achieved because, internally, it is no longer necessary to decompress all lines of data to display the scaled-down image.

You can take advantage this feature when loading files that are stored in the LEAD 1-Bit, TIFF Group 3 or Group 4, IOCA, WinFax, or raw FAX formats. To see whether a file can be loaded this way, you can call the LFile::GetInfo function, then check the Flags field in the FILEINFO structure to see if it has a value of FILEINFO_COMPRESSED.

To load a 1-bit image in its compressed format, you can specify a LOADFILE_COMPRESSED flag when calling any of the following functions:

LFile::LoadFile

LFile::LoadFile

LFile::LoadOffset

LFile::StartFeedLoad

LMemoryFile::LoadMemory

After an image is loaded, you can check the Flags.Compressed field of its BITMAPHANDLE structure to see if the bitmap is compressed. (LEADTOOLS functions maintain this flag, and you should not set it yourself.)

Once a compressed bitmap is loaded, you can use LEADTOOLS functions to access it just as you would any other 1-bit bitmap.

The LBitmapBase::ChangeCompression function can be used to uncompress bitmaps, compress 1-bit bitmaps using RLE compression, or super compress 1-bit or 24-bit bitmaps.

However, if you create a bitmap yourself using LBitmapBase::Create or LBitmapBase::Allocate, you must specify the storage type as TYPE_COMPRESSED. Also, if necessary, you can use the following low-level functions to access and manipulate the compressed bitmap data:

LBitmapBase::GetRowColCompressed

LBitmapBase::PutRowColCompressed

LBitmapBase::GetRowCompressed

LBitmapBase::PutRowCompressed

LBuffer::ExpandRow

LBuffer::CompressRow

If you use the LFile::LoadFileCallBack function when loading a file, the FILEREAD_COMPRESSED flag will be set in the function's uFlags parameter to indicate that the image data is compressed. In that case, if necessary, you can use the LBuffer::ExpandRow function to decompress data in the callback function. To implement the paint-while-load feature, you do not have to expand the data. Instead you can pass the number of lines as a negative value (-nLines) in the LPaint::PaintDCBuffer function's nCount parameter.