Centers the image display at the specified point.
public virtual void CenterAtPoint(Point pt)
Public Overridable Sub CenterAtPoint( _ByVal pt As Point _)
public:virtual void CenterAtPoint(Point pt)
pt
The point at which to center the image display, in client coordinates.
If the value of CenterZoomAtPointScaleFactor was anything other than the default value of 1, then this method will zooms in (if the value is greater than 1) or zooms out (if the value is less than 0) the image as well around the same center point.
This example shows a method to change the viewer scale factor (zoom) while keeping the viewer centered.
using Leadtools.WinForms;using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing.Color;using Leadtools.Drawing;void ZoomAndCenter(RasterImageViewer viewer, double scaleFactor){// Minimum and maximum scale factors allowed (change if you have to)const double minimumScaleFactor = 0.05;const double maximumScaleFactor = 11;// Normalize the scale factor based on min and maxscaleFactor = Math.Max(minimumScaleFactor, Math.Min(maximumScaleFactor, scaleFactor));// Check if we need to change the scale factor for the viewerif (viewer.ScaleFactor != scaleFactor){// Get the current center in logical units// We will use this point later to re-center the viewer// Get what you see in physical coordinatesRectangle rc = Rectangle.Intersect(viewer.PhysicalViewRectangle, viewer.ClientRectangle);// Get the center of what you see in physical coordinatesPointF center = new PointF(rc.Left + rc.Width / 2, rc.Top + rc.Height / 2);Transformer t = new Transformer(viewer.Transform);// Get the center of what you see in logical coordinatescenter = t.PointToLogical(center);// Set the new scale factorviewer.ScaleFactor = scaleFactor;// Bring the original center into the view centert = new Transformer(viewer.Transform);// Get the center of what you saw before the zoom in physical coordinatescenter = t.PointToPhysical(center);// Bring the old center into the center of the viewviewer.CenterAtPoint(Point.Round(center));}}
Imports Leadtools.WinFormsImports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessing.ColorImports Leadtools.DrawingSub ZoomAndCenter(ByVal viewer As RasterImageViewer, ByVal scaleFactor As Double)' Minimum and maximum scale factors allowed (change if you have to)Const minimumScaleFactor As Double = 0.05Const maximumScaleFactor As Double = 11' Normalize the scale factor based on min and maxscaleFactor = Math.Max(minimumScaleFactor, Math.Min(maximumScaleFactor, scaleFactor))' Check if we need to change the scale factor for the viewerIf (viewer.ScaleFactor <> scaleFactor) Then' Get the current center in logical units' We will use this point later to re-center the viewer' Get what you see in physical coordinatesDim rc As Rectangle = Rectangle.Intersect(viewer.PhysicalViewRectangle, viewer.ClientRectangle)' Get the center of what you see in physical coordinatesDim center As New PointF(rc.Left + rc.Width \ 2, rc.Top + rc.Height \ 2)Dim t As New Transformer(viewer.Transform)' Get the center of what you see in logical coordinatescenter = t.PointToLogical(center)' Set the new scale factorviewer.ScaleFactor = scaleFactor' Bring the original center into the view centert = New Transformer(viewer.Transform)' Get the center of what you saw before the zoom in physical coordinatescenter = t.PointToPhysical(center)' Bring the old center into the center of the viewviewer.CenterAtPoint(Point.Round(center))End IfEnd Sub
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
