代码之家  ›  专栏  ›  技术社区  ›  Ian Boyd

GDI+:为什么FillRectangle在玻璃上是透明的,而FillEllipse是不透明的?

  •  4
  • Ian Boyd  · 技术社区  · 14 年前

    我在玻璃上画了一个长方形和一个椭圆。

    brush = new SolidBrush(0xFF000000); //solid (i.e. non-opaque) black
    graphics.FillRectangle(brush, x,    y,    30, 30);
    graphics.FillEllipse(brush,   x+33, y-15, 30, 30);
    
    • 不透明的
    • 用矩形绘图:它是

    alt text

    这是怎么回事?

    您可以看到其他颜色也同样适用:

    brush = new SolidBrush(0xFFff0000); //solid (i.e. non-opaque) red
    graphics.FillRectangle(brush, x, y,    30, 30);
    graphics.FillEllipse(brush,   x, y+33, 30, 30);
    
    brush = new SolidBrush(0xFF00ff00); //solid (i.e. non-opaque) green
    graphics.FillRectangle(brush, x, y,    30, 30);
    graphics.FillEllipse(brush,   x, y+33, 30, 30);
    
    brush = new SolidBrush(0xFF0000ff); //solid (i.e. non-opaque) blue
    graphics.FillRectangle(brush, x, y,    30, 30);
    graphics.FillEllipse(brush,   x, y+33, 30, 30);
    
    brush = new SolidBrush(0xFFffffff); //solid (i.e. non-opaque) white
    graphics.FillRectangle(brush, x, y,    30, 30);
    graphics.FillEllipse(brush,   x, y+33, 30, 30);
    

    alt text

    结论 :为什么:

    • FillEllipse
    • FillRectangle 使用不透明颜色绘制部分透明

    这个问题几乎是 my other question . 除了这个问题集中在 差异 填充椭圆 -鉴于这个问题 在玻璃上。

    另见

    0 回复  |  直到 7 年前