Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.17
LoadImage Event
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class : LoadImage Event




Occurs during the file load process to provide functionality for manually handling the output image data or monitoring a progress status.

Syntax

Visual Basic (Declaration) 
Public Event LoadImage() As EventHandler(Of CodecsLoadImageEventArgs)
Visual Basic (Usage)Copy Code
Dim instance As RasterCodecs
Dim handler As EventHandler(Of CodecsLoadImageEventArgs)
 
AddHandler instance.LoadImage, handler
C# 
public event EventHandler<CodecsLoadImageEventArgs> LoadImage()
Managed Extensions for C++ 
public: __event EventHandler<CodecsLoadImageEventArgs>* LoadImage();
C++/CLI 
public:
event EventHandler<CodecsLoadImageEventArgs>^ LoadImage();

Example

Visual BasicCopy Code
RasterCodecs.LoadImage
      Private Sub Codecs_LoadImage(ByVal sender As Object, ByVal e As CodecsLoadImageEventArgs)
         e.Cancel = True
         If e.Buffer <> IntPtr.Zero Then
            ' get all properties for the CodecsLoadImageEventArgs class.
            Console.WriteLine("File name is: {0}", e.FileName)
            Console.WriteLine("The Image width and height is: {0},{1}", e.Image.Width, e.Image.Height)
            Console.WriteLine("The Length of the buffer is: {0}", e.Length)
            Console.WriteLine("The current row in the first line of the buffer is: {0}", e.Row)

            If e.OffsetValid Then
               Console.WriteLine("Offset count is : {0}", e.OffsetCount)
               Console.WriteLine("Offset value is : {0}", e.Offset)
            End If

            If e.TileValid Then
               Dim rect As Rectangle = e.Tile
               Console.WriteLine("Tile Dimension ({0},{1},{2},{3)}", rect.X, rect.Y, rect.Width, rect.Height)
            End If

            Console.WriteLine("Page Index is: {0}", e.Page)
            Console.WriteLine("Page Count is: {0}", e.PageCount)
            Console.WriteLine("Image Page Index is: {0}", e.ImagePage)
            Console.WriteLine("Flags = {0}", e.Flags)

            Dim loadStream As System.IO.Stream = e.Stream
            Dim info As CodecsImageInfo = e.Info
            e.Cancel = False
         End If
      End Sub


      Public Sub LoadImageExample()
         RasterCodecs.Startup()
         Dim codecs As RasterCodecs = New RasterCodecs()

         AddHandler codecs.LoadImage, AddressOf Codecs_LoadImage
         Dim image As RasterImage = codecs.Load("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp")
         RemoveHandler codecs.LoadImage, AddressOf Codecs_LoadImage

         ' Clean up
         codecs.Dispose()
         image.Dispose()
         RasterCodecs.Shutdown()
      End Sub
C#Copy Code
RasterCodecs.LoadImage 
      private void Codecs_LoadImage(object sender, CodecsLoadImageEventArgs e) 
      { 
         e.Cancel = true; 
         if(e.Buffer != IntPtr.Zero) 
         { 
            // get all properties for the CodecsLoadImageEventArgs class. 
            Console.WriteLine("File name is: {0}", e.FileName); 
            Console.WriteLine("The Image width and height is: {0},{1}", e.Image.Width, e.Image.Height); 
            Console.WriteLine("The Length of the buffer is: {0}", e.Length); 
            Console.WriteLine("The current row in the first line of the buffer is: {0}", e.Row); 
 
            if(e.OffsetValid) 
            { 
               Console.WriteLine("Offset count is : {0}", e.OffsetCount); 
               Console.WriteLine("Offset value is : {0}", e.Offset); 
            } 
 
            if(e.TileValid) 
            { 
               Rectangle rect = e.Tile; 
               Console.WriteLine("Tile Dimension ({0},{1},{2},{3)}", rect.X, rect.Y, rect.Width, rect.Height); 
            } 
 
            Console.WriteLine("Page Index is: {0}", e.Page); 
            Console.WriteLine("Page Count is: {0}", e.PageCount); 
            Console.WriteLine("Image Page Index is: {0}", e.ImagePage); 
            Console.WriteLine("Flags = {0}", e.Flags); 
 
            System.IO.Stream loadStream = e.Stream; 
            CodecsImageInfo info = e.Info; 
            e.Cancel = false; 
         } 
      } 
 
      public void LoadImageExample() 
      { 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
 
         codecs.LoadImage += new EventHandler<CodecsLoadImageEventArgs>(Codecs_LoadImage); 
         RasterImage image = codecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp"); 
         codecs.LoadImage -= new EventHandler<CodecsLoadImageEventArgs>(Codecs_LoadImage); 
 
         // Clean up 
         codecs.Dispose(); 
         image.Dispose(); 
         RasterCodecs.Shutdown(); 
      }

Remarks

This event will fire during loading images with the Load methods. You can use this event to get information about the image being loaded, manually handle the image scanline data or provide a progress status as well as to abort the load operation.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also