C# 在缩放时调整Picturebox的大小,而不会造成延迟
我已经做了一种绘画程序,可以画线和图标,背面有一个图像,我们将在上面绘画。我想用滚轮缩放这张图片 我发现的问题是,当我调整它的大小时,witch起作用,我发现在100%的大小上,移动图标时根本没有延迟,但放大了200%,例如,它是滞后的 什么是解决这个问题的明智而正确的方法 代码:C# 在缩放时调整Picturebox的大小,而不会造成延迟,c#,zooming,picturebox,lag,C#,Zooming,Picturebox,Lag,我已经做了一种绘画程序,可以画线和图标,背面有一个图像,我们将在上面绘画。我想用滚轮缩放这张图片 我发现的问题是,当我调整它的大小时,witch起作用,我发现在100%的大小上,移动图标时根本没有延迟,但放大了200%,例如,它是滞后的 什么是解决这个问题的明智而正确的方法 代码: @ Scroll wheel previousWidth = previousWidth * 1.25; previousHeight = previousHeight * 1.25; pictureBox1.Wid
@ 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;
你在做WinForms吗?你说“laggy”是指闪烁吗
尝试将窗体的属性
双缓冲区设置为True。就像前面提到的。嘿,ec8or,不,我是说速度慢,我认为双缓冲在PictureBox中是自动实现的,而不是在面板中。还是谢谢你的建议。