public void WriteImage(User,UserFont,fsUser,UserColor)
{
Font fUser = new Font(UserFont, 9, fsUser);
Brush b = new SolidBrush(UserColor);g.DrawString(User, fUser, b, new Point(260, 60));
// 质量监控
System.Drawing.Imaging.EncoderParameter p;
System.Drawing.Imaging.EncoderParameters ps;
ps = new System.Drawing.Imaging.EncoderParameters(1);
p = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 90L); /*100L 无损*/
ps.Param[0] = p;
System.Drawing.Image image = bitmap as System.Drawing.Image;
byte[] imagebytes = ImgToByt(image);
//将imagebytes 加入数据库
//读取 imagebytes 显示图片
byte[] byteimg = Signature.SelectImage(id);
if (byteimg == null)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('无!')</script>");
}
else
{
Response.ContentType = "image/jpeg";
Response.BinaryWrite(byteimg);
}
}
public static byte[] ImgToByt(System.Drawing.Image img)
{
MemoryStream ms = new MemoryStream();
byte[] imagedata = null;
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
imagedata = ms.GetBuffer();
return imagedata;
}
public static System.Drawing.Image BytToImg(byte[] byt)
{
MemoryStream ms = new MemoryStream(byt);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
return img;
}