469,903 Members | 1,993 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Problems with GDI+ and transparent PNG-Imges

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
Nov 17 '05 #1
4 15375
I'm sorry, but I've forgotten to tell you that I'm using the ImageList
class to store my images. As I just read in an CodeProject article
(http://www.codeproject.com/cs/miscct...select=958905),
it seems as if the ImageList class has a bug and looses the Alpha channel.
felix wrote:
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

Nov 17 '05 #2
felix wrote:
Does anybody know if that's a problem with the image, the gdi+ or with
my programming?? I simply call


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
Nov 17 '05 #3
Actually, my ColorDepth wasn't at 32Bit. I changed it but it doesn't help...

Greetings,
Felix
Christoph Brüser wrote:
felix wrote:
Does anybody know if that's a problem with the image, the gdi+ or
with my programming?? I simply call

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

Nov 17 '05 #4
felix wrote:
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
Christoph Brüser wrote:
felix wrote:
Does anybody know if that's a problem with the image, the gdi+ or
with my programming?? I simply call

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


Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.