Loading and Saving Images
LEADTOOLS provides many options when loading and saving image files. Nevertheless, the code can be as simple as the following, which loads a LEAD compressed file and saves it as a Windows BMP file:
LBitmapBase TmpBitmap; /* LBitmapBase
object for the temporary bitmap */
/* Load a bitmap at its own bits per pixel */
TmpBitmap.Load(TEXT("v:\\images\\eagle.cmp"), 0, ORDER_BGR);
/* Save the image as a 24-bit Windows BMP file */
TmpBitmap.Save(TEXT("d:\\temp\\test.bmp"), FILE_BMP, 24, 0);
LEADTOOLS also supports super compressed images. Only 1-bit and 24-bit bitmaps can be kept super compressed in memory. For more information, refer to Super Compressed Bitmaps.
You can load an image at its own color resolution, manipulate it, and display it, regardless of current video mode. You can also convert the image to a specific color resolution (bits per pixel) as you load or save it. If you want to convert while loading or saving, refer to Conversion Considerations.
Whether an image file is on disk or in memory, you can get information about the image before loading it. You can also handle file-format-specific information, such as the page number or physical resolution. The following topics provide more information about specific file formats:
Controlling Progressive Loads and Saves
Implementing PhotoCD and FlashPix Features
Implementing FlashPix Extension
Implementing TIFF Comments and Tags
Implementing GeoKeys (GeoTIFF tags)
Working with the RAW File Filter
You can supply the input for a load operation or the output of a save operation, and you can add processing, such as a paint-while-load feature. Using Callback Functions describes these features. Callbacks lists the functions that you can supply.
You can control the execution of a load procedure as you supply transmitted image data. Refer to the LFile::StartFeedLoad, LFile::FeedLoad, and LFile::StopFeedLoad functions.
PSD file formats support layers. LEADTOOLS provides the LFile::LoadLayer function to allow the loading of an individual layer. PSD files can also be saved with layer information by calling LFile::SaveBitmapWithLayers.
When working with multipage files, you can delete individual pages within the file using LFile::DeletePage.
To load an image from a file, into a bitmap, and resize the bitmap as it loads, call LFile::LoadBitmapResize or LBitmapBase::LoadResize.
To save a bitmap to a file in a memory buffer, use LMemoryFile::SaveBitmapBuffer or LMemoryFile::SaveFileBuffer. If the buffer of the LBuffer object used by the LMemoryFile::SaveBitmapBuffer is not large enough to accommodate the file in memory, the LMemoryFile::SaveBitmapBufferCallBack function is called, giving the user the opportunity to reallocate the buffer to the appropriate size. If the buffer of the LBuffer object used by the LMemoryFile::SaveFileBuffer is not large enough to accommodate the file in memory, the LMemoryFile::SaveFileBufferCallBack function is called, giving the user the opportunity to reallocate the buffer to the appropriate size. In addition, the LMemoryFile::SaveFileBuffer also calls the LMemoryFile::SaveFileCallBack to the image data from the specified bitmap. The LMemoryFile::SaveFileCallBack can be overridden if the user wants to supply the image data to save.
LEADTOOLS can load overlay files, which are usually PTOCA files, by either loading directly from the disk, or by calling an overlay callback function to get the overlay bitmap from the user. To set the callback function to use, as well as the methods and the order of those methods LEADTOOLS should use to load an overlay file, call LBase::EnableOverlayCallBack. To determine the current overlay callback function, (which is the one last set), use LBase::EnableOverlayCallBack. This overlay callback must adhere to the function syntax specified in LBase::OverlayCallBack.
When loading HPGL files, you can use the LFileSettings::GetPLTOptions to get the current values for the control options used by LEADTOOLS when loading an HPGL file. You can then use LFileSettings::SetPLTOptions to change the values for the control options.
When loading RTF files, you can use the LFileSettings::GetRTFOptions to get the current values for the control options used by LEADTOOLS when loading an RTF file. You can then use LFileSettings::SetRTFOptions to change the values for the control options.
When loading PTOCA and AFP:PTOCA files, you can use the LFileSettings::GetPTKOptions to get the current values for the control options used by LEADTOOLS when loading a PTOCA file. You can then use LFileSettings::SetPTKOptions to change the values for the control options.
When loading DJVU files, you can use the LFileSettings::GetDJVOptions to get the current values for the control options used by LEADTOOLS when loading a DJVU file. You can then use LFileSettings::SetDJVOptions to change the values for the control options.
When loading WMF/EMF files, you can use the LFileSettings::GetWMFResolutionExt to get the current DPI (dots per inch) value for the control options used by LEADTOOLS when loading a WMF/EMF file. You can then use LFileSettings::SetWMFResolutionExt to change the values for the control options.
Please note that the Document/Medical editions also support the loading and saving of Mixed Raster Content (MRC) files. The Mixed Raster Content format was defined for use for color and grayscale fax as part of the RFC-2301, File Format for Internet Fax. The Mixed Raster Content mode (T.44) enables different coding methods and resolutions to be used within a single page by defining a 3-layer image model for structuring and combining the scanned image data. For more information, refer to the LEADTOOLS Mixed Raster Content (MRC) Class Library Help File.
LEADTOOLS also lets you load embedded ICC profiles. These profiles can be loaded from JPEG, TIFF or EPS files. Before loading an ICC profile, an MEMICCPROFILE structure must be initialized by calling LFile::InitICCProfile. Then, the profile itself can be loaded by calling LFile::LoadICCProfile. When the structure that contains the loaded profile is no longer needed, the memory must be freed by calling LFile::FreeICCProfile. Please note that LEAD also supports ICC Profile functions through the LTCLR DLL. For more information on these functions, refer to Using ICC Profile Functions.
LEADTOOLS supports loading TIFF CMYK files without converting the data to BGR. This is done by loading each CMYK plane as a separate LEADTOOLS bitmap using LFile::LoadCMYKArray. To save the bitmap as TIFF CMYK, call LFile::SaveCMYKArray.
Regions are saved automatically inside TIFF files. For more information, refer to Saving a Region.
For information on saving bitmaps that have been window leveled, refer to Saving Window-Leveled Bitmaps.
LEADTOOLS will attempt to load corrupted files, so you can see at least a portion of the image. For these images, the load functions will return SUCCESS, but LBitmapBase::GetLoadStatus will return an error code.
When loading TXT files, you can use the LFileSettings::GetTXTOptions to get the current values for the control options used by LEADTOOLS. You can also use LFileSettings::SetTXTOptions to change the values for the control options before loading TXT file.
When saving JBIG2 file, you can use the LFileSettings::GetJBIG2Options to get the current values for the control options used by LEADTOOLS. You can also use LFileSettings::SetJBIG2Options to change the values for the control options before saving JBIG2 file.