←Select platform

Progress Event

Summary
Occurs during the processing of the image processing commands.
Syntax
C#
C++/CLI
Python
public event EventHandler<RasterCommandProcessorProgressEventArgs> Progress 
public: 
event EventHandler<RasterCommandProcessorProgressEventArgs^>^ Progress 
def Progress(sender,e): # sender: RasterCommandProcessor e: RasterCommandProcessorProgressEventArgs 
Event Data

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

PropertyDescription
Cancel Determine how to process or cancel the current command.
Command Gets the RasterCommand object currently being executed.
CommandNumber Gets the index of the current RasterCommand in the Commands collection.
Image Gets the RasterImage object being processed.
ImageNumber Gets the index of the current RasterImage in the Images collection.
Percent Gets the percentage completion of the current command.
TotalCommands Gets the total number of commands to be executed.
TotalImages Gets the total number of images to be processed.
Remarks

You can use this event to get progress status, or to cancel the process.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
 
 
public void RasterCommandProcessorExample() 
{ 
	RasterCodecs codecs = new RasterCodecs(); 
 
	string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "RasterCommandProcessor.tif"); 
 
	// create a raster command processor 
	RasterCommandProcessor processor = new RasterCommandProcessor(); 
 
	// add the commands (color-res to 8 then flip) 
	processor.Commands.Add(new ColorResolutionCommand( 
	   ColorResolutionCommandMode.InPlace, 
	   8, 
	   RasterByteOrder.Rgb, 
	   RasterDitheringMethod.None, 
	   ColorResolutionCommandPaletteFlags.Optimized, 
	   null)); 
	processor.Commands.Add(new FlipCommand(false)); 
 
	// load the images 
	const int imageCount = 4; 
	for (int i = 0; i < imageCount; i++) 
	{ 
		string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, string.Format("Image{0}.cmp", (i + 1) % 2 + 1)); 
		processor.Images.Add(codecs.Load(srcFileName)); 
	} 
 
	// run the commands 
	processor.Progress += new EventHandler<RasterCommandProcessorProgressEventArgs>(processor_Progress); 
	processor.Run(); 
	processor.Progress -= new EventHandler<RasterCommandProcessorProgressEventArgs>(processor_Progress); 
 
	// save the result image as multi-page tif file 
	if (File.Exists(destFileName)) 
		File.Delete(destFileName); 
 
	for (int i = 0; i < imageCount; i++) 
		codecs.Save( 
		   processor.Images[i], 
		   destFileName, 
		   RasterImageFormat.Tif, 
		   8, 
		   1, 
		   1, 
		   -1, 
		   CodecsSavePageMode.Append); 
 
	// clean up 
	for (int i = 0; i < imageCount; i++) 
		processor.Images[i].Dispose(); 
} 
 
void processor_Progress(object sender, RasterCommandProcessorProgressEventArgs e) 
{ 
	// show information about the command 
	Console.Write("Running command {0} ({1}) of {2}, ", e.CommandNumber, e.Command, e.TotalCommands); 
	Console.Write("On image {0} ({1} by {2} pixels) of {3}, ", e.ImageNumber, e.Image.Width, e.Image.Height, e.TotalImages); 
	Console.WriteLine("{0}% done", e.Percent); 
} 
 
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.