110,536
社区成员
发帖
与我相关
我的任务
分享
public Image GetBitmap(string sId)
{
//System.ComponentModel.ComponentResourceManager resourceManager = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
////ResourceManager resourceManager = new ResourceManager("WindowsApplication", this.GetType().Assembly);
//Bitmap bitmap = (System.Drawing.Bitmap)(resourceManager.GetObject("_"+sId));
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
Image image = ((System.Drawing.Image)(resources.GetObject("_" + sId)));
return image;
}
public Image GetBitmap(string sId)
{
Assembly asm = Assembly.GetExecutingAssembly();
string sResourceName = "WindowsApplication.images." + sId + ".jpg";
Stream sFile = asm.GetManifestResourceStream(sResourceName);
Image img = Image.FromStream(sFile);
return img;
}