我制作了一种可以制作线条和图标并且背面有图像的绘画程序。这张图片我想用滚轮缩放。
我发现的问题是当我调整它的大小时,我发现虽然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;