该方法必须先把图片加入到资源resources里:
动态加载bmp格式的图片
private
System.Drawing.Bitmap GetResourceBitmap(
string
strImageName)
{
object
obj = Properties.Resources.ResourceManager.GetObject(strImageName, Properties.Resources.Culture );
return
((System.Drawing.Bitmap)(obj));
}
private
System.Drawing.Image GetResourceImage(
string
strImageName)
{
object
obj = Properties.Resources.ResourceManager.GetObject(strImageName, Properties.Resources.Culture );
return
((System.Drawing.Image)(obj));
}
示例
pictureBox1.Image = GetResourceImage("image001");//不需要带后缀名