public bool OffsetValid { get; } public:property bool OffsetValid {bool get();}
OffsetValid # get and (CodecsSaveImageEventArgs)
true if the value in the Offset property is valid, false if it is being ignored. The default value is false.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Svg;public void SaveImageExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_SaveImage.cmp");// Load the source file (make sure to load as 24 bits/pixel)RasterImage image = codecs.Load(srcFileName, 24, CodecsLoadByteOrder.Bgr, 1, 1);// Instruct RasterCodecs to generate the saved scanlines data for us to manipulatecodecs.Options.Save.RetrieveDataFromImage = true;// Add a handler to the SaveImage eventcodecs.SaveImage += new EventHandler<CodecsSaveImageEventArgs>(codecs_SaveImage);// Save the imagecodecs.Save(image, destFileName, RasterImageFormat.Cmp, 24);codecs.SaveImage -= new EventHandler<CodecsSaveImageEventArgs>(codecs_SaveImage);image.Dispose();// Clean upcodecs.Dispose();}private void codecs_SaveImage(object sender, CodecsSaveImageEventArgs e){// This example works with images saved as 24-bit per pixel onlyDebug.Assert(e.Image.BitsPerPixel == 24);e.Cancel = false;if (e.Row == 0){// Show information about the image being savedDebug.WriteLine("Saving an image with {0} bpp to {1}", e.Image.BitsPerPixel, e.FileName);Debug.WriteLine("Offset: {0}, OffsetValid: {1}", e.Offset, e.OffsetValid);Debug.WriteLine("Page: {0} of {1}", e.Page, e.LastPage - e.FirstPage + 1);Debug.WriteLine("Page percent: {0}%, Total percent: {1}%, Image Page: {2}", e.PagePercent, e.TotalPercent, e.ImagePage);if (e.Stream != null){Debug.WriteLine("Stream: {0}", e.Stream);}}Debug.WriteLine("Row: {0}, Lines {1}", e.Row, e.Lines);// Get the scanlines from the imageint scanlineLength = e.Image.BytesPerLine;byte[] scanline = new byte[scanlineLength];// Loop through all the scanlines in the datafor (int y = 0; y < e.Lines; y++){// Get this rowe.Buffer.GetData(y * scanlineLength, scanline, 0, scanlineLength);// We got the data, now double the intensity// Remember, this is 24-bits/pixelfor (int x = 0; x < scanlineLength; x++){scanline[x] *= 2;}// Copy it back to the event buffere.Buffer.SetData(y * scanlineLength, scanline, 0, scanlineLength);}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}
import java.io.*;import java.net.*;import java.nio.file.Paths;import java.util.*;import java.time.Instant;import java.time.Duration;import org.junit.*;import org.junit.runner.JUnitCore;import org.junit.runner.Result;import org.junit.runner.notification.Failure;import static org.junit.Assert.*;import leadtools.*;import leadtools.codecs.*;import leadtools.codecs.RasterCodecs.FeedCallbackThunk;import leadtools.drawing.internal.*;import leadtools.imageprocessing.*;import leadtools.imageprocessing.color.ChangeIntensityCommand;import leadtools.svg.*;public void saveImageExample() {final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";RasterCodecs codecs = new RasterCodecs();String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "Image1.cmp");String destFileName = combine(LEAD_VARS_IMAGES_DIR, "Image2.cmp");// Load the source file (make sure to load as 24 bits/pixel)RasterImage image = codecs.load(srcFileName, 24, CodecsLoadByteOrder.BGR, 1, 1);// Instruct RasterCodecs to generate the saved scanlines data for us to// manipulatecodecs.getOptions().getSave().setRetrieveDataFromImage(true);// Add a handler to the SaveImage eventcodecs.addSaveImageListener(codecsSaveImage);// Save the imagecodecs.save(image, destFileName, RasterImageFormat.CMP, 24);assertTrue("File unsuccessfully saved to" + destFileName, (new File(destFileName)).exists());System.out.println("File is saved to" + destFileName);// Clean upcodecs.removeSaveImageListener(codecsSaveImage);image.dispose();codecs.dispose();}CodecsSaveImageListener codecsSaveImage = new CodecsSaveImageListener() {@Overridepublic void onSaveImage(CodecsSaveImageEvent e) {// This example works with images saved as 24-bit per pixel onlyassertTrue(e.getImage().getBitsPerPixel() == 24);e.setCancel(false);if (e.getRow() == 0) {// Show information about the image being savedSystem.out.println("Saving an image with " + e.getImage().getBitsPerPixel() + " bpp");System.out.println("Page: " + e.getPage() + " of " + (e.getLastPage() - e.getFirstPage() + 1));System.out.println("Page percent: " + e.getPagePercent() + "%, Total percent: " + e.getTotalPercent()+ "%, Image Page: " + e.getImagePage());if (e.getStream() != null) {System.out.println("Stream: " + e.getStream());}}System.out.println("Row: " + e.getRow() + ", Lines " + e.getLines());// Get the scanlines from the imageint scanlineLength = e.getImage().getBytesPerLine();byte[] scanline = new byte[scanlineLength];// Loop through all the scanlines in the datafor (int y = 0; y < e.getLines(); y++) {// Get this rowe.getBuffer().getData(y * scanlineLength, scanline, 0, scanlineLength);// We got the data, now double the intensity// Remember, this is 24-bits/pixelfor (int x = 0; x < scanlineLength; x++) {scanline[x] *= 2;}// Copy it back to the event buffere.getBuffer().setData(y * scanlineLength, scanline, 0, scanlineLength);}}};
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
