public class CodecsSaveImageEventArgs : EventArgs
Public Class CodecsSaveImageEventArgs
Inherits System.EventArgs
@interface LTCodecsSaveImageEventArgs : NSObject
public class CodecsSaveImageEvent extends LeadEvent
public ref class CodecsSaveImageEventArgs : public System.EventArgs
The Buffer property works as the input and output buffer containing the image data to save. If the value of RetrieveDataFromImage is set to false (the default), then the user is always responsible for providing the image data by setting in Buffer. If the value of RetrieveDataFromImage is set to true, then the RasterCodecs object will populate the Buffer prior to raising this event. The user can then inspect or modify the scanlines data or simple ignore it to save the original image data as is.
Notice that on either case, the user must provide the scanline data in the source image original format (stored in the Image property. The RasterCodecs object will then convert this data to the appropriate output format if needed, for example, if the user instructed the RasterCodecs object to save the image in a different file format than the original image.
This event can also be used to provide feedback to the user on the save operation progression and a chance for cancellation. To understand the various page and percentages, consider the following example.
File Ocr.tif is a multipage TIF file containing 4 pages. We want to save pages 2 through 4 (a total of 3 pages). We make the following call:
private void Test(RasterCodecs rasterCodecsObject)
{
// Load the image
RasterImage image = rasterCodecsObject.Load(@"C:\LEADTOOLS21\Resources\Images\Ocr.tif");
// Tell the RasterCodecs object to automatically set the image data to save from the source image
rasterCodecsObject.Options.Save.RetrieveDataFromImage = true;
// Subscribe to the SaveImage event
rasterCodecsObject.SaveImage += new EventHandler<CodecsSaveImageEventArgs>(rasterCodecsObject_SaveImage);
// Save pages 2 through 4 (total of 3 pages)
int firstImagePage = 2;
int lastImagePage = 4;
int firstFilePage = 1;
// Save
rasterCodecsObject.Save(
image,
@"C:\LEADTOOLS21\Resources\Images\Ocr_pages2through4.tif",
RasterImageFormat.Tif,
1, // Bits per pixel
firstImagePage,
lastImagePage,
firstFilePage,
CodecsSavePageMode.Overwrite);
// Unsubscribe to the LoadImage
event rasterCodecsObject.SaveImage -= new EventHandler<CodecsSaveImageEventArgs>(rasterCodecsObject_SaveImage);
image.Dispose();
}
private void rasterCodecsObject_SaveImage(object sender, CodecsSaveImageEventArgs e)
{
}
Inside the event handler, we will have the following values:
Member | Values |
---|---|
FirstPage | Will always be 1 since we specified 1 as the first file page number. |
Page | Will go from 1 through 3 since we are saving 3 pages total starting as destination (file) page number 1. |
LastPage | Will always be 3 since we are saving 3 pages from 1 to 3. |
ImagePage | Will go from 2 through 4 since we are saving existing pages 2, 3, and 4. |
PagePercent | Will go from 0 to 100 three times since we are saving three pages. This value will reset back to zero whenever Page and ImagePage changes. |
TotalPercent | Will go from 0 to 100 during the whole saving operation. When this value is 100, all the pages are saved and the method returns. |
For an example, refer to RasterCodecs.SaveImage.
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document