3

我正在制作一个带有两个半透明文本的简单表格,并将其放入绘画事件中。只是,当我扩大表格时,文本会变得更暗和有颗粒感。实际上我想要更深的颜色而不是颗粒感。

这是我的代码片段:

private void sbfToolBox_Paint(object sender, PaintEventArgs e)
{
    System.Drawing.Graphics formGraphics = this.CreateGraphics();
    formGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
    string drawString = "tekst";
    System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 50);
    Color color_red = Color.FromArgb(30, 100, 0, 0);
    Color color_cyan = Color.FromArgb(30, 0, 100, 100);
    System.Drawing.SolidBrush brush_red = new System.Drawing.SolidBrush(color_red);
    System.Drawing.SolidBrush brush_cyan = new System.Drawing.SolidBrush(color_cyan);
    float x = 0.0F;
    float x2 = 20.0F;
    float y = 50.0F;
    formGraphics.DrawString(drawString, drawFont, brush_red, x, y);
    formGraphics.DrawString(drawString, drawFont, brush_cyan, x2, y);
    drawFont.Dispose();
    brush_red.Dispose();
    brush_cyan.Dispose();
    formGraphics.Dispose();
}    

提前致谢

4

1 回答 1

2

使用 PaintEventArgs 中的 Graphics 对象。

改变

System.Drawing.Graphics formGraphics = this.CreateGraphics();

System.Drawing.Graphics formGraphics = e.Graphics;

并删除

formGraphics.Dispose();
于 2010-04-12T21:05:20.617 回答