GDI+: Why is FillRectangle transparent on glass, while FillEllipse is opaque?

来源:互联网 发布:淘宝网店购买 编辑:程序博客网 时间:2024/05/17 14:26

i'm drawing a rectangle, and an ellipse, on glass.

brush = new SolidBrush(0xFF000000); //solid (i.e. non-opaque) blackgraphics.FillRectangle(brush, x,    y,    30, 30);graphics.FillEllipse(brush,   x+33, y-15, 30, 30);
  • drawing with ellipse: it's opaque
  • drawing with rectangle: it's not opaque

alt text

What is going on here?

You can see the same also applies for other colors:

brush = new SolidBrush(0xFFff0000); //solid (i.e. non-opaque) redgraphics.FillRectangle(brush, x, y,    30, 30);graphics.FillEllipse(brush,   x, y+33, 30, 30);brush = new SolidBrush(0xFF00ff00); //solid (i.e. non-opaque) greengraphics.FillRectangle(brush, x, y,    30, 30);graphics.FillEllipse(brush,   x, y+33, 30, 30);brush = new SolidBrush(0xFF0000ff); //solid (i.e. non-opaque) bluegraphics.FillRectangle(brush, x, y,    30, 30);graphics.FillEllipse(brush,   x, y+33, 30, 30);brush = new SolidBrush(0xFFffffff); //solid (i.e. non-opaque) whitegraphics.FillRectangle(brush, x, y,    30, 30);graphics.FillEllipse(brush,   x, y+33, 30, 30);

alt text

Conclusion: Why does:

  • FillEllipse with an opaque color draw opaque
  • FillRectangle with an opaque color draws partially transparent

Note: This question is very nearly a duplicate of my other question. Except this question focuses on the difference between FillRectangle and FillEllipse - whereas that question deals with *How to draw opaque colors on glass.

See also

  • Aero: How to draw solid (opaque) colors on glass?
  • Windows Aero: What color to paint to make “glass” appear?

转自:http://stackoverflow.com/questions/4286467/gdi-why-is-fillrectangle-transparent-on-glass-while-fillellipse-is-opaque
原创粉丝点击