public bool UseDpi {get; set;}
Public Property UseDpi As Boolean
public bool UseDpi {get; set;}
@property (nonatomic) BOOL useDpi;
public boolean getUseDpi() public void setUseDpi(boolean useDpi)
get_UseDpi();
set_UseDpi(value);
Object.defineProperty('UseDpi');
Changing the value of this property will fire the PropertyChanged and TransformChanged events.
The physical resolution of an image is measured in dots per inch (DPI). The values of ImageDpiX, ImageDpiY, ScreenDpiX and ScreenDpiY are used when calculating how to display the image if the value of UseDpi is set to true.
For example, a typical A4 document image is 8.5 by 11 inches. Which could be 2550 by 3300 pixels if the image has a resolution of 300 by 300. Most document viewer applications will try to display this image in its original size. i.e. the image will take 8.5 inches of screen horizontal space and 11 inches of screen vertical space. If you do not use the UseDpi property for this control, you are required to do the calculations yourself as follows:
viewer.UseDpi = false;
viewer.ScaleFactor = screenResolution / imageResolution;
In the case of the image above, this will be 96 (typical screen resolution) divided by 300. Or, you can set the UseDpi value to true and the control will use the above formula internally keeping the ScaleFactor set to 1 as follows:
viewer.UseDpi = true;
viewer.ScaleFactor = 1;
The viewer will not automatically set the values of ImageDpiX, ImageDpiY, ScreenDpiX and ScreenDpiY to the current image and screen resolution, instead, these values will all be set to the default value of 96. Set these values to the correct values to use UseDpi correctly.
When UseDpi is set to false, the values of ImageSize and RealImageSize will be the same (the size of the image in pixels). When UseDpi is set to true, the values of ImageSize and RealImageSize may not be the same as the image or screen DPI. ImageSize will have the original size in pixels while RealImageSize will contain the size multiplied by a ratio between screen and image sizes.
using Leadtools; using Leadtools.Codecs; using Leadtools.Controls; [TestMethod] public void UseDpiExample() { // Check if UseDpi is set to true if (!_viewer.UseDpi) { // No, set it to true // Also set the image DPI to 300 and the screen DPI to 96 _viewer.BeginUpdate(); _viewer.ImageDpiX = 300; _viewer.ImageDpiY = 300; _viewer.ScreenDpiX = 96; _viewer.ScreenDpiY = 96; _viewer.UseDpi = true; _viewer.EndUpdate(); } else { // Yes, set it back to false _viewer.UseDpi = false; } // Show the image and real image sizes Size imageSize = _viewer.ImageSize; Size realImageSize = _viewer.RealImageSize; string content = "UseDPI: " + _viewer.UseDpi; content += " Image size: " + imageSize.Width + ", " + imageSize.Height; content += " Real image size: " + realImageSize.Width + ", " + realImageSize.Height; _infoLabel.Text = content; }