Zooming / stretching a picturebox on current mouse position?

…衆ロ難τιáo~ 提交于 2019-12-01 09:26:05

the code below zoomed and stretched the pictureBox on the current mouse position

pictureBox1.Width = (int)(pictureBox1.Width * zoomratio );
pictureBox1.Height = (int)(pictureBox1.Height * zoomratio );                
pictureBox1.Top = (int)(e.Y - zoomratio * (e.Y - pictureBox1.Top));
pictureBox1.Left = (int)(e.X - zoomratio * (e.X - pictureBox1.Left));

I managed to tweak the calculation of the location in this line of code. It's working fine, it is zooming just the way I need it.

pbxMapa.Location = new Point(pbxMapa.Location.X + (int)(((pbxMapa.Location.X - mouseXPbx) / 10) * zoomRatio), pbxMapa.Location.Y + (int)(((pbxMapa.Location.Y - mouseYPbx) / 10) * zoomRatio));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!