使用GDI+绘图new Bitmap()的时候出错,
大山里的松 2007-08-13 12:34:51 这是一个asp.net的应用,并且将网站的bin\*.dll都更新后需要过好长一段时间才出现无法new bitmap() 的错误,未将对象引用设置到对象实例。
我尝试在一个测试程序中用循环来不停的new bitmap()但是除了把iis崩溃掉以外并没有出现仅仅是无法画图而其他都正常的情况。
这个困扰了我很久,因为我在本机调试的时候从来不出错,放到远程服务器上积累一段时间才会出错,敬请高手们指教 分不够可以另外开帖子加分
具体代码如下,创建的位图稍微有些大5000x3000像素,
Bitmap bm = null;
Graphics g = null;
try
{
bm = new Bitmap(this.width, this.height);
g = Graphics.FromImage(bm);
g.CompositingQuality = CompositingQuality.HighQuality;
DrawPanel(g);
this.DrawFrame(g);
this.DrawTitle(g);
if (this.isDrawBackground) DrawBackground(g);
DrawYieldChart(g);
DrawLegend(g);
HttpContext hc = HttpContext.Current;
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
bm.Save(memStream, System.Drawing.Imaging.ImageFormat.Png);
hc.Response.OutputStream.Write(memStream.ToArray(), 0, (int)memStream.Length);
}
finally
{
g.Dispose();
bm.Dispose();
}