←Select platform

AutoFixImageResolutionUnit Enumeration

Summary

Units to use for the page size.

Syntax
C#
Objective-C
C++/CLI
Java
Python
public enum AutoFixImageResolutionUnit 
typedef NS_ENUM(NSInteger, LTAutoFixImageResolutionUnit) { 
 LTAutoFixImageResolutionUnitInch = 1,  
 LTAutoFixImageResolutionUnitMillimeter = 2 
}; 
public final class AutoFixImageResolutionUnit 
    extends java.lang.Enum<AutoFixImageResolutionUnit> 
public: 
   enum class AutoFixImageResolutionUnit sealed 
class AutoFixImageResolutionUnit(Enum): 
   Inch = 1 
   Millimeter = 2 
Members
ValueMemberDescription
1InchInches
2MillimeterMillimeters
Remarks

For more information, refer to AutoFixImageResolutionOptions.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
 
 
public static void AutoFixImageResolutionOptions_Example() 
{ 
	// Simulate a digital camera image 
	string fileName = Path.Combine(LEAD_VARS.ImagesDir, "digital-camera.jpg"); 
	int pixelWidth = 3042; 
	int pixelHeight = 4032; 
	int resolution = 72; 
	using (var rasterImage = RasterImage.Create(pixelWidth, pixelHeight, 24, resolution, RasterColor.White)) 
	{ 
		using (var codecs = new RasterCodecs()) 
		{ 
			codecs.Save(rasterImage, fileName, RasterImageFormat.ExifJpeg411, 24); 
		} 
	} 
 
	Console.WriteLine("Default"); 
 
	// Load it using the default values, it should be the original size 
	using (var codecs = new RasterCodecs()) 
	{ 
		using (var rasterImage = codecs.Load(fileName, 1)) 
		{ 
			Console.WriteLine("image size {0} by {1} pixels at {2} DPI", rasterImage.Width, rasterImage.Height, rasterImage.XResolution); 
			// Show its size in inches 
			double inchesWidth = (double)rasterImage.Width / rasterImage.XResolution; 
			double inchesHeight = (double)rasterImage.Height / rasterImage.YResolution; 
			Console.WriteLine("size in inches {0} by {1}", inchesWidth, inchesHeight); 
			Debug.Assert(rasterImage.Width == pixelWidth); 
			Debug.Assert(rasterImage.Height == pixelHeight); 
			Debug.Assert(rasterImage.XResolution == resolution); 
			Debug.Assert(rasterImage.YResolution == resolution); 
		} 
	} 
 
	Console.WriteLine("Fixing the resolution"); 
 
	// Automatically fix its resolution next time we load it 
	AutoFixImageResolutionOptions options = RasterDefaults.GetAutoFixImageResolutionOptions(); 
	options.PageWidth = 8.5; 
	options.PageHeight = 11; 
	options.Unit = AutoFixImageResolutionUnit.Inch; 
	options.MinResolution = 96; 
	RasterDefaults.SetAutoFixImageResolutionOptions(options); 
 
	using (var codecs = new RasterCodecs()) 
	{ 
		// Use the option with this RasterCodecs 
		codecs.Options.Load.AutoFixImageResolution = true; 
		using (var rasterImage = codecs.Load(fileName, 1)) 
		{ 
			Console.WriteLine("image size {0} by {1} pixels at {2} DPI", rasterImage.Width, rasterImage.Height, rasterImage.XResolution); 
			// Show its size in inches 
			double inchesWidth = (double)rasterImage.Width / rasterImage.XResolution; 
			double inchesHeight = (double)rasterImage.Height / rasterImage.YResolution; 
			Console.WriteLine("size in inches {0} by {1}", inchesWidth, inchesHeight); 
			Debug.Assert(rasterImage.Width == pixelWidth); 
			Debug.Assert(rasterImage.Height == pixelHeight); 
			Debug.Assert((int)inchesWidth <= 8.5); 
			Debug.Assert((int)inchesHeight <= 11); 
		} 
	} 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
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.