Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, April 9, 2013 12:18:58 PM(UTC)
tbecker82

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
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, April 10, 2013 6:39:46 AM(UTC)

Ibrahim  
Guest

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)
tbecker82

Groups: Registered
Posts: 37


Thank you Ibrahim, that worked.

Tony
 
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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.081 seconds.