[HandleProcessCorruptedStateExceptionsAttribute()]protected virtual void Dispose(bool disposing)
protected:virtual void Dispose(bool disposing)
def Dispose(self,disposing):
disposing
True to release both managed and unmanaged resources; False to release only unmanaged resources.
The RasterImage class implements the IDisposable interface, it is recommended that you follow the standard .NET dispose pattern when using the RasterImage class. For more information, refer to the IDisposable interface documentation in MSDN, the IsDisposed property and the RasterImage.Disposed event.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Dicom;using Leadtools.Drawing;using Leadtools.Controls;using Leadtools.Svg;public void RasterImageExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");string destFileName1 = Path.Combine(LEAD_VARS.ImagesDir, "Image1_RasterImage1.bmp");string destFileName2 = Path.Combine(LEAD_VARS.ImagesDir, "Image1_RasterImage2.bmp");// Load the imageRasterImage srcImage = codecs.Load(srcFileName);// Creates a new image in memory with same dimensions as the source imageRasterImage destImage = new RasterImage(RasterMemoryFlags.Conventional,srcImage.Width,srcImage.Height,srcImage.BitsPerPixel,srcImage.Order,srcImage.ViewPerspective,srcImage.GetPalette(),IntPtr.Zero,0);// Copy the data from the source image to the destination imagesrcImage.Access();destImage.Access();byte[] buffer = new byte[srcImage.BytesPerLine];for (int y = 0; y < srcImage.Height; y++){srcImage.GetRow(y, buffer, 0, buffer.Length);destImage.SetRow(y, buffer, 0, buffer.Length);}destImage.Release();srcImage.Release();// We do not need the source image anymoresrcImage.Dispose();// save the destination imagecodecs.Save(destImage, destFileName1, RasterImageFormat.Bmp, 24);// perform image processing on the imageFlipCommand flipCmd = new FlipCommand();flipCmd.Horizontal = false;flipCmd.Run(destImage);// save itcodecs.Save(destImage, destFileName2, RasterImageFormat.Bmp, 24);// Clean updestImage.Dispose();codecs.Dispose();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}
import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import java.util.ArrayList;import java.util.List;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.imageprocessing.core.*;import leadtools.svg.*;import leadtools.imageprocessing.CloneCommand;import leadtools.imageprocessing.FillCommand;import leadtools.imageprocessing.FlipCommand;import leadtools.imageprocessing.GrayscaleCommand;import leadtools.imageprocessing.color.InvertCommand;import leadtools.imageprocessing.color.PosterizeCommand;public void rasterImageExample() {final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";RasterCodecs codecs = new RasterCodecs();String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "Image1.cmp");String destFileName1 = combine(LEAD_VARS_IMAGES_DIR, "Image1_RasterImage1.bmp");String destFileName2 = combine(LEAD_VARS_IMAGES_DIR, "Image1_RasterImage2.bmp");// Load the imageRasterImage srcImage = codecs.load(srcFileName);// Creates a new image in memory with same dimensions as the source imagebyte[] userData = new byte[0];RasterImage destImage = new RasterImage(RasterMemoryFlags.CONVENTIONAL.getValue(), srcImage.getWidth(),srcImage.getHeight(),srcImage.getBitsPerPixel(), srcImage.getOrder(), srcImage.getViewPerspective(), srcImage.getPalette(),userData, 0);// Copy the data from the source image to the destination imagesrcImage.access();destImage.access();byte[] buffer = new byte[srcImage.getBytesPerLine()];for (int y = 0; y < srcImage.getHeight(); y++) {srcImage.getRow(y, buffer, 0, buffer.length);destImage.setRow(y, buffer, 0, buffer.length);}destImage.release();srcImage.release();// We do not need the source image anymoresrcImage.dispose();// Save the destination imagecodecs.save(destImage, destFileName1, RasterImageFormat.BMP, 24);// Perform image processing on the imageFlipCommand flipCmd = new FlipCommand();flipCmd.setHorizontal(false);flipCmd.run(destImage);// Save itcodecs.save(destImage, destFileName2, RasterImageFormat.BMP, 24);// Clean updestImage.dispose();codecs.dispose();assertTrue("file unsuccessfully saved to " + destFileName2, (new File(destFileName2)).exists());System.out.printf("File saved successfully to %s%n", destFileName2);}
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
