在我的应用程序中,我需要将一个
List<MenuItem>
发送到WCF中的shell扩展。这些菜单项由图标和标签组成。图标的类型是System.Drawing.Icon
,但我必须从System.Windows.Media.Imaging.BitmapImage
中进行操作。
有没有一种方法可以将BitmapImage
转换为Icon
?
bmp.Save(stream, ImageFormat.Icon)
在使用ImageFormat参数时会抛出ArgumentNullException异常。所以我使用了一个可行的替代方法:Icon.FromHandle(((Bitmap)bitmap).GetHicon())
,但是颜色有所损失并且颠倒了。 - Akhilleus