我已經設置訪問一個嵌入式資源並返回一個System.Drawing.Image,但我不能用它來設置畫布的背景。訪問嵌入式圖像並創建一個System.Windows.Controls.Image
有人請告訴我如何訪問一個嵌入式圖像文件並創建一個System.Windows.Controls.Image。代碼我至今是:
public static Image Load(Type classType, string resourcePath)
{
Assembly asm = Assembly.GetAssembly(classType);
Stream imgStream = asm.GetManifestResourceStream(resourcePath);
Image img = Image.FromStream(imgStream);
imgStream.Close();
return img;
}
請讓我知道如果你需要了信息
你試過嗎? http://stackoverflow.com/questions/7346282/creating-images-from-an-embedded-resource – paul
Im努力將它與我的情況聯繫起來,因爲資源不在相同的dll中,而是嵌入在類類型參數中。一個代碼示例將幫助我極大地 – user589195
我可以問爲什麼你需要一個'System.Drawing.Image'如果你想要做的是設置一個WPF畫布的背景,那麼有更簡單的方法 – paul