如何 Graphics 对象设置背景色

时间:2022-11-09 14:51:00

用 Clear 方法可以轻松地给 Graphics 对象设置背景色。

using (Bitmap bmp = new Bitmap(width, height))
{
    using (Graphics graphics = Graphics.FromImage(bmp))
    {
         graphics.Clear(Color.White);

当然这是在还没有绘图之前就要设置。