PNG transparency in ListView?

A

Alain Dekker

Hi,

Using VS 2005, C#, CF .NET v2.0 targetting Windows CE.

I'm using a standard Windows.Form.ListView and I've added a bunch of icons.
I've in the process of converting the actually images from ICO files into
PNG but I've hit a snag.

For the transparent colour of the PNG, I've chosen Fuchsia (R=255, G=0,
B=255). I've then set the transparent colour for the PNG to Fuchsia and it
works great. In Windows Picture and fax Viewer (used to preview the image)
the image appears perfectly (no Fuchsia in sight). When I load it into
Visual Studio 2005, the ListView.LargeImageList.Images collection shows the
image perfectly (no Fuchsia). But when I actually run the application, I see
a bright pink background!

What am I doing wrong? Is this a limitation of Windows CE? The Compact
Framework? Is there some coding I need to do?

Thanks,
Alain
 
A

Alain Dekker

My researches (thanks Google!) have suggested this is a bug in .NET 2.0 (and
therefore in the CF 2.0) which apparently gets fixed in .NET 3.5. There was
an article I came across that gave code to derive your own ListView, handle
the loading and then display of the images yourself to get alpha channel
transparency support for PNGs...but I haven't got the time for this solution
now so have just gone back to plain 'ol bitmaps for the time being. Will
tackle this at an opportune moment in the new year.

Thanks again, Peter.
Alain

Peter Duniho said:
[...]When I load it into
Visual Studio 2005, the ListView.LargeImageList.Images collection shows
the
image perfectly (no Fuchsia). But when I actually run the application, I
see
a bright pink background!

What am I doing wrong? Is this a limitation of Windows CE? The Compact
Framework? Is there some coding I need to do?

I don't even know that it would work on the desktop .NET. It might, but
there are certainly bitmap forms that .NET doesn't support, and that might
be one of them. In any case, it definitely would not surprise me for CF
.NET to not support colorkey transparency in PNGs.

Note that PNG also supports transparency via alpha channel. So one
possible option is to edit the image using something that supports
transparency/alpha, instead of using color keying. Of course, that relies
on CF .NET supporting that format too, which it might not.

Pete
 

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