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