views:

37

answers:

1

I need to be able to set an icon on a ToolStripStatusLabel item in a C# Windows Forms application. The item will being displaying an image and text. I assumed that I could use an Icon with such an item but I am mistaken. What is the best way of creating an Image object from an existing Icon object?

the intended code will look something like:

Image image = new Image(); // Get this image somehow from a pre-existing Icon object
serverInfoToolStripStatusLabel.Text = "Connected to server X";
serverInfoToolStripStatusLabel.Image = image;

(NB: serverInfoToolStripStatusLabel is declared as System.Windows.Forms.ToolStripStatusLabel) regards.

A: 

Icon has the ToBitmap method, which will give you a Bitmap, which is an Image

Timores
ToBitmap method works bad (at least on WinXP) when converting icon with alpha-blending.
arbiter
Your're right. The docs mention that the transparent color is mapped to RGB(13,11,12).
Timores