开发者

WPF: Use a specific icon image in an Image element

How do I get a System.Windows.Controls.Image to use an image of a specified re开发者_运维问答solution and color depth from a .ico resource?


Create a BitmapFrame and use its Decoder. For example, to access a 48x48, 32-bit image:

BitmapFrame icon = BitmapFrame.Create(new Uri("pack://application:,,,/Resources/Icon.ico", UriKind.Absolute));
BitmapFrame image = icon.Decoder.Frames.First(f => f.PixelHeight == 48 && f.Format.BitsPerPixel == 32);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜