3
如何获取System.Windows.Controls.Image以使用来自.ico资源的指定分辨率和颜色深度的图像?WPF:在图像元素中使用特定图标图像
如何获取System.Windows.Controls.Image以使用来自.ico资源的指定分辨率和颜色深度的图像?WPF:在图像元素中使用特定图标图像
创建一个BitmapFrame并使用它的解码器。例如,要访问48x48,32位图像:
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);
感谢Meleak为我提供简洁解决方案的关键类。 – 2010-11-24 15:21:50