Leadtools.Codecs Namespace > RasterCodecs Class : LoadPage Event |
public event EventHandler<CodecsPageEventArgs> LoadPage
'Declaration Public Event LoadPage As EventHandler(Of CodecsPageEventArgs)
'Usage Dim instance As RasterCodecs Dim handler As EventHandler(Of CodecsPageEventArgs) AddHandler instance.LoadPage, handler
public event EventHandler<CodecsPageEventArgs> LoadPage
add_LoadPage(function(sender, e)) remove_LoadPage(function(sender, e))
public: event EventHandler<CodecsPageEventArgs^>^ LoadPage
The event handler receives an argument of type CodecsPageEventArgs containing data related to this event. The following CodecsPageEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Command | Gets or sets a value indicating how the load or save process should continue. |
FileName | Gets the name of the file being loaded or saved. |
Image | Gets the object being loaded from the image file page or the image that is being saved. |
Page | Gets the page number of the image being loaded or saved. |
PageCount | Gets the number of pages being loaded or saved. |
State | Gets the state of the load or save process. |
Stream | Gets the stream used by the load process. |
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() Dim codecs As RasterCodecs = New RasterCodecs() AddHandler codecs.LoadPage, AddressOf Codecs_LoadSavePage AddHandler codecs.SavePage, AddressOf Codecs_LoadSavePage Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")) codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "loadsave.jpg"), RasterImageFormat.Jpeg, image.BitsPerPixel) RemoveHandler codecs.LoadPage, AddressOf Codecs_LoadSavePage RemoveHandler codecs.SavePage, AddressOf Codecs_LoadSavePage ' Clean up codecs.Dispose() image.Dispose() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
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 codecs = new RasterCodecs(); codecs.LoadPage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); codecs.SavePage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")); codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "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(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
function Codecs_LoadSavePage(e) { if (e.state == Leadtools.Codecs.CodecsPageEventState.after) console.info("The image has been processed"); else console.info("The image has not processed yet"); if (e.page > 5) e.command = Leadtools.Codecs.CodecsPageEventCommand.stop; if (e.image != null) console.info("The Image width and height is: ", e.image.width, " , ", e.image.height); console.info("Page Index is: ", e.page); console.info("Page Count is: ", e.pageCount); } RasterCodecsExamples.prototype.LoadPageExample = function () { Tools.SetLicense(); with (Leadtools) { with (Leadtools.Codecs) { var codecs = new RasterCodecs(); var image; Leadtools.RasterSupport.initialize(); codecs.eventsDispatchMode = Leadtools.LeadEventsDispatchMode.useCoreDispatcher; codecs.addEventListener("loadpage", Codecs_LoadSavePage); codecs.addEventListener("savepage", Codecs_LoadSavePage); var srcFileName = "Assets\\Image1.cmp"; var destFileName = "loadsave.jpg"; var image; console.info("Loading..."); return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) { return codecs.loadAsync(LeadStreamFactory.create(loadFile)) }) .then(function (img) { image = img; console.info("Saving..."); return Tools.AppLocalFolder().createFileAsync(destFileName) }) .then(function (saveFile) { return codecs.saveAsync(image, LeadStreamFactory.create(saveFile), RasterImageFormat.jpeg, image.bitsPerPixel) }) .then(function () { codecs.removeEventListener("loadPage", Codecs_LoadSavePage); codecs.removeEventListener("savePage", Codecs_LoadSavePage); // Clean up codecs.close(); image.close(); }); } } }
private void Codecs_LoadSavePage(object sender, CodecsPageEventArgs e) { if (e.State == CodecsPageEventState.After) Debug.WriteLine("The image has been processed"); else Debug.WriteLine("The image has not processed yet"); if (e.Page > 5) e.Command = CodecsPageEventCommand.Stop; if (e.Image != null) Debug.WriteLine("The Image width and height is: {0},{1}", e.Image.Width, e.Image.Height); Debug.WriteLine("Page Index is: {0}", e.Page); Debug.WriteLine("Page Count is: {0}", e.PageCount); } [TestMethod] public async Task LoadPageExample() { RasterCodecs codecs = new RasterCodecs(); codecs.LoadPage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); codecs.SavePage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); string srcFileName = @"Assets\Image1.cmp"; string destFileName = @"loadsave.jpg"; Debug.WriteLine("Loading..."); StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)); Debug.WriteLine("Saving..."); StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName); await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), RasterImageFormat.Jpeg, image.BitsPerPixel); codecs.LoadPage -= new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); codecs.SavePage -= new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); // Clean up codecs.Dispose(); image.Dispose(); }
private void Codecs_LoadSavePage(object sender, CodecsPageEventArgs e) { if(e.State == CodecsPageEventState.After) Debug.WriteLine("The image has been processed"); else Debug.WriteLine("The image has not processed yet"); if(e.Page > 5) e.Command = CodecsPageEventCommand.Stop; Debug.WriteLine("File name is: {0}", e.FileName); if(e.Image != null) Debug.WriteLine("The Image width and height is: {0},{1}", e.Image.Width, e.Image.Height); Debug.WriteLine("Page Index is: {0}", e.Page); Debug.WriteLine("Page Count is: {0}", e.PageCount); } public void LoadPageExample(Stream inStream, Stream outStream) { RasterCodecs codecs = new RasterCodecs(); codecs.LoadPage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); codecs.SavePage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); RasterImage image = codecs.Load(inStream); codecs.Save(image, outStream, RasterImageFormat.Jpeg, image.BitsPerPixel); codecs.LoadPage -= new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); codecs.SavePage -= new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); // Clean up image.Dispose(); }
Private Sub Codecs_LoadSavePage(ByVal sender As Object, ByVal e As CodecsPageEventArgs) If e.State = CodecsPageEventState.After Then Debug.WriteLine("The image has been processed") Else Debug.WriteLine("The image has not processed yet") End If If e.Page > 5 Then e.Command = CodecsPageEventCommand.Stop End If Debug.WriteLine("File name is: {0}", e.FileName) If Not e.Image Is Nothing Then Debug.WriteLine("The Image width and height is: {0},{1}", e.Image.Width, e.Image.Height) End If Debug.WriteLine("Page Index is: {0}", e.Page) Debug.WriteLine("Page Count is: {0}", e.PageCount) End Sub Public Sub LoadPageExample(ByVal inStream As Stream, ByVal outStream As Stream) Dim codecs As RasterCodecs = New RasterCodecs() AddHandler codecs.LoadPage, AddressOf Codecs_LoadSavePage AddHandler codecs.SavePage, AddressOf Codecs_LoadSavePage Dim image As RasterImage = codecs.Load(inStream) codecs.Save(image, outStream, RasterImageFormat.Jpeg, image.BitsPerPixel) RemoveHandler codecs.LoadPage, AddressOf Codecs_LoadSavePage RemoveHandler codecs.SavePage, AddressOf Codecs_LoadSavePage ' Clean up image.Dispose() End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2