Some multipage file formats (including DICOM, PDF, JP2, among others), become quite slow to load or convert when they have a lot of pages. That is because to get to page N you sometimes have to go through pages 1, 2, ... N-1 before you get to page N. For such formats, very often loading page N becomes slower and slower as N increases.
LEADTOOLS provides a mechanism for speeding up the loading or conversion of such files.
To use this mechanism, perform something like the following steps:
public void OptimizedLoadExample()
using (RasterCodecs codecs = new RasterCodecs())
// The speed improvement is most noticeable in source files with many pages
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "MultiPage.pdf");
// Start a loop from the same source file
for (int i = 1; i < 10; i++)
using (RasterImage image = codecs.Load(srcFileName, i))
string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "out_" + i.ToString() + ".jpg");
// Save as the destination image
codecs.Save(image, destFileName, RasterImageFormat.Jpeg411, 24);
// Finish using the same source file.
The above example uses filter data to convert all of the pages of a PDF file. For PDF files, the speed improvement will be noticeable when large files (1000 pages or more) are converted. For other file formats, the speed improvement can be significant even with fewer pages (as few as 10 pages). TIFF/BigTIFF files use a simpler mechanism (the IFD, or file offset of each page). For more information about using the IFD, refer to Loading and Saving Large TIFF/BigTIFF Files.
Medical Web Viewer .NET