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 files:
Visual Basic
' Startup the LEADTOOLS I/O engine
Leadtools.Codecs.RasterCodecs.Startup()
' Create a new instance of the RasterCodecs class
Dim codecs As New Leadtools.Codecs.RasterCodecs()
' Load an image at its own bits per pixel
Dim image As Leadtools.RasterImage = codecs.Load( _
"c:\Test.cmp", _
0, _
Leadtools.Codecs.CodecsLoadByteOrder.Bgr, _
1, _
1)
' Save the image as a 24-bit Windows BMP file
codecs.Save( _
image, _
"C:\Test.bmp", _
Leadtools.RasterImageFormat.Bmp, _
24, _
1, _
1, _
1, _
Leadtools.Codecs.CodecsSavePageMode.Overwrite)
' Dispose of the objects we created
image.Dispose()
codecs.Dispose()
' Shutdown the LEADTOOLS I/O engine
Leadtools.Codecs.RasterCodecs.Shutdown()
C#
// Startup the LEADTOOLS I/O engine
Leadtools.Codecs.RasterCodecs.Startup();
// Create a new instance of the RasterCodecs class
Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs();
// Load an image at its own bits per pixel
Leadtools.RasterImage image = codecs.Load(
@"c:\Test.cmp",
0,
Leadtools.Codecs.CodecsLoadByteOrder.Bgr,
1,
1);
// Save the image as a 24-bit Windows BMP file
codecs.Save(
image,
@"C:\Test.bmp",
Leadtools.RasterImageFormat.Bmp,
24,
1,
1,
1,
Leadtools.Codecs.CodecsSavePageMode.Overwrite);
// Dispose of the objects we created
image.Dispose();
codecs.Dispose();
// Shutdown the LEADTOOLS I/O engine
Leadtools.Codecs.RasterCodecs.Shutdown();
J#
// Startup the LEADTOOLS I/O engine
Leadtools.Codecs.RasterCodecs.Startup();
// Create a new instance of the RasterCodecs class
Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs();
// Load an image at its own bits per pixel
Leadtools.RasterImage image = codecs.Load("c:\\PSPMainWindow.JPG", 0, Leadtools.Codecs.CodecsLoadByteOrder.Bgr, 1, 1);
Toolkit.getDefaultToolkit().getImage(getClass().getResource("mario.gif"));
// Save the image as a 24-bit Windows BMP file
codecs.Save(image,"c:\\Test.bmp" ,Leadtools.RasterImageFormat.Bmp,24,1,1,1,Leadtools.Codecs.CodecsSavePageMode.Overwrite);
// Dispose of the objects we created
image.Dispose();
codecs.Dispose();
// Shutdown the LEADTOOLS I/O engine
Leadtools.Codecs.RasterCodecs.Shutdown();
LEADTOOLS also supports super compressed images. Only 1-bit and 24-bit images can be kept super compressed in memory. For more information, refer to Super Compressed Images. 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 Exif Features Implementing TIFF Comments and Tags 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.
You can control the execution of a load procedure as you supply transmitted image data. Refer to the RasterCodecs.StartFeedLoad, RasterCodecs.FeedLoad, and RasterCodecs.StopFeedLoad methods.
The Load method lets you resize the image to new dimensions as it is loaded by setting the desired width and height. The LoadImage method loads an MRC image file into an image (the file can be in any supported image file format.)
To save an image to a file in a memory buffer, Save uses an optional callback method to allow additional processing of the saved material.
Regions are saved automatically inside TIFF files. For more information, refer to Saving a Region. Note, however, that the ability to save a region inside a TIFF file must be unlocked. This requires the Document Imaging Toolkit, Document Imaging Suite, Medical Imaging Toolkit, or Medical Imaging Suite.
Window-leveling applied with the WindowLevelCommandclass can be saved to TIF or DICOM formats without changing the image data. For more information, refer to Saving Window-Leveled Images.
LEADTOOLS supports loading TIFF CMYK files without converting the data to BGR.This is done by loading each CMYK plane as a separate page in an Image using LoadCmykPlanes. To save the planes as TIFF CMYK, call SaveCmykPlanes. For more information, refer to Handling CMYK Files as Separate Images.