62,233
社区成员




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();
}
// Brush brush = Brushes.Black;
SolidBrush brush = new SolidBrush(Color.Black);
改成Brush的子类就没问题了,搞什么飞机。。。ms的bug吗?谁能给解释下什么问题噶。。。
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
try
{
string str = Server.MapPath("~/upload/test.jpg");
System.Drawing.Image myImage = System.Drawing.Image.FromFile(str);
Bitmap map = new Bitmap(myImage);
myImage.Dispose();
Graphics graphics = Graphics.FromImage(map);
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
SolidBrush brush = new SolidBrush(Color.Red);
PointF P = new PointF(100, 100);
Font font = new Font("宋体", 40);
graphics.DrawString("guwei4037", font, brush, P);
map.Save(str.Substring(0, str.LastIndexOf("\\") + 1) + "new" + str.Substring(str.LastIndexOf("\\") + 1, str.LastIndexOf(".") - str.LastIndexOf("\\") - 1) + str.Substring(str.LastIndexOf("."), str.Length - str.LastIndexOf(".")), ImageFormat.Jpeg);
font.Dispose();
graphics.Dispose();
}
catch { }
}
}