Centers the image display at the specified point.
public virtual void CenterAtPoint(
Point pt
)
public:
virtual void CenterAtPoint(
Point pt
)
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 max
scaleFactor = Math.Max(minimumScaleFactor, Math.Min(maximumScaleFactor, scaleFactor));
// Check if we need to change the scale factor for the viewer
if (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 coordinates
Rectangle rc = Rectangle.Intersect(viewer.PhysicalViewRectangle, viewer.ClientRectangle);
// Get the center of what you see in physical coordinates
PointF 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 coordinates
center = t.PointToLogical(center);
// Set the new scale factor
viewer.ScaleFactor = scaleFactor;
// Bring the original center into the view center
t = new Transformer(viewer.Transform);
// Get the center of what you saw before the zoom in physical coordinates
center = t.PointToPhysical(center);
// Bring the old center into the center of the view
viewer.CenterAtPoint(Point.Round(center));
}
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
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.