Note: Question http://stackoverflow.com/questions/220465/using-256-x-256-vista-icon-in-application deals with using a "Vista" icon as the application's icon. This question deals with manually painting a Vista icon.
Note: Question http://stackoverflow.com/questions/281999/winforms-net-20-how-to-paint-with-the-proper-icon deals with painting a Vista icon loaded from a file. This question deals with painting a Vista icon that is loaded from a .resource.
i've included an icon in my Visual Studio project that has various formats:
- 16x16
- 32x32
- 48x48
- 256x256 (png compressed)
Now want to draw the 256x256 version. None of the following things i've tried work.
The following draws the 32x32 format stretched to 256x256:
Icon ico = Properties.Resources.TestIconThatHasA256PNGFormat;
e.Graphics.DrawIcon(ico, new Rectangle(0, 0, 256, 256));
The following draws the 32x32 format unstretched:
Icon ico = Properties.Resources.TestIconThatHasA256PNGFormat;
e.Graphics.DrawIconUnstretched(ico, new Rectangle(0, 0, 256, 256));
The following draws the 32x32 format stretched to 256x256:
Icon ico = Properties.Resources.TestIconThatHasA256PNGFormat;
e.Graphics.DrawImage(ico.ToBitmap(), new Rectangle(0, 0, 256, 256));
The following draws the 48x48 format stretched to 256x256:
Icon ico = Properties.Resources.TestIconThatHasA256PNGFormat;
e.Graphics.DrawIcon(
new Icon(ico, new Size(256, 256)),
new Rectangle(0, 0, 256, 256));
How do i draw the 256x256 format icon?
Notes:
The icon is not coming from a file, so PInvoking LoadImage() will not help.
The icon is not the icon associated with a file, so PInvoking SHGetFileInfo() will not help. Nor will using Icon.ExtractAssociatedIcon.
i'm also not trying to author icons with a 256x256 format at runtime, so libraries designed to do that will not help.
[2]: Question http://stackoverflow.com/questions/281999/winforms-net-20-how-to-paint-with-the-proper-icon