In my application I have to send a List<MenuItem>
to my shell extension in WCF. These MenuItems are composed of an icon and a label. The type of the icon is System.Drawing.Icon
but I have to work from System.Windows.Media.Imaging.BitmapImage
.
Is there a way to convert BitmapImage
to Icon
?
Asked
Active
Viewed 5,623 times
4
2 Answers
5
My thoughts:
First comvert BitmapImage to Bitmap
Converting BitmapImage to Bitmap and vice versa
then save as Icon
http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/4a10d440-707f-48d7-865b-1d8804faf649/
Hope this helps!
-
`bmp.Save(stream, ImageFormat.Icon)` throw an ArgumentNullException with the ImageFormat parameter. So I used this method in place that works : `Icon.FromHandle(((Bitmap)bitmap).GetHicon())` but there is a loss of color and they are reversed. – Akhilleus Jun 28 '12 at 15:39
-
Is there any color loss if you save it as bmp or png file? – mortb Jun 29 '12 at 08:16
0
Haven’t created icons myself this way but perhaps you could benefit from going from Graphics to Icon. Then you can select interpolation mode (which perhaps could be nice). See an example here: http://www.dreamincode.net/code/snippet1684.htm

Oleksandr Fentsyk
- 5,256
- 5
- 34
- 41