I'm developing a program that makes use of Windows 7 (and Vista) taskbar features. Right now I have a custom bitmap that will be shown in the taskbar thumbnail. The bitmap is created programmatic and shows up successfully. The only 'problem' I'm having is that want to use transparent in that image, which should show transparent in the thumbnail too. But without any success, resulting in the standard Light-Gray color.
I've seen evidence that programs successfully get transparent in the their images:
- http://blog.miranda.or.at/wp-content/uploads/2010/05/taskbar.png
- http://www.addictivetips.com/wp-content/uploads/2010/04/TaskbarRSS.png
- http://www.addictivetips.com/wp-content/uploads/2009/10/Thumbnail1.png
Now is my question: how do I get transparent in my thumbnail image?
I'll be filling the image with the Graphics
class, so anything is allowed.
I should mention that I use Windows® API Code Pack, which uses GetHbitmap
to
set the image as thumbnail.
EDIT:
Just to make it complete, this is the code I'm using atm:
Bitmap bmp = new Bitmap(197, 119);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(0, 0, bmp.Width, bmp.Height)); // Transparent is actually light-gray;
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
g.DrawString("Information:", fontHeader, brush, new PointF(5, 5));
bmp.MakeTransparent(Color.Red);
return bmp;
What pixel format is your Bitmap? If it has no alpha channel, you won't be able to store transparency information in your image.
Here is how to create a bitmap with an alpha channel and make it transparent by default:
You can then draw anything you want, including semi transparent stuff using the alpha channel.
Also note that if you are trying to paint transparency over existing opaque stuff (say to make a hole), you need to change compositing mode:
This will make whatever color you use to overwrite the one in the image rather than blending with it.