ImageGear .NET
Loading and Saving Pages and Documents

ImGearFileFormats Class should be used to load/save images. It offers LoadPage Method(), SavePage Method(), LoadDocument Method() and SaveDocument Method() members for these purposes. Each of these members mainly loads (saves) an image from a given .NET Stream object. ImageGear supports loading from streams having the seek ability, as well as from streams that don't have the seek ability, such as network streams.

ImageGear only supports saving to streams that have the seek ability.

The following example demonstrates how to load a single page from a local file: 

C#
Copy Code
ImGearPage igPage;
using (FileStream localFile = new FileStream("photo.jpg",FileMode.Open))
{
    igPage = ImGearFileFormats.LoadPage(localFile, 0);
}

The next example demonstrates how to load a page from a remote file:

C#
Copy Code
ImGearPage igPage;
WebRequest request = WebRequest.Create("http://www.google.com/intl/en_ALL/images/logo.gif");
using (WebResponse response = request.GetResponse())
    using (Stream stream = response.GetResponseStream())
        igPage = ImGearFileFormats.LoadPage(stream, 0);

The example below demonstrates how to stream a particular page of document into memory:

C#
Copy Code
ImGearDocument igDocument;
using (FileStream localFile = new FileStream("MULTIPAG.TIF", FileMode.Open))
{
    int pageCount = ImGearFileFormats.GetPageCount(localFile, ImGearFormats.UNKNOWN);
    igDocument = ImGearFileFormats.LoadDocument(localFile, 0, pageCount);
}
System.IO.MemoryStream memory = new MemoryStream(); 
ImGearFileFormats.SavePage(igDocument.Pages[0], memory, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.JPG); 
byte[] array = memory.ToArray();

Also refer to the following sections:

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback