Drawing of PNGs with transparent pixels



Hi everyone,

I have a problem I'm currently stuck with. To enable icons in menus, I've
written my own drawing routine for MenuItems (OwnerDraw=true). The icons to
be displayed are PNGs with tranparency and are an embedded resource. On
startup I load the images into an ImageList as described in [1].

So far everything works fine. If I assign one of my icons to a TabPage it is
displayed correctly including transparent regions without artifacts on
edges. The same is true for ToolBarButtons with an appropriate ImageIndex
set.

For MenuItems I use the method Graphics.DrawImage() to draw the icon. But
here, the disturbing artifacts appear again! The same happens if I assign an
image to a PictureBox control.

What seems unlogical to me is that other controls like ToolBarButton draw
the icon correctly. I've set
Graphics.CompositingMode=CompositingMode.SourceOver to ensure that
half-transparent pixels are merged with the background color, but to no
avail.

Does anybody know a way how to get around that?

Thank you very much, best regards,

Alex

[1] http://www.codeproject.com/cs/miscctrl/AlphaImageImagelist.asp
--
_______________________________________

Alexander Groß
Dipl.-Ing. (BA) für Informationstechnik
PLEASEAlexanderGrossREMOVETHIS@xxxxxx
http://www.it99.org/axl
ICQ# 36765668
_______________________________________


.