LEADTOOLS Support
Imaging
Imaging SDK Questions
Issue with keeping image centered while zooming
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Tuesday, April 9, 2013 12:18:58 PM(UTC)
Groups: Registered
Posts: 37
Leadtools v.17.5 .Net libraries
Hello,
As the subject says I am having an issue keeping my image centered while zooming in or out.
When I zoom in, the viewing area is being "pushed" up until the viewing area reaches the top of the image.
When I zoom out, the viewing area is being "pushed" down until the viewing area reaches the bottom of the image.
The following code is what I am using to handle the zoom event. It is based upon the example for the RasterImageViewer.CenterAtPoint() function.
private void Zoom(bool isPositive)
{
double temp = Math.Round(m_viewer.ScaleFactor, 2);
Rectangle rc = Rectangle.Intersect(m_viewer.PhysicalViewRectangle, m_viewer.ClientRectangle);
PointF center = new PointF((float)((rc.Left + rc.Width / 2)), (float)((rc.Top + rc.Height / 2)));
Leadtools.Drawing.Transformer t = new Leadtools.Drawing.Transformer(m_viewer.Transform);
center = t.PointToLogical(center);
if (isPositive)
m_viewer.ScaleFactor = temp + 0.01;
else
{
if (temp - 0.01 > 0.05)
{
if (temp > 0.75)
m_viewer.ScaleFactor = temp - 0.5;
else
m_viewer.ScaleFactor = temp - 0.01;
}
else
m_viewer.ScaleFactor = 0.05;
}
// Get the center of what you saw before the zoom in physical coordinates
t = new Leadtools.Drawing.Transformer(m_viewer.Transform);
center = t.PointToPhysical(center);
m_viewer.CenterAtPoint(Point.Round(center));
m_model.Magnification = (float)m_viewer.ScaleFactor;
}
The image stays centered until it is to big to fit in the viewing area, at which point the image begins to creep up when zooming.
Any ideas would be greatly appreciated.
Thanks
Tony
#2
Posted
:
Wednesday, April 10, 2013 6:39:46 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Tony,
The difference might be caused by the scrollbars if they are enabled.
See code project posted by Adnan Ismail in forum post:
http://support.leadtools.com/cs/forums/16679/ShowPost.aspx#16679
#3
Posted
:
Wednesday, April 10, 2013 9:30:00 AM(UTC)
Groups: Registered
Posts: 37
Thank you Ibrahim, that worked.
Tony
LEADTOOLS Support
Imaging
Imaging SDK Questions
Issue with keeping image centered while zooming
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.