←Select platform

Cancel Property

Summary
A value indicating whether to abort the resize operation.
Syntax
C#
C++/CLI
Python
public bool Cancel { get; set; } 
public: 
property bool Cancel { 
   bool get(); 
   void set (    bool ); 
} 
Cancel # get and set (RasterImageResizeEventArgs) 

Property Value

true to abort the resize operation, false to continue.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
 
 
public void RasterImageResizeExample() 
{ 
	string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
	string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_RasterImageResize.bmp"); 
 
	using (RasterCodecs codecs = new RasterCodecs()) 
	{ 
		// Load the source image 
		using (RasterImage srcImage = codecs.Load(srcFileName)) 
		{ 
			// We will resize to half the original size 
			int destWidth = srcImage.Width / 2; 
			int destHeight = srcImage.Height / 2; 
 
			// Create the destination image 
			using (RasterImage destImage = new RasterImage( 
			   RasterMemoryFlags.Conventional, 
			   destWidth, 
			   destHeight, 
			   srcImage.BitsPerPixel, 
			   srcImage.Order, 
			   srcImage.ViewPerspective, 
			   srcImage.GetPalette(), 
			   IntPtr.Zero, 
			   0)) 
			{ 
				RasterImageResize resize = new RasterImageResize(); 
 
				// Add Event Handler 
				resize.Resize += new EventHandler<RasterImageResizeEventArgs>(resize_Resize); 
 
				byte[] buffer = new byte[destImage.BytesPerLine]; 
 
				// Start the resize process 
				resize.Start( 
				   srcImage, 
				   destWidth, 
				   destHeight, 
				   srcImage.BitsPerPixel, 
				   srcImage.Order, 
				   srcImage.DitheringMethod, 
				   RasterSizeFlags.None, 
				   srcImage.GetPalette()); 
 
				destImage.Access(); 
				// get the rows for the resized image, one by one 
				for (int row = 0; row < destImage.Height; row++) 
				{ 
					resize.ResizeBuffer(row, 0, buffer, 0, destImage.BytesPerLine); 
					destImage.SetRow(row, buffer, 0, destImage.BytesPerLine); 
				} 
				destImage.Release(); 
				resize.Stop(); 
 
				// Save the destination image 
				codecs.Save(destImage, destFileName, RasterImageFormat.Bmp, 24); 
			} 
		} 
	} 
} 
 
private void resize_Resize(object sender, RasterImageResizeEventArgs e) 
{ 
	// e.Row should ALWAYS be less than e.Image.Height 
	if (e.Row >= e.Image.Height) 
	{ 
		e.Cancel = true; // abort the resize 
		return; 
	} 
 
	byte[] buffer = new byte[e.Bytes]; 
	e.Image.Access(); 
	e.Image.GetRowColumn(e.Row, e.Column, buffer, 0, e.Bytes); 
	e.Image.Release(); 
	Marshal.Copy(buffer, 0, e.Buffer, e.Bytes); 
	Console.WriteLine("{0}, {1}", e.Row, e.Column); 
} 
 
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.