←Select platform

Clone(LeadRect) Method

Summary
Creates a new RasterImage object by copying an area of this RasterImage.
Syntax
C#
Objective-C
C++/CLI
Java
Python
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): 

Parameters

rc
Specifies the area to copy.

Remarks

This method copies only the current active page.

Example
C#
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 image 
	RasterImage 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 only 
	RasterImage 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 only 
	LeadRect 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 pages 
	RasterImage 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 up 
	destImage4.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:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.