Asp.net 绘图“参数无效”的错误

常见问题与解答 2021-03-01 10:15:04 19

摘要

publicvoidProcessRequest(HttpContextcontext){Bitmapnbitmap=newBitmap(1000,1000);Graphicsg=Graphics.FromImage(nbitmap);Fontfont=newFont(FontFamily.GenericSansSerif,10,FontStyle.Italic);Brushbrush=Brushes.Black;g.DrawString("测试字符串",font,brush……

public void ProcessRequest(HttpContext context)



{


Bitmap nbitmap = new Bitmap(1000, 1000);


Graphics g = Graphics.FromImage(nbitmap);




Font font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Italic);


Brush brush = Brushes.Black;


g.DrawString("测试字符串", font, brush, 10, 10);/////运行到这句报参数无效


g.Dispose();


font.Dispose();


brush.Dispose();


nbitmap.Save(context.Server.MapPath("~/upload/cert" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg"));


nbitmap.Dispose();


}


评论(0)
1422369665