如何从.ico资源获取System.Windows.Controls.Image以使用指定分辨率和颜色深度的图像?
创建位图帧并使用其解码器。例如,要访问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);