←Select platform

LeadTempFileMode Enumeration

Summary

Enumeration that indicates whether the temp files are on disk, in memory or a combination of disk and memory.

Syntax
C#
Objective-C
C++/CLI
Java
Python
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 
Members
ValueMemberDescription
0AutoLets LEADTOOLS pick the default mode (behavior might change from one version to another). Currently, it is the same as DiskAndMemory
1DiskDisk only, does not use memory to back up temp files.
2DiskAndMemoryUses Memory for small temp files, but disk for large temp files.
3MemoryDisables 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.
Remarks

Refer to RasterDefaults.TempFileMode for more information.

Example
C#
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; 
} 
Requirements

Target Platforms

See Also

Reference

Leadtools Namespace

Help Version 22.0.2023.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.