public Bitmap DrawBitmap()
{
Bitmap bmp = new Bitmap(3720, 3720);
Graphics sg = Graphics.FromImage(bmp);
float st = 270;
float ws = 0.5f;
for (int i = 0; i < 730; i++)
{
st = st + ws;
for (int j = 0; j < 1840; j++)
{
int Ri = 1840 - 1 * j;
Rectangle rec = new(20 + j, 20 + j, Ri * 2, Ri * 2);
SolidBrush sb = GetRandomColor();
sg.FillPie(sb, rec, st, ws);
}
}
sg.Dispose();
return bmp;
}
private SolidBrush GetRandomColor()
{
long tick = DateTime.Now.Ticks;
Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
int R = ran.Next(255);
int G = ran.Next(255);
int B = ran.Next(255);
B = (R + G > 400) ? R + G - 400 : B;//0 : 380 - R - G;
B = (B > 255) ? 255 : B;
return new SolidBrush(Color.FromArgb(R, G, B));
}
请教大神,如何修改这段绘制Bitmap方法,提高绘图速度?不管用哪台电脑绘制下来基本上都要超过1分钟,有没有办法提高绘制效率呢。
努力~