←Select platform

TotalPercent Property

Gets the overall completion percentage for the save operation.
public int TotalPercent { get; } 
@property (nonatomic, assign, readonly) NSInteger totalPercent; 
public int getTotalPercent() 
property int TotalPercent { 
   int get(); 
TotalPercent # get  (CodecsSaveImageEventArgs) 

Property Value

A number between 0 and 100 that indicates the overall completion percentage of the save operation. The default value is 0.


Using the PagePercent and TotalPercent properties, you can use the CodecsSaveImageEventArgs to show a progress bar of the current save operation.

When saving a multipage file, PagePercent will go from 0 to 100 for each page saved while TotalPercent will go from 0 to 100 only once during the whole page operation. Usually, you will use TotalPercent to show an overall save progress if the multipage image is considered to be one document. If however, individual progress is required for each page, then you can track the PagePercent property as well.

When saving a single page file or one page to a multipage file, both PagePercent and TotalPercent will go from 0 to 100 simultaneously.

using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
public void SaveImageExample() 
   RasterCodecs codecs = new RasterCodecs(); 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
   string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_SaveImage.cmp"); 
   // Load the source file (make sure to load as 24 bits/pixel) 
   RasterImage image = codecs.Load(srcFileName, 24, CodecsLoadByteOrder.Bgr, 1, 1); 
   // Instruct RasterCodecs to generate the saved scanlines data for us to manipulate 
   codecs.Options.Save.RetrieveDataFromImage = true; 
   // Add a handler to the SaveImage event 
   codecs.SaveImage += new EventHandler<CodecsSaveImageEventArgs>(codecs_SaveImage); 
   // Save the image 
   codecs.Save(image, destFileName, RasterImageFormat.Cmp, 24); 
   codecs.SaveImage -= new EventHandler<CodecsSaveImageEventArgs>(codecs_SaveImage); 
   // Clean up 
private void codecs_SaveImage(object sender, CodecsSaveImageEventArgs e) 
   // This example works with images saved as 24-bit per pixel only 
   Debug.Assert(e.Image.BitsPerPixel == 24); 
   e.Cancel = false; 
   if (e.Row == 0) 
      // Show information about the image being saved 
      Debug.WriteLine("Saving an image with {0} bpp to {1}", e.Image.BitsPerPixel, e.FileName); 
      Debug.WriteLine("Offset: {0}, OffsetValid: {1}", e.Offset, e.OffsetValid); 
      Debug.WriteLine("Page: {0} of {1}", e.Page, e.LastPage - e.FirstPage + 1); 
      Debug.WriteLine("Page percent: {0}%, Total percent: {1}%, Image Page: {2}", e.PagePercent, e.TotalPercent, e.ImagePage); 
      if(e.Stream != null) 
         Debug.WriteLine("Stream: {0}", e.Stream); 
   Debug.WriteLine("Row: {0}, Lines {1}", e.Row, e.Lines); 
   // Get the scanlines from the image 
   int scanlineLength = e.Image.BytesPerLine; 
   byte[] scanline = new byte[scanlineLength]; 
   // Loop through all the scanlines in the data 
   for (int y = 0; y < e.Lines; y++) 
      // Get this row 
      e.Buffer.GetData(y * scanlineLength, scanline, 0, scanlineLength); 
      // We got the data, now double the intensity 
      // Remember, this is 24-bits/pixel 
      for (int x = 0; x < scanlineLength; x++) 
         scanline[x] *= 2; 
      // Copy it back to the event buffer 
      e.Buffer.SetData(y * scanlineLength, scanline, 0, scanlineLength); 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 

Target Platforms

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

Leadtools.Codecs Assembly

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