可以使用创建一个新的 Graphics 对象,在新的 Graphics 对象中绘制旧图片和新图片,然后再将新的 Graphics 对象绘制到屏幕上。这样旧图片和新图片就不会互相覆盖。

示例代码:

// 假设有一个名为 'oldImage' 的旧图片,名为 'newImage' 的新图片
Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
Graphics g = Graphics.FromImage(bmp);

// 先绘制旧图片
g.DrawImage(oldImage, 0, 0);

// 再绘制新图片
g.DrawImage(newImage, 100, 100);

// 将新的 Graphics 对象绘制到屏幕上
e.Graphics.DrawImage(bmp, 0, 0);
C# Graphics 绘制图片防止覆盖技巧

原文地址: http://www.cveoy.top/t/topic/osyn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录