public RasterImage Clone(LeadRect rc)
- (nullable LTRasterImage *)cloneWithRect:(LeadRect)rect error:(NSError **)error public RasterImage clone(LeadRect rc);
public:RasterImage^ Clone(LeadRect rc)
def Clone(self,rc):
rc
Specifies the area to copy.
This method copies only the current active page.
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 CloneExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "eye.gif");// Load the multi-page imageRasterImage srcImage = codecs.Load(srcFileName);Console.WriteLine("Pages in source image: {0}", srcImage.PageCount);// Use the Clone method to clone this image// Notice, this method only clones the current active page onlyRasterImage destImage1 = srcImage.Clone();Console.WriteLine("Pages in image created with Clone: {0}", destImage1.PageCount);Assert.IsTrue(destImage1.PageCount == 1);// Use the Clone rectangle method to clone this image// Notice, this method also clones the current active page onlyLeadRect rc = new LeadRect(0, 0, srcImage.Width / 2, srcImage.Height / 2);Console.WriteLine("Cloning with a rectangle = {0}", rc.ToString());RasterImage destImage2 = srcImage.Clone(rc);Console.WriteLine("Pages in image created with Clone(LeadRect): {0}", destImage2.PageCount);Console.WriteLine("Image created with Clone(LeadRect) size = {0} by {1}", destImage2.Width, destImage2.Height);Assert.IsTrue(destImage2.PageCount == 1);Assert.IsTrue(destImage2.Width == srcImage.Width / 2);Assert.IsTrue(destImage2.Height == srcImage.Height / 2);// Use the CloneAll method, this should create a copy// of all the pagesRasterImage destImage3 = srcImage.CloneAll();Console.WriteLine("Pages in image created with CloneAll: {0}", destImage3.PageCount);Assert.IsTrue(destImage3.PageCount == srcImage.PageCount);// Use the CloneCommand, this allows you to have a progress// bar as well as control the memory flags, here// we will create a destination image using disk memory.CloneCommand cloneCmd = new CloneCommand();cloneCmd.Progress += new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);cloneCmd.CreateFlags = RasterMemoryFlags.Disk;cloneCmd.Run(srcImage);cloneCmd.Progress -= new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);RasterImage destImage4 = cloneCmd.DestinationImage;Console.WriteLine("Pages in image created with CloneCommand: {0}", destImage4.PageCount);Console.WriteLine("Disk memory model of image created with CloneCommand: {0}", destImage4.IsDiskMemory);Assert.IsTrue(destImage4.PageCount == 1);Assert.IsTrue(destImage4.IsDiskMemory);// Clean updestImage4.Dispose();destImage3.Dispose();destImage2.Dispose();destImage1.Dispose();srcImage.Dispose();codecs.Dispose();}void cloneCmd_Progress(object sender, RasterCommandProgressEventArgs e){if (e.Percent == 0)Console.WriteLine("Clone progress started");if (e.Percent == 100)Console.WriteLine("Clone progress ended");}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 cloneExample() {final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";RasterCodecs codecs = new RasterCodecs();String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "eye.gif");// Load the multi-page imageRasterImage srcImage = codecs.load(srcFileName);System.out.printf("Pages in source image: %s%n", srcImage.getPageCount());// Use the Clone method to clone this image// Notice, this method only clones the current active page onlyRasterImage destImage1 = srcImage.clone();System.out.printf("Pages in image created with Clone: %s%n", destImage1.getPageCount());assertTrue(destImage1.getPageCount() == 1);// Use the Clone rectangle method to clone this image// Notice, this method also clones the current active page onlyLeadRect rc = new LeadRect(0, 0, srcImage.getWidth() / 2, srcImage.getHeight() / 2);System.out.printf("Cloning with a rectangle = %s%n", rc.toString());RasterImage destImage2 = srcImage.clone(rc);System.out.printf("Pages in image created with Clone(LeadRect): %s%n", destImage2.getPageCount());System.out.printf("Image created with Clone(LeadRect) size = %1s by %2s%n", destImage2.getWidth(),destImage2.getHeight());assertTrue(destImage2.getPageCount() == 1);assertTrue(destImage2.getWidth() == srcImage.getWidth() / 2);assertTrue(destImage2.getHeight() == srcImage.getHeight() / 2);// Use the CloneAll method, this should create a copy// of all the pagesRasterImage destImage3 = srcImage.cloneAll();System.out.printf("Pages in image created with CloneAll: %s%n", destImage3.getPageCount());assertTrue(destImage3.getPageCount() == srcImage.getPageCount());// Use the CloneCommand, this allows you to have a progress// bar as well as control the memory flags, here// we will create a destination image using disk memory.CloneCommand cloneCmd = new CloneCommand();cloneCmd.addProgressListener(cloneCmd_Progress);cloneCmd.setCreateFlags(RasterMemoryFlags.DISK.getValue());cloneCmd.run(srcImage);cloneCmd.removeProgressListener(cloneCmd_Progress);RasterImage destImage4 = cloneCmd.getDestinationImage();System.out.printf("Pages in image created with CloneCommand: %s%n", destImage4.getPageCount());System.out.printf("Disk memory model of image created with CloneCommand: %s%n", destImage4.isDiskMemory());assertTrue(destImage4.getPageCount() == 1);assertTrue(destImage4.isDiskMemory());// Save itcodecs.save(srcImage, combine(LEAD_VARS_IMAGES_DIR, "Result.gif"), RasterImageFormat.GIF, 0);// Clean updestImage4.dispose();destImage3.dispose();destImage2.dispose();destImage1.dispose();srcImage.dispose();codecs.dispose();assertTrue("file unsuccessfully saved to " + combine(LEAD_VARS_IMAGES_DIR, "Result.gif"),(new File(combine(LEAD_VARS_IMAGES_DIR, "Result.gif"))).exists());System.out.printf("File saved successfully to %s%n", combine(LEAD_VARS_IMAGES_DIR, "Result.gif"));}RasterImageProgressListener cloneCmd_Progress = new RasterImageProgressListener() {@Overridepublic void RasterImageProgressAlert(RasterImageProgressEvent arg0) {if (arg0.getPercentComplete() == 0) {System.out.println("Clone progress started");}if (arg0.getPercentComplete() == 100) {System.out.println("Clone progress ended");}}};
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
