←Select platform

CodecsLoadImageEventArgs Class

Summary
Provides information for the RasterCodecs.LoadImage event.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public class CodecsLoadImageEventArgs : EventArgs 
@interface LTCodecsLoadImageEventArgs : NSObject 
public class CodecsLoadImageEvent extends LeadEvent 
public ref class CodecsLoadImageEventArgs : public System.EventArgs  
class CodecsLoadImageEventArgs(EventArgs): 
Remarks

To understand the various page and percentages, consider the following example.

File Ocr.tif is a multipage TIF file containing 4 pages. We want to load pages 2 through 4 (a total of 3 pages). We make the following call:

C#
private RasterImage Test(RasterCodecs rasterCodecsObject) 
{  
   // Subscribe to the LoadImage event  
   rasterCodecsObject.LoadImage += new EventHandler<CodecsLoadImageEventArgs>(rasterCodecsObject_LoadImage);  
 
   // Load pages 2 through 4 (total of 3 pages)  
   RasterImage image = rasterCodecsObject.Load(@"C:\LEADTOOLS22\Resources\Images\Ocr.tif", 0, CodecsLoadByteOrder.BgrOrGray, 2, 4); 
    
   // Unsubscribe to the LoadImage event  
   rasterCodecsObject.LoadImage -= new EventHandler<CodecsLoadImageEventArgs>(rasterCodecsObject_LoadImage);  
    
   return image; 
}  
 
private void rasterCodecsObject_LoadImage(object sender, CodecsLoadImageEventArgs e) 
{ 
} 

Inside the event handler, we will have the following values:

Member Values
FirstPage Will always be 2 since we specified 2 as the first page to load.
Page Will go from 2 through 4 since we are loading pages 2, 3 and 4.
LastPage Will always be 4 since we specified 4 as the last page to load.
ImagePage Will go from 1 through 3 since we are loading new pages 1, 2 and 3.
PagePercent Will go from 0 to 100 three times since we are loading three pages. This value will reset back to zero whenever Page and ImagePage changes.
TotalPercent Will go from 0 to 100 during the whole loading operation. When this value is 100, all the pages are loaded and the method returns.
Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
private void Codecs_LoadImage(object sender, CodecsLoadImageEventArgs e) 
{ 
   e.Cancel = true; 
 
   // get all properties for the CodecsLoadImageEventArgs class. 
   Debug.WriteLine("File name is: {0}", e.FileName); 
   Debug.WriteLine("The Image width and height is: {0},{1}", e.Image.Width, e.Image.Height); 
   Debug.WriteLine("The Length of the buffer is: {0}", e.Buffer.Length); 
   Debug.WriteLine("The current row in the first line of the buffer is: {0}", e.Row); 
   Debug.WriteLine("The number of lines in the buffer is: {0}", e.Lines); 
 
   if (e.OffsetValid) 
   { 
      Debug.WriteLine("Offset count is : {0}", e.OffsetCount); 
      Debug.WriteLine("Offset value is : {0}", e.Offset); 
   } 
 
   if (e.TileValid) 
   { 
      LeadRect rect = e.Tile; 
      Debug.WriteLine("Tile Dimension ({0},{1},{2},{3)}", rect.X, rect.Y, rect.Width, rect.Height); 
   } 
 
   Debug.WriteLine("Image p number: {0}", e.ImagePage); 
   Debug.WriteLine("First page number: {0}", e.FirstPage); 
   Debug.WriteLine("Current page number: {0}", e.Page); 
   Debug.WriteLine("Last page number: {0}", e.LastPage); 
   Debug.WriteLine("Page percent: {0}%", e.PagePercent); 
   Debug.WriteLine("Total percent: {0}%", e.TotalPercent); 
   Debug.WriteLine("Flags = {0}", e.Flags); 
 
   System.IO.Stream loadStream = e.Stream; 
   CodecsImageInfo info = e.Info; 
   e.Cancel = false; 
} 
 
 
public void LoadImageExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   codecs.LoadImage += new EventHandler<CodecsLoadImageEventArgs>(Codecs_LoadImage); 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")); 
   codecs.LoadImage -= new EventHandler<CodecsLoadImageEventArgs>(Codecs_LoadImage); 
 
   // Clean up 
   codecs.Dispose(); 
   image.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

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.