Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
RasterDefaults Class
See Also  Members   Example 
Leadtools Namespace : RasterDefaults Class



Specifies the default extra values used when creating RasterImage objects.

Object Model


Syntax

Visual Basic (Declaration) 
Public MustInherit NotInheritable Class RasterDefaults 
Visual Basic (Usage)Copy Code
Dim instance As RasterDefaults
C# 
public static class RasterDefaults 
C++/CLI 
public ref class RasterDefaults abstract sealed 

Example

Visual BasicCopy Code
Public Sub RasterDefaultsExample()
 ShowValues()

 ' Create a raster image with current DPI
 Dim image1 As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, 100, 100, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, IntPtr.Zero, 0)
 Console.WriteLine("Resolution of created image is {0} by {1} DPI", image1.XResolution, image1.YResolution)

 ' Change the resolution
 Dim xOldResolution As Integer = RasterDefaults.XResolution
 Dim yOldResolution As Integer = RasterDefaults.YResolution
 Dim xNewResolution As Integer = 196
 Dim yNewResolution As Integer = 196
 RasterDefaults.XResolution = xNewResolution
 RasterDefaults.YResolution = yNewResolution
 ShowValues()

 ' Create another raster image
 ' Create a raster image with current DPI
 Dim image2 As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, 100, 100, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, IntPtr.Zero, 0)
 Console.WriteLine("Resolution of created image is {0} by {1} DPI", image2.XResolution, image2.YResolution)
 Debug.Assert(image2.XResolution = xNewResolution)
 Debug.Assert(image2.YResolution = yNewResolution)

 ' Reset old values
 RasterDefaults.XResolution = xOldResolution
 RasterDefaults.YResolution = yOldResolution

 image1.Dispose()
 image2.Dispose()
      End Sub

      Private Sub ShowValues()
 Console.WriteLine("Current defaults:")
 Console.WriteLine("XResolution: {0}", RasterDefaults.XResolution)
 Console.WriteLine("YResolution: {0}", RasterDefaults.YResolution)
 Console.WriteLine("DitheringMethod: {0}", RasterDefaults.DitheringMethod)
 Console.WriteLine("MemoryFlags: {0}", RasterDefaults.MemoryFlags)

 Dim threshold As RasterMemoryThreshold = RasterDefaults.MemoryThreshold
 Console.WriteLine("MemoryThreshold.TiledThreshold: {0}", threshold.TiledThreshold)
 Console.WriteLine("MemoryThreshold.MaximumConventionalSize: {0}", threshold.MaximumConventionalSize)
 Console.WriteLine("MemoryThreshold.TileSize: {0}", threshold.TileSize)
 Console.WriteLine("MemoryThreshold.ConventionalTiles: {0}", threshold.ConventionalTiles)
 Console.WriteLine("MemoryThreshold.ConventionalBuffers: {0}", threshold.ConventionalBuffers)

 Console.WriteLine("TemporaryDirectory: {0}", RasterDefaults.TemporaryDirectory)
      End Sub
C#Copy Code
public void RasterDefaultsExample() 

   ShowValues(); 
 
   // Create a raster image with current DPI 
   RasterImage image1 = new RasterImage( 
      RasterMemoryFlags.Conventional, 
      100, 
      100, 
      24, 
      RasterByteOrder.Bgr, 
      RasterViewPerspective.TopLeft, 
      null, 
      IntPtr.Zero, 
      0); 
   Console.WriteLine("Resolution of created image is {0} by {1} DPI", image1.XResolution, image1.YResolution); 
 
   // Change the resolution 
   int xOldResolution = RasterDefaults.XResolution; 
   int yOldResolution = RasterDefaults.YResolution; 
   int xNewResolution = 196; 
   int yNewResolution = 196; 
   RasterDefaults.XResolution = xNewResolution; 
   RasterDefaults.YResolution = yNewResolution; 
   ShowValues(); 
 
   // Create another raster image 
   // Create a raster image with current DPI 
   RasterImage image2 = new RasterImage( 
      RasterMemoryFlags.Conventional, 
      100, 
      100, 
      24, 
      RasterByteOrder.Bgr, 
      RasterViewPerspective.TopLeft, 
      null, 
      IntPtr.Zero, 
      0); 
   Console.WriteLine("Resolution of created image is {0} by {1} DPI", image2.XResolution, image2.YResolution); 
   Debug.Assert(image2.XResolution == xNewResolution); 
   Debug.Assert(image2.YResolution == yNewResolution); 
 
   // Reset old values 
   RasterDefaults.XResolution = xOldResolution; 
   RasterDefaults.YResolution = yOldResolution; 
 
   image1.Dispose(); 
   image2.Dispose(); 

 
void ShowValues() 

   Console.WriteLine("Current defaults:"); 
   Console.WriteLine("XResolution: {0}", RasterDefaults.XResolution); 
   Console.WriteLine("YResolution: {0}", RasterDefaults.YResolution); 
   Console.WriteLine("DitheringMethod: {0}", RasterDefaults.DitheringMethod); 
   Console.WriteLine("MemoryFlags: {0}", RasterDefaults.MemoryFlags); 
 
   RasterMemoryThreshold threshold = RasterDefaults.MemoryThreshold; 
   Console.WriteLine("MemoryThreshold.TiledThreshold: {0}", threshold.TiledThreshold); 
   Console.WriteLine("MemoryThreshold.MaximumConventionalSize: {0}", threshold.MaximumConventionalSize); 
   Console.WriteLine("MemoryThreshold.TileSize: {0}", threshold.TileSize); 
   Console.WriteLine("MemoryThreshold.ConventionalTiles: {0}", threshold.ConventionalTiles); 
   Console.WriteLine("MemoryThreshold.ConventionalBuffers: {0}", threshold.ConventionalBuffers); 
 
   Console.WriteLine("TemporaryDirectory: {0}", RasterDefaults.TemporaryDirectory); 
}

Remarks

You can use the RasterDefaults class to specify extra attributes used when creating a RasterImage object

For example, you can use XResolution and YResolution to set the physical resolution (DPI) of all the RasterImage objects creates afterwards.

You can use DitheringMethod to specifies the default dithering method to use when converting an image from 64, 48, 32, 24, or 16 bits per pixel to 8 bits per pixel or fewer.

MemoryFlags and MemoryThreshold controls how newly created images use the system memory. The TemporaryDirectory controls where disk-based images are stored.

Inheritance Hierarchy

System.Object
   Leadtools.RasterDefaults

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also