WPF: use a specific icon image in an image element

How can I make System.Windows.Controls.Image use an image with a given resolution and color depth from a .ico resource?

+3
source share
1 answer

Create a BitmapFrame and use its Decoder. For example, to access a 48-bit 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);
+4
source

Source: https://habr.com/ru/post/1775225/


All Articles