public bool AllPages { get; set; } Public Property AllPages As Boolean @property (nonatomic, assign) BOOL allPages public final boolean getAllPages()public final void setAllPages(boolean value)
true to clone all the pages if the source image is multipage; false, otherwise.
If the source image (the image passed to the RasterCommand.Run method) contains multiple pages, then you can use the AllPages property to control whether the CloneCommand will create a copy of the current active page or all the pages in the image.
Note that when the source image has multiple pages and the value of AllPages was set to true, then the RasterCommand.Progress event will fire from 0 to 100 for each page processed. If an overall progress percentage is desired, then you can inspect the RasterImage.Page and RasterImage.PageCount properties of the SourceImage property to calculate this value as shown in the example below.
The default value of this property is false to clone only the current page.
This example will clone a multipage image and shows the over-all progress value.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;private void CloneAllTest(){RasterCodecs codecs = new RasterCodecs();// Create a multi-page image for testing purposesRasterImage image = null;for (int i = 1; i <= 4; i++){RasterImage pageImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "OCR" + i.ToString() + ".tif"));if (image == null)image = pageImage;else{image.AddPage(pageImage);pageImage.Dispose();}}Console.WriteLine("Input image has {0} pages", image.PageCount);// Clone all pagesCloneCommand cloneCmd = new CloneCommand();cloneCmd.AllPages = true;cloneCmd.Progress += new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);cloneCmd.Run(image);cloneCmd.Progress -= new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);RasterImage destinationImage = cloneCmd.DestinationImage;Console.WriteLine("Cloned image has {0} pages", destinationImage.PageCount);destinationImage.Dispose();image.Dispose();codecs.Dispose();}private void cloneCmd_Progress(object sender, RasterCommandProgressEventArgs e){// By using the SourceImage property of the CloneCommand we can find out// the progress for the current page as well as the overallCloneCommand cmd = sender as CloneCommand;int overallPercent;if (cmd.AllPages && cmd.SourceImage.PageCount > 1){// For multiple-pages, the command will fire the Progress event from 0 to 100 for each page// Use the source image Page property to find out where we are in overall completetionoverallPercent = ((cmd.SourceImage.Page - 1) * 100 + e.Percent) / cmd.SourceImage.PageCount;}else{// Otherwise, the percent is the same as the current pageoverallPercent = e.Percent;}Console.WriteLine("Current page completion: {0} of {1} - {2}% - Overall image completion {3}%", cmd.SourceImage.Page, cmd.SourceImage.PageCount, e.Percent, overallPercent);}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingPrivate Sub CloneAllTest()Dim codecs As New RasterCodecs()' Create a multi-page image for testing purposesDim image As RasterImage = NothingFor i As Integer = 1 To 4Dim pageImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "\OCR" + i.ToString() + ".tif"))If IsNothing(image) Thenimage = pageImageElseimage.AddPage(pageImage)pageImage.Dispose()End IfNextConsole.WriteLine("Input image has {0} pages", image.PageCount)' Clone all pagesDim cloneCmd As New CloneCommand()cloneCmd.AllPages = TrueAddHandler cloneCmd.Progress, AddressOf cloneCmd_ProgresscloneCmd.Run(image)RemoveHandler cloneCmd.Progress, AddressOf cloneCmd_ProgressDim destinationImage As RasterImage = cloneCmd.DestinationImageConsole.WriteLine("Cloned image has {0} pages", destinationImage.PageCount)destinationImage.Dispose()image.Dispose()codecs.Dispose()End SubPrivate Sub cloneCmd_Progress(ByVal sender As Object, ByVal e As RasterCommandProgressEventArgs)' By using the SourceImage property of the CloneCommand we can find out' the progress for the current page as well as the overallDim cmd As CloneCommand = DirectCast(sender, CloneCommand)Dim overallPercent As IntegerIf cmd.AllPages AndAlso cmd.SourceImage.PageCount > 1 Then' For multiple-pages, the command will fire the Progress event from 0 to 100 for each page' Use the source image Page property to find out where we are in overall completetionoverallPercent = ((cmd.SourceImage.Page - 1) * 100 + e.Percent) \ cmd.SourceImage.PageCountElse' Otherwise, the percent is the same as the current pageoverallPercent = e.PercentEnd IfConsole.WriteLine("Current page completion: {0} of {1} - {2}% - Overall image completion {3}%",cmd.SourceImage.Page, cmd.SourceImage.PageCount, e.Percent, overallPercent)End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"End Class
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
