Transparent Icon Problem

D

Drew

Having trouble with a transparent application icon:

It's black where it should be transparent.

I've soft reset the device many times, but it's still black.

This is strange because I have other transparent
icons which work as expected.

The icons are 32x32 and 16x16 at 256 colors.

I've gone to just coloring in the transparent portions
with white, but this is not ideal.

Any ideas?

Drew
 
L

Lloyd Dupont

I had similar problemand used an almost good workaround.
for the application icon I use the XOR color (the computer iwth pink screen)
instead of the transparent one and it gaves me a white background
 
G

Graeme Anderson

Drew said:
Having trouble with a transparent application icon:

It's black where it should be transparent.

I've soft reset the device many times, but it's still black.

This is strange because I have other transparent
icons which work as expected.

The icons are 32x32 and 16x16 at 256 colors.

I've gone to just coloring in the transparent portions
with white, but this is not ideal.

Any ideas?

Drew


This is a straight forward fix, but I believe you have to convert the
ico to a bmp for it to work correctly?

In class instantiation
----------------------
public static Bitmap bLogo;

In say form load
----------------
bLogo = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().
GetManifestResourceStream("GUIFramework.images.yourimage"));

In your paint event:
-------------------
protected override void OnPaint(PaintEventArgs e)
{
try
{
Graphics g;
g = CreateGraphics();
ImageAttributes att = new ImageAttributes();
// make the white section of the logo transparent so the
// backcolor of form shows through
att.SetColorKey(Color.White ,Color.White );
int h = global_form.bLogo.Height;
int w = global_form.bLogo.Width ;
Rectangle img = new Rectangle( 1,1,w,h );
g.DrawImage( global_form.bLogo,
img,1,1,w,h,GraphicsUnit.Pixel,att);
}
catch {}
}
base.OnPaint (e);
}

That should do the job - in the example I have embedded the image as
part of the EXE. As an enhancement you could load all the images into
a bitmap array and play with that.

good luck

Graeme Anderson
 
D

Drew

Huh?

I'm not trying to draw an image.

This is the icon for the application that you
see in the "programs" folder or with the
file explorer.

I still don't see why one icon would work
with transparency, and another would show
up as black. Could it be something with
the color table of this specific icon?

Drew
 
D

Drew

Lloyd Dupont said:
I had similar problemand used an almost good workaround.
for the application icon I use the XOR color (the computer iwth pink screen)
instead of the transparent one and it gaves me a white background

OK. I tried using the XOR color and it does give a white background.

However, this is still not the same as a transparent background.

Drew
 

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

Similar Threads

Transparent Color in Icons 5
newbie: toolbars icons 3
Icon vs BitMap 2
Icon text background not transparent 1
Icon Question 3
Icon with VS 2003 != VS 2005 ? 7
Problem with Application Icon 2
SP2 Imagelist Bug 7

Top