前台:'/>
后台:
///
/// 创建图像
///
///
public void CreateImage(string str)
{
if (str == "")
{
return;
}
Bitmap image = new Bitmap((int)(str.Length * 30), 50);
Graphics g = Graphics.FromImage(image);
Random random = new Random();
g.Clear(Color.White);
try
{
//画字符串
Font face = new Font("C39HrP48DlTt", 50, FontStyle.Regular);
SolidBrush brush = new SolidBrush(Color.Black);
g.DrawString(str, face, brush, 2, 2);
//输出
MemoryStream ms = new MemoryStream();
image.Save(ms, ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/gif";
Response.BinaryWrite(ms.ToArray());
}
finally
{
image.Dispose();
g.Dispose();
}
}
报错:编译器错误信息: CS1502: 与“System.Convert.ToString(object, System.IFormatProvider)”最匹配的重载方法具有一些无效参数
inghot 说的是对的,但是返回类型是string的话,那么页面就只有response的内容了,其他的都没了....
|