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




Occurs once for each page loaded from an image file.

Syntax

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

Example

Visual BasicCopy Code
RasterCodecs.LoadPage
      Private Sub Codecs_LoadSavePage(ByVal sender As Object, ByVal e As CodecsPageEventArgs)
         If e.State = CodecsPageEventState.After Then
            Console.WriteLine("The image has been processed")
         Else
            Console.WriteLine("The image has not processed yet")
         End If
         If e.Page > 5 Then
            e.Command = CodecsPageEventCommand.Stop
         End If

         Console.WriteLine("File name is: {0}", e.FileName)
         If Not e.Image Is Nothing Then
            Console.WriteLine("The Image width and height is: {0},{1}", e.Image.Width, e.Image.Height)
         End If
         Console.WriteLine("Page Index is: {0}", e.Page)
         Console.WriteLine("Page Count is: {0}", e.PageCount)
      End Sub


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

         AddHandler codecs.LoadPage, AddressOf Codecs_LoadSavePage
         AddHandler codecs.SavePage, AddressOf Codecs_LoadSavePage

         Dim image As RasterImage = codecs.Load("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp")
         codecs.Save(image, "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\loadsave.jpg", RasterImageFormat.Jpeg, image.BitsPerPixel)

         RemoveHandler codecs.LoadPage, AddressOf Codecs_LoadSavePage
         RemoveHandler codecs.SavePage, AddressOf Codecs_LoadSavePage

         ' Clean up
         codecs.Dispose()
         image.Dispose()
         RasterCodecs.Shutdown()
      End Sub
C#Copy Code
RasterCodecs.LoadPage 
      private void Codecs_LoadSavePage(object sender, CodecsPageEventArgs e) 
      { 
         if(e.State == CodecsPageEventState.After) 
            Console.WriteLine("The image has been processed"); 
         else 
            Console.WriteLine("The image has not processed yet"); 
         if(e.Page > 5) 
            e.Command = CodecsPageEventCommand.Stop; 
 
         Console.WriteLine("File name is: {0}", e.FileName); 
         if(e.Image != null) 
            Console.WriteLine("The Image width and height is: {0},{1}", e.Image.Width, e.Image.Height); 
         Console.WriteLine("Page Index is: {0}", e.Page); 
         Console.WriteLine("Page Count is: {0}", e.PageCount); 
      } 
 
      public void LoadPageExample() 
      { 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
 
         codecs.LoadPage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); 
         codecs.SavePage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); 
 
         RasterImage image = codecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp"); 
         codecs.Save(image, @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\loadsave.jpg", RasterImageFormat.Jpeg, image.BitsPerPixel); 
 
         codecs.LoadPage -= new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); 
         codecs.SavePage -= new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); 
 
         // Clean up 
         codecs.Dispose(); 
         image.Dispose(); 
         RasterCodecs.Shutdown(); 
      }

Remarks

This event will fire once for each page loaded with any of the Load methods. You can use this event to get information about the image pages being loaded or to skip loading certain pages.

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