在c#winform PictureBox中用新映像替换旧映像

在c#winform PictureBox中用新映像替换旧映像,c#,winforms,C#,Winforms,我正在尝试缩放图片框中的图像: private void pe_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { var pe = (PictureEdit)sender; e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.ScaleTransform

我正在尝试缩放图片框中的图像:

private void pe_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
        var pe = (PictureEdit)sender;
        e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
        e.Graphics.ScaleTransform(zoom, zoom);
        e.Graphics.DrawImage(pe.Image, imgx, imgy);
        }

但是图像框图片没有更新。实际上,一个新图像正在旧图像上绘制。旧图像仍然存在。当我平移新图像时,我可以看到它后面的旧图像。

在绘制前清除图形
e.graphics.clear(pe.BackColor)请注意,通常缩放图片框的方法是设置其SizeMode=zoom并更改其大小,通常是在将PB放置在自动滚动面板中之后此外,在每次绘画活动中绘制整个图像看起来相当昂贵。。