C# barcode生成代码
protected void Page_Load(object sender, EventArgs e) { string code = Request.Params["code"]; if (string.IsNullOrEmpty(code)) { code = "*123456789*"; } Bitmap bitMap = new Bitmap(1700, 300); Graphics g = Graphics.FromImage(bitMap); Font font = new Font("C39HrP36DmTt", 200, FontStyle.Regular); Font fontKaitiLarge = new Font("KaiTi", 24, FontStyle.Regular); Font fontKaitiSmail = new Font("KaiTi", 18, FontStyle.Regular); SolidBrush b = new SolidBrush(Color.White);//这里修改颜色 g.FillRectangle(b, 0, 0, 1700, 1000); g.DrawString(code, font, Brushes.Black, new PointF(0, 0)); MemoryStream ms = new MemoryStream(); bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Response.ClearContent(); Response.ContentType = "image/Jpeg"; Response.BinaryWrite(ms.ToArray());//这里的Write改成BinaryWrite即可 Response.End(); }