SavePage Event (original) (raw)

Summary

Occurs once for each page saved to an image file.

Syntax

synchronized public void addSavePageListener(CodecsSavePageListener listener) synchronized public void removeSavePageListener(CodecsSavePageListener listener)

public: event EventHandler<CodecsPageEventArgs^>^ SavePage

def SavePage(sender,e): # sender: RasterCodecs e: CodecsPageEventArgs 

Event Data

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 A value indicating how the load or save process should continue.

Example

This example will use the SavePage event to skip a certain page when saving a multipage file

using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Color; using Leadtools.Svg; public void SavePageExample() { RasterCodecs codecs = new RasterCodecs(); codecs.Options.Load.AllPages = true; string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Eye.gif"); string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Eye_SavePage.gif"); // Load all the pages in the file RasterImage image = codecs.Load(srcFileName); Debug.WriteLine("Original image has {0} pages", image.PageCount); // Add a handler to the SavePage event codecs.SavePage += new EventHandler<CodecsPageEventArgs>(codecs_SavePage); // Save all the pages of this file codecs.Save(image, destFileName, RasterImageFormat.Gif, 0, 1, image.PageCount, 1, CodecsSavePageMode.Overwrite); codecs.SavePage -= new EventHandler<CodecsPageEventArgs>(codecs_SavePage); // Check if we saved all pages but 1 CodecsImageInfo info = codecs.GetInformation(destFileName, true); Debug.WriteLine("Info reports {0} pages saved to the file", info.TotalPages); Debug.Assert(info.TotalPages == (image.PageCount - 1)); image.Dispose(); // Clean up codecs.Dispose(); } void codecs_SavePage(object sender, CodecsPageEventArgs e) { if (e.State == CodecsPageEventState.Before && e.Page == 1) { // Before saving the first page, show the save operation information Debug.WriteLine( "Saving {0} pages to {1}. Image size is {2} by {3}", e.PageCount - 1, e.FileName, e.Image.Width, e.Image.Height); } Debug.WriteLine("{0} saving page {1}:{2}", e.State == CodecsPageEventState.After ? "After" : "Before", e.Page, e.PageCount); // If this is the 2nd page, ignore it if (e.Page == 2 && e.State == CodecsPageEventState.Before) { e.Command = CodecsPageEventCommand.Skip; Debug.WriteLine("--- Skipping this page, there should be no 'After' for this one"); } } static class LEAD_VARS { public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; }

Leadtools.Codecs Assembly

CompactFile(Stream,Stream,int,int,bool,int,int,bool,int,CodecsSavePageMode,bool,bool) Method

CompactFile(Stream,Stream,int,int,bool,long,int,bool,long,CodecsSavePageMode,bool,bool,bool) Method

CompactFile(string,string,int,int,bool,int,int,bool,int,CodecsSavePageMode,bool,bool) Method

CompactFile(string,string,int,int,bool,long,int,bool,long,CodecsSavePageMode,bool,bool,bool) Method

StartCompress(int,int,int,RasterByteOrder,RasterViewPerspective,int,byte[],int,int,CodecsCompression,CodecsCompressDataCallback) Method