Problems with GDI+ and transparent PNG-Imges

  • Thread starter Thread starter felix
  • Start date Start date
F

felix

Hi,

I tried google and searched the old posts -- with no success. Like a
zillion of people before I have a problem when rendering transparent
PNGs with GDI+ and the C# Graphics class. The image shows am object on a
transparent background. I get ugly artifacts at the object's edge where
the transparency begins. It looks as if there was a 8bit alpha reduced
to 1 bit. Where there wasn't full transparency, the background (I
suppose blue) seems to shine through.

Does anybody know if that's a problem with the image, the gdi+ or with
my programming?? I simply call

g.DrawImage(img, startPos, 0, imageWidth, height);

Thanks for any reply and best regards,
Felix
 
I'm using an ImageList with transparent PNG images with no problems so
far. Did you set the ImageList properties ColorDepth and TransparentColor?

imageList.TransparentColor = Color.Transparent;
imageList.ColorDepth = ColorDepth.Depth32Bit;

Not sure if that solves your problem, but you might give it a try.

Christoph Brüser
 
Actually, my ColorDepth wasn't at 32Bit. I changed it but it doesn't help...

Greetings,
Felix
 
felix said:
Actually, my ColorDepth wasn't at 32Bit. I changed it but it doesn't
help...

We are having the same problem with ImageLists. As soon as you put an Image
into it it loses transparency. We are embedding Images as resources now and
use the ResourceManager to retrieve them. That works fine with transparency
and the API for accessing the Images is better than the ImageList's also.

Max
 
Back
Top