DotImage Knowledgebase

Home : Use Many Framed Images Efficiently
Q10257 - HOWTO: Use Many Framed Images Efficiently

When opening many separate AtalaImages to process and save into another file, it is generally best to use the FileSystemImageSource object. It efficiently loads individual frames and save out on a single active stream. It also tries to keep as little additional information in physical memory as possible. In most situations this will result in much less physical memory usage. Here is an example of opening two image files to save to a single Pdf:

C#

private void MergeAndConvertToPdf(string FirstFile,string SecondFile, string OutFilePath)

{

    string[] s = new string[2];

    s[0] = FirstFile;

    s[1] = SecondFile;

    FileSystemImageSource fsis = new FileSystemImageSource(s,true);

//true does all frames in both files

    PdfEncoder encoder = new PdfEncoder();

    using(FileStream OutStream = new FileStream(OutFilePath, FileMode.OpenOrCreate))

    {

    encoder.Save(OutStream,fsis,null);

    }

}

 

VB.NET

Private Sub MergeAndConvertToPdf(ByVal FirstFile As String, ByVal SecondFile As String, ByVal OutFilePath As String)

    Dim s As String() = New String(1) {}

    s(0) = FirstFile

    s(1) = SecondFile

    Dim fsis As New FileSystemImageSource(s, True)

    'True does all frames in both files

    Dim encoder As New PdfEncoder()

    Using OutStream As New FileStream(OutFilePath, FileMode.OpenOrCreate)

        encoder.Save(OutStream, fsis, Nothing)

    End Using

End Sub

 

If additional processing needs to be done on images being controlled by a FileSystemImageSource, this article explains how to overload the FileSystemImageSource to have it process each frame individually:

http://www.atalasoft.com/KB/article.aspx?id=10193

 

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2013. InstantASP Ltd. All Rights Reserved

preload preload preload