473,324 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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 15631
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Nathan Sokalski | last post by:
I am trying to create graphics with GDI+ that include transparency. However, the transparency never seems to show up, even though my colors have an alpha value of 0. How can I generate a graphic...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.