Icon::ToBitmap Method ()
Assembly: System.Drawing (in System.Drawing.dll)
The transparent areas of the icon are lost when it is converted to a bitmap, and the transparent color of the resulting bitmap is set to RGB(13,11,12). The returned bitmap has the same height and width as the original icon.
Note |
|---|
Beginning with framework version 4.6 support was added for PNG frames in .ico files. Applications that target earlier versions of the framework but are running on the 4.6 bits can opt in into the new behavior by adding the following line to the <runtime> section of the app.config file:<AppContextSwitchOverrides value="Switch.System.Drawing.DontSupportPngFramesInIcons=false" /> |
The following code example demonstrates how to use the ToBitmap method. This example is designed to be used with Windows Forms. Create a form and paste the following code into it. Call the IconToBitmap method in the form's .Paint event handler, passing e as PaintEventArgs .
private: void IconToBitmap( PaintEventArgs^ e ) { // Construct an Icon. System::Drawing::Icon^ icon1 = gcnew System::Drawing::Icon( SystemIcons::Exclamation,40,40 ); // Call ToBitmap to convert it. Bitmap^ bmp = icon1->ToBitmap(); // Draw the bitmap. e->Graphics->DrawImage( bmp, Point(30,30) ); }
Available since 1.1
