←Select platform

GlobalMemoryThresholds Structure

Summary
Holds conventional memory restrictions used when allocating new RasterImage objects.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public struct GlobalMemoryThresholds 
@interface GlobalMemoryThresholds : NSObject 
public class GlobalMemoryThresholds 
public: struct GlobalMemoryThresholds 
class GlobalMemoryThresholds: 
Remarks

Use RasterDefaults.GetGlobalMemoryThresholds and RasterDefaults.SetGlobalMemoryThresholds to get or set the conventional memory restrictions used when allocating new RasterImage objects.

GlobalMemoryThresholds contains the following members:

Member Description
MaximumConventionalMemory Maximum size of continuous conventional memory in bytes to use when creating a RasterImage object.
Example
C#
using Leadtools; 
using Leadtools.Codecs; 
 
 
public static void MaximumConventionalMemoryTest() 
{ 
	Console.WriteLine("maximumConventionalMemoryTest"); 
	string imageFileName = @"C:\LEADTOOLS22\Resources\Images\Leadtools.pdf"; 
 
	long size = 0; 
 
	using (var rasterCodecs = new RasterCodecs()) 
	{ 
		using (var rasterImage = rasterCodecs.Load(imageFileName, 1)) 
		{ 
			Console.WriteLine("loaded, size:{0} Conventional:{1} Disk:{2}", 
			   rasterImage.DataSize, rasterImage.IsConventionalMemory, rasterImage.IsDiskMemory); 
			Debug.Assert(rasterImage.IsConventionalMemory); 
			Debug.Assert(!rasterImage.IsDiskMemory); 
 
			size = rasterImage.DataSize; 
		} 
 
		// Set maximum conventional size to half of the bitmap's and re-check. Should be disk 
		GlobalMemoryThresholds thresholds = RasterDefaults.GetGlobalMemoryThresholds(); 
		Console.WriteLine("Original GlobalMemoryThresholds.MaximumConventionalMemory = {0}", thresholds.MaximumConventionalMemory); 
		thresholds.MaximumConventionalMemory = size / 2; 
		RasterDefaults.SetGlobalMemoryThresholds(thresholds); 
		thresholds = RasterDefaults.GetGlobalMemoryThresholds(); 
		Console.WriteLine("New      GlobalMemoryThresholds.MaximumConventionalMemory = {0}", thresholds.MaximumConventionalMemory); 
 
		using (var rasterImage = rasterCodecs.Load(imageFileName, 1)) 
		{ 
			Console.WriteLine("loaded, size:{0} Conventional:{1} Disk:{2}", 
				  rasterImage.DataSize, rasterImage.IsConventionalMemory, rasterImage.IsDiskMemory); 
			Debug.Assert(!rasterImage.IsConventionalMemory); 
			Debug.Assert(rasterImage.IsDiskMemory); 
		} 
 
		// Now set to -1 and try to create a 20 by 20 at 32-BPP inch bitmap, should be disk 
		// Reset 
		RasterDefaults.SetGlobalMemoryThresholds(GlobalMemoryThresholds.Default); 
		thresholds = RasterDefaults.GetGlobalMemoryThresholds(); 
		Console.WriteLine("Original GlobalMemoryThresholds.MaximumConventionalMemory = {0}", thresholds.MaximumConventionalMemory); 
		thresholds.MaximumConventionalMemory = -1; 
		RasterDefaults.SetGlobalMemoryThresholds(thresholds); 
		thresholds = RasterDefaults.GetGlobalMemoryThresholds(); 
		Console.WriteLine("New      GlobalMemoryThresholds.MaximumConventionalMemory = {0}", thresholds.MaximumConventionalMemory); 
 
		using (var rasterImage = new RasterImage( 
		   RasterMemoryFlags.Conventional, 
		   20 * 300, 
		   20 * 300, 
		   32, 
		   RasterByteOrder.Bgr, 
		   RasterViewPerspective.TopLeft, 
		   null, 
		   null, 
		   0)) 
		{ 
			Console.WriteLine("created, size:{0} Conventional:{1} Disk:{2}", 
				  rasterImage.DataSize, rasterImage.IsConventionalMemory, rasterImage.IsDiskMemory); 
			Debug.Assert(!rasterImage.IsConventionalMemory); 
			Debug.Assert(rasterImage.IsDiskMemory); 
		} 
 
		// finally create 8.5 by 11 at 300 DPI, should be conv 
		using (var rasterImage = new RasterImage( 
		   RasterMemoryFlags.Conventional, 
		   (int)(8.5 * 300), 
		   11 * 300, 
		   32, 
		   RasterByteOrder.Bgr, 
		   RasterViewPerspective.TopLeft, 
		   null, 
		   null, 
		   0)) 
		{ 
			Console.WriteLine("created, size:{0} Conventional:{1} Disk:{2}", 
					 rasterImage.DataSize, rasterImage.IsConventionalMemory, rasterImage.IsDiskMemory); 
			Debug.Assert(rasterImage.IsConventionalMemory); 
			Debug.Assert(!rasterImage.IsDiskMemory); 
		} 
	} 
 
	// Reset 
	RasterDefaults.SetGlobalMemoryThresholds(GlobalMemoryThresholds.Default); 
} 
Requirements

Target Platforms

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.