←Select platform

Progress Event

Summary
Occurs during the image processing command, to provide status on the progress of the command.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public event EventHandler<RasterCommandProgressEventArgs> Progress 
typedef void (^LTRasterCommandProgress)(NSInteger percent, BOOL *cancel) 
 
- (BOOL)run:(LTRasterImage *)image  
   progress:(nullable LTRasterCommandProgress)progressHandler  
      error:(NSError **)error 
public void addProgressListener(RasterImageProgressListener listener) 
public void removeProgressListener(RasterImageProgressListener listener) 
public: 
event EventHandler<RasterCommandProgressEventArgs^>^ Progress 
def Progress(sender,e): # sender: RasterCommand e: RasterCommandProgressEventArgs 
Event Data

The event handler receives an argument of type RasterCommandProgressEventArgs containing data related to this event. The following RasterCommandProgressEventArgs properties provide information specific to this event.

PropertyDescription
Cancel Gets or sets a value indicating whether the image processing command should be canceled.
Remarks

The Progress event is fired when the Run method. RasterCommandProgressEventArgs provides data on the current progress of the image processing command. You can use this data to provide visual feedback to the user.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
 
 
public void RasterCommandExample() 
{ 
	RasterCodecs codecs = new RasterCodecs(); 
 
	string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
	string rotatedFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_rotated.bmp"); 
	string flippedFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_flipped.bmp"); 
 
	// Load the source image from disk 
	RasterImage image = codecs.Load(srcFileName); 
 
	// flip the image 
	FlipCommand flip = new FlipCommand(false); 
	RunCommand(image, flip); 
 
	// save the image 
	codecs.Save(image, flippedFileName, RasterImageFormat.Bmp, 24); 
 
	// rotate the image by 45 degrees 
	RotateCommand rotate = new RotateCommand(); 
	rotate.Angle = 45 * 100; 
	rotate.FillColor = RasterColor.FromKnownColor(RasterKnownColor.White); 
	rotate.Flags = RotateCommandFlags.Resize; 
	RunCommand(image, rotate); 
 
	// save the image 
	codecs.Save(image, rotatedFileName, RasterImageFormat.Bmp, 24); 
 
	// clean up 
	image.Dispose(); 
	codecs.Dispose(); 
} 
 
bool cancelAt50; 
 
void RunCommand(RasterImage image, RasterCommand command) 
{ 
	// subscribe to the progress event of the command 
	command.Progress += new EventHandler<RasterCommandProgressEventArgs>(command_Progress); 
 
	// if this is a flip command, we want to stop at 50 percent 
	cancelAt50 = command is FlipCommand; 
 
	// run the command 
	command.Run(image); 
 
	command.Progress -= new EventHandler<RasterCommandProgressEventArgs>(command_Progress); 
} 
 
void command_Progress(object sender, RasterCommandProgressEventArgs e) 
{ 
	// show the percentage 
	Console.WriteLine(e.Percent); 
 
	// check if we need to cancel the command at 50% 
	if (e.Percent == 50 && cancelAt50) 
		e.Cancel = true; 
} 
 
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.