Problems with GDI+ and transparent PNG-Imges

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
 
?

=?ISO-8859-1?Q?Christoph_Br=FCser?=

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
 
F

felix

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

Greetings,
Felix
 
M

Markus Stoeger

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top