Gets or sets a value that indicates whether the control must account for the physical resolution of the image when calculating the display properties. This is a dependency property.
public bool UseDpi {get; set;}Public Property UseDpi As Booleantrue to account for the physical resolution of the image when calculating the display properties; otherwise, false.
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.
Imports Leadtools.Windows.ControlsPrivate Class MyWindow1 : Inherits WindowPrivate theImage As ImageBoxPublic Sub New()' Create the viewertheImage = New ImageBox()' Create Dock PanelDim panel As DockPanel = New DockPanel()Content = panelDockPanel.SetDock(theImage, Dock.Bottom)theImage.HorizontalAlignment = HorizontalAlignment.CentertheImage.VerticalAlignment = VerticalAlignment.BottomtheImage.UseDpi = TruetheImage.ScreenDpiX = 96theImage.ScreenDpiY = 96panel.Children.Add(theImage)' load an image into the viewertheImage.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode)AddHandler theImage.MouseDown, AddressOf theImage_MouseClickEnd SubPrivate Sub theImage_MouseClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs)Select Case theImage.SizeModeCase SizeMode.NormaltheImage.SizeMode = SizeMode.StretchCase SizeMode.StretchtheImage.SizeMode = SizeMode.FitCase SizeMode.FittheImage.SizeMode = SizeMode.FitAlwaysCase SizeMode.FitAlwaystheImage.SizeMode = SizeMode.FitWidthCase SizeMode.FitWidththeImage.SizeMode = SizeMode.NormalEnd SelectTitle = String.Format("Size mode = {0}, double click to change", theImage.SizeMode)End SubEnd ClassPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools.Help;using Leadtools.Windows.Controls;class MyWindow1 : Window{ImageBox theImage;public MyWindow1(){// Create the viewertheImage = new ImageBox();// Create Dock PanelDockPanel panel = new DockPanel();Content = panel;DockPanel.SetDock(theImage, Dock.Bottom);theImage.HorizontalAlignment = HorizontalAlignment.Center;theImage.VerticalAlignment= VerticalAlignment.Bottom;theImage.UseDpi = true;theImage.ScreenDpiX = 96;theImage.ScreenDpiY = 96;panel.Children.Add(theImage);// load an image into the viewertheImage.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);theImage.MouseDown += new MouseButtonEventHandler(theImage_MouseClick);}void theImage_MouseClick(object sender, MouseButtonEventArgs e){switch(theImage.SizeMode){case SizeMode.Normal:theImage.SizeMode = SizeMode.Stretch;break;case SizeMode.Stretch:theImage.SizeMode = SizeMode.Fit;break;case SizeMode.Fit:theImage.SizeMode = SizeMode.FitAlways;break;case SizeMode.FitAlways:theImage.SizeMode = SizeMode.FitWidth;break;case SizeMode.FitWidth:theImage.SizeMode = SizeMode.Normal;break;}Title = string.Format("Size mode = {0}, double click to change", theImage.SizeMode);}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
using Leadtools.Help;using Leadtools.Windows.Controls;class MyWindow1 : ChildWindow{ImageBox theImage;public MyWindow1(){// Create the viewertheImage = new ImageBox();// Create Dock PanelStackPanel panel = new StackPanel();Content = panel;theImage.HorizontalAlignment = HorizontalAlignment.Center;theImage.VerticalAlignment= VerticalAlignment.Bottom;theImage.UseDpi = true;theImage.ScreenDpiX = 96;theImage.ScreenDpiY = 96;panel.Children.Add(theImage);// load an image into the viewertheImage.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg"));Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);theImage.MouseLeftButtonDown +=new MouseButtonEventHandler(theImage_MouseLeftButtonDown);}void theImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e){switch (theImage.SizeMode){case SizeMode.Normal:theImage.SizeMode = SizeMode.Stretch;break;case SizeMode.Stretch:theImage.SizeMode = SizeMode.Fit;break;case SizeMode.Fit:theImage.SizeMode = SizeMode.FitAlways;break;case SizeMode.FitAlways:theImage.SizeMode = SizeMode.FitWidth;break;case SizeMode.FitWidth:theImage.SizeMode = SizeMode.Normal;break;}Title = string.Format("Size mode = {0}, double click to change", theImage.SizeMode);}}
Imports Leadtools.Windows.ControlsPrivate Class MyWindow1 : Inherits ChildWindowPrivate theImage As ImageBoxPublic Sub New()' Create the viewertheImage = New ImageBox()' Create Dock PanelDim panel As StackPanel = New StackPanel()Content = paneltheImage.HorizontalAlignment = HorizontalAlignment.CentertheImage.VerticalAlignment= VerticalAlignment.BottomtheImage.UseDpi = TruetheImage.ScreenDpiX = 96theImage.ScreenDpiY = 96panel.Children.Add(theImage)' load an image into the viewertheImage.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg"))Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode)AddHandler theImage.MouseLeftButtonDown, AddressOf theImage_MouseLeftButtonDownEnd SubPrivate Sub theImage_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)Select Case theImage.SizeModeCase SizeMode.NormaltheImage.SizeMode = SizeMode.StretchCase SizeMode.StretchtheImage.SizeMode = SizeMode.FitCase SizeMode.FittheImage.SizeMode = SizeMode.FitAlwaysCase SizeMode.FitAlwaystheImage.SizeMode = SizeMode.FitWidthCase SizeMode.FitWidththeImage.SizeMode = SizeMode.NormalEnd SelectTitle = String.Format("Size mode = {0}, double click to change", theImage.SizeMode)End SubEnd Class
<!--WPF example--><Window x:Class="WPFSamples.ImageBox"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"Height="600" Width="800"><DockPanel><Leadtools_Windows_Controls:ImageBoxName="theImage"Source="file:///c:\users\Public\Documents\LEADTOOLS Images\cannon.jpg"DockPanel.Dock= "Bottom"HorizontalAlignment="Center" VerticalAlignment="Bottom" SizeMode="Fit" UseDpi="true"></Leadtools_Windows_Controls:ImageBox ></DockPanel><Window.Title>"Apply a effect"</Window.Title></Window><!--Silverlight example--><UserControl x:Class="SilverlightApplication1.MainPage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"mc:Ignorable="d"d:DesignHeight="300" d:DesignWidth="400"><Grid x:Name="LayoutRoot" Background="White"><Leadtools_Windows_Controls:ImageBox Name="theImage" Source="http://www.MyServer.com/images/MyImage.png" HorizontalAlignment="Center" VerticalAlignment="Bottom" SizeMode="Fit" UseDpi="true"></Leadtools_Windows_Controls:ImageBox ></Grid></UserControl>
|
Products |
Support |
Feedback: UseDpi Property (ImageBox) - Leadtools.Windows.Controls |
Introduction |
Help Version 19.0.2017.3.22
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.