我需要将xml图像路径传递给位图。我有一个xml文件,其中我有应用程序中使用的所有图像路径。下面是代码。我得到无效的参数错误。
protected void Button1_Click(object sender, EventArgs e)
{
XmlDocument xmldoc = new XmlDocument();
string file = HttpContext.Current.Server.MapPath("XMLFile1.xml");
xmldoc.Load(file);
string path = xmldoc.SelectSingleNode("ImagesXml/Ad/ImageUrl2").InnerText;
Bitmap b = new System.Drawing.Bitmap(xmldoc.SelectSingleNode("ImagesXml/Ad/ImageUrl2").InnerText);
Graphics g = Graphics.FromImage(b);
MemoryStream memStream = new MemoryStream();
g.SmoothingMode = SmoothingMode.AntiAlias;
}
答案 0 :(得分:0)
试试这个。
Image img = Image.FromFile(xmldoc.SelectSingleNode("ImagesXml/Ad/ImageUrl2").InnerText);
Bitmap bm = new Bitmap(img);
Graphics g = Graphics.FromImage (bm);