←Select platform

ImageDpiY Property

Summary

Gets or sets the vertical resolution in dots/inch (or DPI) of the image.

Syntax

C#
VB
Java
Objective-C
WinRT C#
public double ImageDpiY {get; set;} 
Public Property ImageDpiY As Double 
public double ImageDpiY {get; set;} 
@property (nonatomic, assign) NSUInteger imageDpiY 
public int getImageDpiY() 
public void setImageDpiY(int imageDpiY) 
             
  
get_ImageDpiY(); 
set_ImageDpiY(value); 
Object.defineProperty('ImageDpiY');  

Property Value

The current vertical resolution in dots/inch (or DPI) of the image. A value of 0 means use the default image resolution which 96. The default value is 0.

Remarks

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. Without using the UseDpi property of 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; 

This code will produce the same result as the previous one.

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. You must set these values to the correct values if the UseDpi is to be used 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 might not be the same of the image or screen DPI is different. ImageSize will have the original size in pixels while RealImageSize will contain the size multiplied by a ratio between screen and image sizes.

When you set a new image in the viewer, you can also set the image resolution (DPI) into the ImageDpiX and ImageDpiY values. Some images such as FAX documents might have different values for horizontal and vertical resolution done mainly to compress the image during transfer. For example, a FAX TIF image might have 300 as the horizontal resolution and only 150 for the vertical. This image has an aspect ratio of 2/1.

When you set these values in ImageViewer, the image will be displayed squished vertically, since the image contains half the number of scan lines in the vertical direction. Document viewers will usually compensate for that by scaling the display transformation by 2 in the Y direction to correct the aspect ratio back to 1.

When you set EnableDpiCorrection to true, the ImageViewer control will do exactly that and the image will be displayed in the correct aspect ratio.

Example

For an example, refer to UseDpi.

Requirements

Target Platforms

Help Version 19.0.2017.10.28
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Controls Assembly (WinRT / WPF / iOS / OS X / Android)