【发布时间】:2014-06-26 10:43:14
【问题描述】:
我制作了一种绘画程序,可以制作线条和图标,并在背面有一个图像将被绘制。我想使用滚轮缩放这张图片。
我发现的问题是,当我调整它的大小时,我发现在 100% 的大小上移动图标时完全没有延迟,但放大到 200% 时,例如它是延迟的。
什么是解决这个问题的聪明而正确的方法?
代码:
@ Scroll wheel
previousWidth = previousWidth * 1.25;
previousHeight = previousHeight * 1.25;
pictureBox1.Width = (int)previousWidth;
pictureBox1.Height = (int)previousHeight;
// the previous height is to avoid losing the 0.xxxx and so rescaling will
// not eventually end up in a 1 by 1 pixel image or too large.
array.zoomOut(); //makes the lines zoom properly with the picture
icon.zoomOut(); // makes the icons zoom properly with the picture
pictureBox1.Refresh();
// @ opening the file //
file = System.Drawing.Image.FromFile(openFileDialog1.FileName);
pictureBox1.Image = file;
pictureBox1.Size = new System.Drawing.Size(file.Width, file.Height);
bitmap = new Bitmap(pictureBox1.Image);
pictureBox1.DrawToBitmap(bitmap, new System.Drawing.Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
pictureLoaded = true;
previousWidth = pictureBox1.Width;
previousHeight = pictureBox1.Height;
【问题讨论】:
标签: c# zooming picturebox lag