Enumeration that indicates whether the temp files are on disk, in memory or a combination of disk and memory.
public enum LeadTempFileMode
typedef NS_ENUM(NSInteger, LTLEADTempFileMode) {
LTLEADTempFileModeAuto,
LTLEADTempFileModeDisk,
LTLEADTempFileModeDiskAndMemory,
LTLEADTempFileModeMemory
};
public final class LeadTempFileMode
extends java.lang.Enum<LeadTempFileMode>
public:
enum class LeadTempFileMode sealed
class LeadTempFileMode(Enum):
Auto = 0
Disk = 1
DiskAndMemory = 2
Memory = 3
Value | Member | Description |
---|---|---|
0 | Auto | Lets LEADTOOLS pick the default mode (behavior might change from one version to another). Currently, it is the same as DiskAndMemory |
1 | Disk | Disk only, does not use memory to back up temp files. |
2 | DiskAndMemory | Uses Memory for small temp files, but disk for large temp files. |
3 | Memory | Disables disk, all temp files should be created in memory. Some features might fail with if they require temporary files on disk. The failure might be an out of memory errors or a RasterException with code set to RasterExceptionCode.TempFileDiskDisabled. |
Refer to RasterDefaults.TempFileMode for more information.
using Leadtools;
using Leadtools.Codecs;
public static void RasterDefaults_TempFileMode_Example()
{
// Store the default value
LeadTempFileMode defaultTempFileMode = RasterDefaults.TempFileMode;
GlobalMemoryThresholds defaultGlobalMemoryThreshold = RasterDefaults.GetGlobalMemoryThresholds();
// Set to auto
Console.WriteLine("RasterDefaults.TempFileMode is Auto");
RasterDefaults.TempFileMode = LeadTempFileMode.Auto;
// Allocating an image should work, normal conventional
using (var image = RasterImage.Create(1024, 1024, 32, 300, RasterColor.FromKnownColor(RasterKnownColor.White)))
{
Console.WriteLine("default options:");
Console.WriteLine(" image.IsConventionalMemory:" + image.IsConventionalMemory);
Console.WriteLine(" image.IsDiskMemory:" + image.IsDiskMemory);
Console.WriteLine(" image.IsTiled:" + image.IsTiled);
Debug.Assert(image.IsConventionalMemory);
Debug.Assert(!image.IsDiskMemory);
Debug.Assert(!image.IsTiled);
}
Console.WriteLine("MaximumConventionalMemory is set to low");
// Change the default maximum memory threshold to something small (1MB)
GlobalMemoryThresholds globalMemoryThreshold = RasterDefaults.GetGlobalMemoryThresholds();
globalMemoryThreshold.MaximumConventionalMemory = 1 * 1024 * 1024;
RasterDefaults.SetGlobalMemoryThresholds(globalMemoryThreshold);
// Now, the image should be of type disk or tiled
using (var image = RasterImage.Create(1024, 1024, 32, 300, RasterColor.FromKnownColor(RasterKnownColor.White)))
{
Console.WriteLine("low global memory threshold:");
Console.WriteLine(" image.IsConventionalMemory:" + image.IsConventionalMemory);
Console.WriteLine(" image.IsDiskMemory:" + image.IsDiskMemory);
Console.WriteLine(" image.IsTiled:" + image.IsTiled);
Debug.Assert(!image.IsConventionalMemory);
Debug.Assert(image.IsDiskMemory || image.IsTiled);
}
// Disable disk for temp files
Console.WriteLine("RasterDefaults.TempFileMode is Memory");
RasterDefaults.TempFileMode = LeadTempFileMode.Memory;
// Now it should go back to conventional
using (var image = RasterImage.Create(1024, 1024, 32, 300, RasterColor.FromKnownColor(RasterKnownColor.White)))
{
Console.WriteLine("low global memory threshold:");
Console.WriteLine(" image.IsConventionalMemory:" + image.IsConventionalMemory);
Console.WriteLine(" image.IsDiskMemory:" + image.IsDiskMemory);
Console.WriteLine(" image.IsTiled:" + image.IsTiled);
Debug.Assert(image.IsConventionalMemory);
Debug.Assert(!image.IsDiskMemory);
Debug.Assert(!image.IsTiled);
}
// Reset
RasterDefaults.SetGlobalMemoryThresholds(defaultGlobalMemoryThreshold);
RasterDefaults.TempFileMode = defaultTempFileMode;
}
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.*;
import org.junit.Test;
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.*;
public void rasterDefaultsTempFileModeExample() {
// Store the default value
LeadTempFileMode defaultTempFileMode = RasterDefaults.getTempFileMode();
GlobalMemoryThresholds defaultGlobalMemoryThreshold = RasterDefaults.getGlobalMemoryThresholds();
// Set to auto
System.out.println("RasterDefaults.TempFileMode is Auto");
RasterDefaults.setTempFileMode(LeadTempFileMode.AUTO);
// Allocating an image should work, normal conventional
RasterImage image = RasterImage.create(1024, 1024, 32, 300, RasterColor.fromKnownColor(RasterKnownColor.WHITE));
System.out.println("default options:");
System.out.println(" image.IsConventionalMemory:" + image.isConventionalMemory());
System.out.println(" image.IsDiskMemory:" + image.isDiskMemory());
System.out.println(" image.IsTiled:" + image.isTiled());
assertTrue(image.isConventionalMemory());
assertTrue(!image.isDiskMemory());
assertTrue(!image.isTiled());
System.out.println("MaximumConventionalMemory is set to low");
// Change the default maximum memory threshold to something small (1MB)
GlobalMemoryThresholds globalMemoryThreshold = RasterDefaults.getGlobalMemoryThresholds();
globalMemoryThreshold.setMaximumConventionalMemory(1 * 1024 * 1024);
RasterDefaults.setGlobalMemoryThresholds(globalMemoryThreshold);
image.dispose();
// Now, the image should be of type disk or tiled
RasterImage image2 = RasterImage.create(1024, 1024, 32, 300, RasterColor.fromKnownColor(RasterKnownColor.WHITE));
System.out.println("low global memory threshold:");
System.out.println(" image.IsConventionalMemory:" + image2.isConventionalMemory());
System.out.println(" image.IsDiskMemory:" + image2.isDiskMemory());
System.out.println(" image.IsTiled:" + image2.isTiled());
assertTrue(!image2.isConventionalMemory());
assertTrue(image2.isDiskMemory() || image2.isTiled());
// Disable disk for temp files
System.out.println("RasterDefaults.TempFileMode is Memory");
RasterDefaults.setTempFileMode(LeadTempFileMode.MEMORY);
image2.dispose();
// Now it should go back to conventional
RasterImage image3 = RasterImage.create(1024, 1024, 32, 300, RasterColor.fromKnownColor(RasterKnownColor.WHITE));
System.out.println("low global memory threshold:");
System.out.println(" image.IsConventionalMemory:" + image3.isConventionalMemory());
System.out.println(" image.IsDiskMemory:" + image3.isDiskMemory());
System.out.println(" image.IsTiled:" + image3.isTiled());
assertTrue(image3.isConventionalMemory());
assertTrue(!image3.isDiskMemory());
assertTrue(!image3.isTiled());
// Reset
RasterDefaults.setGlobalMemoryThresholds(defaultGlobalMemoryThreshold);
RasterDefaults.setTempFileMode(defaultTempFileMode);
}
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