Converts a point from control (display) to image coordinates.
public virtual Point PointToImageCoordinates(Point point)
Public Overridable Function PointToImageCoordinates( _ByVal point As Point _) As Point
public:virtual Point PointToImageCoordinates(Point point)
point
The source point in control (display) coordinates.
A System.Windows.Point that contains the converted values in image coordinates.
The viewer control contain many properties that control how the image will be displayed on the surface of the control. At any time, you might require to convert a point or a rectangle from control (where it is on the surface of the control) to image (the pixel x and y value in the image data) and vice versa.
Use PointToImageCoordinates to convert a point from control to image coordinates, use PointFromImageCoordinates to convert a point from image to control coordinates. Use BoundsToImageCoordinates to convert a rectangle value from control to image coordinates and BoundsFromImageCoordinates to convert a rectangle value from image to control coordinates.
Note that when using the RasterImageBox and RasterImageViewer controls to display a LEADTOOLS Leadtools.RasterImage object, the image coordinates are assumed to be in top-left view perspective. If the image contains a RasterImage.ViewPerspective value other than RasterViewPerspective.TopLeft you must call RasterImage.PointToImage or RasterImage.RectangleToImage to further convert the values to actual rows and columns pixel values in the image.
Imports Leadtools.Windows.ControlsPrivate Class PointToImageCoordinatesWindow : Inherits WindowPrivate theImage As ImageViewerPublic Sub New()' Create the viewertheImage = New ImageViewer()' Create Dock PanelDim panel As DockPanel = New DockPanel()Content = panelDockPanel.SetDock(theImage, Dock.Bottom)theImage.HorizontalAlignment = HorizontalAlignment.CentertheImage.VerticalAlignment = VerticalAlignment.Bottompanel.Children.Add(theImage)' load an image into the viewertheImage.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))theImage.SizeMode = SizeMode.FitTitle = 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)Dim point As Point = theImage.PointToImageCoordinates(e.GetPosition(Me))Dim s As String = String.Format("Point accroding the image coordinates {0}", point.ToString())MessageBox.Show(s)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 PointToImageCoordinatesWindow : Window{ImageViewer theImage;public PointToImageCoordinatesWindow(){// Create the viewertheImage = new ImageViewer();// Create Dock PanelDockPanel panel = new DockPanel();Content = panel;DockPanel.SetDock(theImage, Dock.Bottom);theImage.HorizontalAlignment = HorizontalAlignment.Center;theImage.VerticalAlignment = VerticalAlignment.Bottom;panel.Children.Add(theImage);// load an image into the viewertheImage.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));theImage.SizeMode = SizeMode.Fit;Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);theImage.MouseDown += new MouseButtonEventHandler(theImage_MouseClick);}void theImage_MouseClick(object sender, MouseButtonEventArgs e){Point point = theImage.PointToImageCoordinates(e.GetPosition(this));string s = string.Format("Point accroding the image coordinates {0}", point.ToString());MessageBox.Show(s);}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
using Leadtools.Help;using Leadtools.Windows.Controls;class PointToImageCoordinatesWindow : ChildWindow{ImageViewer theImage;public PointToImageCoordinatesWindow(){// Create the viewertheImage = new ImageViewer();// Create Dock PanelStackPanel panel = new StackPanel();Content = panel;theImage.HorizontalAlignment = HorizontalAlignment.Center;theImage.VerticalAlignment = VerticalAlignment.Bottom;panel.Children.Add(theImage);// load an image into the viewertheImage.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg"));theImage.SizeMode = SizeMode.Fit;Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);theImage.MouseLeftButtonDown += new MouseButtonEventHandler(theImage_MouseLeftButtonDown);}void theImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e){Point point = theImage.PointToImageCoordinates(e.GetPosition(this));string s = string.Format("Point accroding the image coordinates {0}", point.ToString());MessageBox.Show(s);}}
Imports LeadtoolsImports Leadtools.Windows.ControlsPrivate Class PointToImageCoordinatesWindow : Inherits ChildWindowPrivate theImage As ImageViewerPublic Sub New()' Create the viewertheImage = New ImageViewer()' Create Dock PanelDim panel As StackPanel = New StackPanel()Content = paneltheImage.HorizontalAlignment = HorizontalAlignment.CentertheImage.VerticalAlignment = VerticalAlignment.Bottompanel.Children.Add(theImage)' load an image into the viewertheImage.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg"))theImage.SizeMode = SizeMode.FitTitle = 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)Dim point As Point = theImage.PointToImageCoordinates(e.GetPosition(Me))Dim s As String = String.Format("Point accroding the image coordinates {0}", point.ToString())MessageBox.Show(s)End SubEnd Class
|
Products |
Support |
Feedback: PointToImageCoordinates Method (ImageViewer) - 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.