| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 5384 人关注过本帖
标题:GDI+ 发生一般性错误
只看楼主 加入收藏
z909562139
Rank: 2
等 级:论坛游民
帖 子:32
专家分:87
注 册:2012-11-5
结帖率:75%
  问题点数:0  回复次数:0   
GDI+ 发生一般性错误
程序代码:
for (int i = 0; i < barCodeArray.Length; i++)
            {

                string barCode = barCodeArray[i];

                Code39 _Code39 = new Code39();
                _Code39.Height = 45;
                _Code39.Magnify = 0;
                _Code39.ViewFont = new Font("宋体", 10);
                System.Drawing.Image _CodeImage = _Code39.GetCodeImage(barCode, Code39.Code39Model.Code39Normal, true);
                System.IO.MemoryStream _Stream = new System.IO.MemoryStream();
               // _CodeImage.Save(_Stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                System.Drawing.Bitmap _newImage = new Bitmap(_CodeImage.Width, _CodeImage.Height);
                Graphics copy = Graphics.FromImage(_newImage);
                copy.DrawImage(_CodeImage, 0, 0);
                string p = Server.MapPath("BarCode");
                string n = Guid.NewGuid().ToString();
                string saveUrl = p + "/" + n + ".jpeg";

                _CodeImage.Dispose();
                _Stream.Close();
                _newImage.Save(saveUrl); //报错GDI+发生一般性错误
                _newImage.Dispose();
               

                System.Web.UI.WebControls.Image webImg = new System.Web.UI.WebControls.Image();
                webImg.Height = _CodeImage.Height;
                webImg.Width = _CodeImage.Width;
                webImg.ImageUrl = "BarCode/" + n + ".jpeg";
                //webImg.ImageUrl = "BarCode/" + n + ".png";

                TableRow tabRow = new TableRow();
                table.Rows.Add(tabRow);
                TableCell imgCell = new TableCell();
                imgCell.Controls.Add(webImg);
                tabRow.Cells.Add(imgCell);
            }

            this.Controls.Add(table);
求帮忙
2013-06-07 17:47







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042878 second(s), 7 queries.
Copyright©2004-2019, BCCN.NET, All Rights Reserved