【问题标题】:resizing the Picturebox as in Zooming, without the lag it causes像缩放一样调整图片框的大小,没有它导致的滞后
【发布时间】: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


    【解决方案1】:

    你在做 WinForms 吗?当你说“滞后”时,你的意思是闪烁吗?

    尝试将表单的属性DoubleBuffered 设置为True。就像提到的here

    【讨论】:

    • 嘿,ec8or,不,我的意思是慢,我认为双缓冲在图片框中自动变为真,但在面板中不是。仍然感谢您的建议。
    猜你喜欢
    • 1970-01-01
    • 2023-01-26
    • 2013-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    相关资源
    最近更新 更多