0

我需要将 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;

        }
4

1 回答 1

0

试试这个。

Image img = Image.FromFile(xmldoc.SelectSingleNode("ImagesXml/Ad/ImageUrl2").InnerText);     
Bitmap bm = new Bitmap(img);     
Graphics g = Graphics.FromImage (bm); 
于 2012-10-25T10:42:43.150 回答