Start optimized page loading for the same source image file or document in this RasterCodecs object.
public void StartOptimizedLoad()
public:
void StartOptimizedLoad()
def StartOptimizedLoad(self):
Optimizes getting information, loading or conversion from a file with multiple pages. Call this method before a loop that involves loading from the same source file or stream. Call StopOptimizedLoad when finished.
This method should be used only if the source file is the same and its contents is unchanged.
This method can greatly speed up a loop involving multiple GetInformation, GetInformationAsync, Load, LoadAsync, or Convert) methods for certain formats (for example, TXT, DOCX, and PDF files).
For more information, refer to Using the OptimizedLoad Functions to Speed Loading Large Files.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
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, @"Forms\Unstructured", "W4.pdf");
// indicate the start of a loop from the same source file
codecs.StartOptimizedLoad();
for (int i = 1; i < 5; 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);
}
}
// Indicate that I finished using the same source file.
codecs.StopOptimizedLoad();
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
import java.io.*;
import java.net.*;
import java.nio.file.Paths;
import java.util.*;
import java.time.Instant;
import java.time.Duration;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.codecs.*;
import leadtools.codecs.RasterCodecs.FeedCallbackThunk;
import leadtools.drawing.internal.*;
import leadtools.imageprocessing.*;
import leadtools.imageprocessing.color.ChangeIntensityCommand;
import leadtools.svg.*;
public void optimizedLoadExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
RasterCodecs codecs = new RasterCodecs();
// The speed improvement is most noticeable in source files with many pages
String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "Forms\\Unstructured\\PortfolioStatement.pdf");
// indicate the start of a loop from the same source file
codecs.startOptimizedLoad();
for (int i = 1; i < 5; i++) {
RasterImage image = codecs.load(srcFileName, i);
String destFileName = combine(LEAD_VARS_IMAGES_DIR, "out_" + i + ".jpg");
// Save as the destination image
codecs.save(image, destFileName, RasterImageFormat.JPEG_411, 24);
assertTrue("The file is saved to " + destFileName, (new File(destFileName)).exists());
System.out.println("The file is saved to " + destFileName);
}
// Indicate that I finished using the same source file.
codecs.stopOptimizedLoad();
codecs.dispose();
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document