Leadtools.Windows.Controls Namespace > ImageViewer Class : UseDpi Property |
public bool UseDpi {get; set;}
'Declaration Public Property UseDpi As Boolean
'Usage Dim instance As ImageViewer Dim value As Boolean instance.UseDpi = value value = instance.UseDpi
The physical resolution of an image is measured in dots per inch (DPI). When you load an image, the Leadtools.RasterImage.XResolution and Leadtools.RasterImage.YResolution properties are updated with the DPI values for the horizontal and vertical resolution. Some images have different horizontal and vertical resolutions. For example, the horizontal resolution of a fax image is typically twice its vertical resolution (for example 200 by 100). In such cases, the displayed images will appear elongated if you do not account for the resolution. If the image horizontal and vertical and resolution are is ot equal, you must set the UseDpi property to true to have the control automated scaling properties account for the physical resolution of the image.
The values of SourceDpiX, SourceDpiY, 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:
control.UseDpi = false; control.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:
control.UseDpi = true; control.ScaleFactor = 1;
This code will produce the same result as the previous one.
The control will automatically set the ScreenDpiX and ScreenDpiY to the current screen resolution, also the SourceDpiX and SourceDpiY will be obtained from the current image set in Source. You can change these values if required for manual calculations.
For XAML example, refer to ImageViewer.
For C#/VB examples, refer to ImageViewer.