Leadtools名前空間 :RasterDefaultsクラス |
public static class RasterDefaults
'Declaration
Public MustInherit NotInheritable Class RasterDefaults
'Usage
Dim instance As RasterDefaults
public sealed static class RasterDefaults
@interface LTRasterDefaults : NSObject
public class RasterDefaults
function Leadtools.RasterDefaults()
public ref class RasterDefaults abstract sealed
RasterDefaultsクラスを使用して、RasterImageオブジェクト作成時に使用する追加の属性を指定できます。
たとえば、その後作成されるすべてのRasterImageオブジェクトの物理的な解像度(DPI)を設定するために、XResolutionとYResolutionを使うことができます。
DitheringMethodを使用して、画像を64、48、32、24または16ビットから8ビット以下に変換する際に使用するデフォルトのディザリング処理メソッドを指定できます。
MemoryFlagsとMemoryThresholdは、作成されたイメージがどれくらい新しくシステムメモリーを使うかについて制御します。TemporaryDirectoryは、ディスクベースのイメージがどこで保存されるかについて制御します。
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Public Sub RasterDefaultsExample() ' Set the limit for RasterImage object allocations Dim threshold As RasterMemoryThreshold = RasterDefaults.MemoryThreshold threshold.MaximumGlobalRasterImageMemory = 20 * 1000 * 1024 RasterDefaults.MemoryThreshold = threshold 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("MaximumThreadCount: {0}", RasterDefaults.MaximumThreadCount) 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("MemoryThreshold.MaximumGlobalRasterImageMemory: {0}", threshold.MaximumGlobalRasterImageMemory) Console.WriteLine("TemporaryDirectory: {0}", RasterDefaults.TemporaryDirectory) End Sub
using Leadtools; using Leadtools.Codecs; public void RasterDefaultsExample() { // Set the limit for RasterImage object allocations RasterMemoryThreshold threshold = RasterDefaults.MemoryThreshold; threshold.MaximumGlobalRasterImageMemory = 20 * 1000 * 1024; RasterDefaults.MemoryThreshold = threshold; 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); Assert.IsTrue(image2.XResolution == xNewResolution); Assert.IsTrue(image2.YResolution == yNewResolution); // Reset old values RasterDefaults.XResolution = xOldResolution; RasterDefaults.YResolution = yOldResolution; image1.Dispose(); image2.Dispose(); } void ShowValues() { Console.WriteLine("Current defaults:"); Console.WriteLine("MaximumThreadCount: {0}", RasterDefaults.MaximumThreadCount); 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("MemoryThreshold.MaximumGlobalRasterImageMemory: {0}", threshold.MaximumGlobalRasterImageMemory); Console.WriteLine("TemporaryDirectory: {0}", RasterDefaults.TemporaryDirectory); }
function RasterDefaultsExample() { with ( Leadtools ) { Tools.SetLicense(); ShowValues(); // Create a raster image with current DPI var image1 = new RasterImage( RasterMemoryFlags.conventional, 100, 100, 24, RasterByteOrder.bgr, RasterViewPerspective.topLeft, null); console.info ("Resolution of created image is " + image1.XResolution + " by " + image1.YResolution + " DPI"); // Change the resolution var xOldResolution = RasterDefaults.xresolution; var yOldResolution = RasterDefaults.yresolution; var xNewResolution = 196; var yNewResolution = 196; RasterDefaults.xresolution = xNewResolution; RasterDefaults.yresolution = yNewResolution; ShowValues(); // Create another raster image // Create a raster image with current DPI var image2 = new RasterImage( RasterMemoryFlags.conventional, 100, 100, 24, RasterByteOrder.bgr, RasterViewPerspective.topLeft, null); console.info("Resolution of created image is " + image2.xresolution + " by " + image2.yresolution + " DPI" ); console.assert (image2.xresolution == xNewResolution, "image2.XResolution == xNewResolution"); console.assert (image2.yresolution == yNewResolution, "image2.YResolution == yNewResolution"); // Reset old values RasterDefaults.xresolution = xOldResolution; RasterDefaults.yresolution = yOldResolution; image1.close(); image2.close(); } } function ShowValues() { with ( Leadtools ) { console.info("Current defaults:"); console.info("XResolution: ", RasterDefaults.xresolution); console.info("YResolution: ", RasterDefaults.yresolution); console.info("DitheringMethod: ", RasterDefaults.ditheringMethod); console.info("MemoryFlags: ", RasterDefaults.memoryFlags); var threshold = RasterDefaults.memoryThreshold; console.info("MemoryThreshold.TiledThreshold: ", threshold.tiledThreshold); console.info("MemoryThreshold.MaximumConventionalSize: ", threshold.maximumConventionalSize); console.info("MemoryThreshold.TileSize: ", threshold.tileSize); console.info("MemoryThreshold.ConventionalTiles: ", threshold.conventionalTiles); console.info("MemoryThreshold.ConventionalBuffers: ", threshold.conventionalBuffers); console.info("TemporaryDirectory: ", RasterDefaults.temporaryDirectory); } }
using Leadtools; using Leadtools.Codecs; 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); Debug.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); Debug.WriteLine("Resolution of created image is {0} by {1} DPI", image2.XResolution, image2.YResolution); Assert.IsTrue(image2.XResolution == xNewResolution); Assert.IsTrue(image2.YResolution == yNewResolution); // Reset old values RasterDefaults.XResolution = xOldResolution; RasterDefaults.YResolution = yOldResolution; image1.Dispose(); image2.Dispose(); } void ShowValues() { Debug.WriteLine("Current defaults:"); //Debug.WriteLine("MaximumThreadCount: {0}", RasterDefaults.MaximumThreadCount); Debug.WriteLine("XResolution: {0}", RasterDefaults.XResolution); Debug.WriteLine("YResolution: {0}", RasterDefaults.YResolution); Debug.WriteLine("DitheringMethod: {0}", RasterDefaults.DitheringMethod); Debug.WriteLine("MemoryFlags: {0}", RasterDefaults.MemoryFlags); RasterMemoryThreshold threshold = RasterDefaults.MemoryThreshold; Debug.WriteLine("MemoryThreshold.TiledThreshold: {0}", threshold.TiledThreshold); Debug.WriteLine("MemoryThreshold.MaximumConventionalSize: {0}", threshold.MaximumConventionalSize); Debug.WriteLine("MemoryThreshold.TileSize: {0}", threshold.TileSize); Debug.WriteLine("MemoryThreshold.ConventionalTiles: {0}", threshold.ConventionalTiles); Debug.WriteLine("MemoryThreshold.ConventionalBuffers: {0}", threshold.ConventionalBuffers); Debug.WriteLine("TemporaryDirectory: {0}", RasterDefaults.TemporaryDirectory); }
using Leadtools; 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, null, 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, null, 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); }
Imports Leadtools 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, Nothing, 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, Nothing, 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) End Sub