开发者

WPF: Use a specific icon image in an Image element

开发者 https://www.devze.com 2023-01-25 03:41 出处:网络
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 acc

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

精彩评论

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