2

I'm creating icons for my usercontrols using Paint.NET. I'd like to have proper transparency like 32 bit PNG or BMPX provides. Is there a way to achieve that? Looking at the toolbox, the regular Label control does seem to use a fully transparent icon (unless MS assumes an always white toolbox background?).

Currently I'm embedding my icons as bitmaps compiled to embedded resource, and use the ToolboxBitmapAttribute(Type, String) constructor. I tried using ICO or PNG or BMPX, but none of those work at all, they don't even get displayed, whereas a simple BMP does get displayed (using the lower left corner pixel color as transparent color).

takrl
  • 6,356
  • 3
  • 60
  • 69

1 Answers1

3

The built-in Winforms toolbox bitmaps use Color.Fuchsia as the background color. A pretty standard choice as the Bitmap.MakeTransparent() color, it is a nice fuchsed up color that is unlikely to cause unintended transparency in the rest of the image. Here's the one for the Label control, retrieved from the System.Windows.Forms.dll assembly:

enter image description here

It got turned into a PNG while uploading it, it is actually a BMP.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Thanks. I had no idea how to extract the original image from System.Windows.Forms, otherwise I'd probably have checked that first. I remember that color from the VB6 days, it was used for the same purpose back then as well. – takrl Jun 15 '11 at 13:50