我使用了条形码字体并使用代码128显示条形码,如何将此条形码保存为图像.. [英] I Have Used A Barcode Font And Displayed A Barcode Using Code 128 And How Can I Save This Barcode As Image..

查看:101
本文介绍了我使用了条形码字体并使用代码128显示条形码,如何将此条形码保存为图像..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将条形码保存为图像?

How can I save the barcode as an image?

推荐答案

请查看下面提到的链接以获取更多信息。



Please check the below mentioned links for more info.

protected void btnGenerate_Click(object sender, EventArgs e)
{
    string barCode = txtCode.Text;
    System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
    using (Bitmap bitMap = new Bitmap(barCode.Length * 40, 80))
    {
        using (Graphics graphics = Graphics.FromImage(bitMap))
        {
            Font oFont = new Font("IDAutomationHC39M", 16);
            PointF point = new PointF(2f, 2f);
            SolidBrush blackBrush = new SolidBrush(Color.Black);
            SolidBrush whiteBrush = new SolidBrush(Color.White);
            graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);
            graphics.DrawString("*" + barCode + "*", oFont, blackBrush, point);
        }
        using (MemoryStream ms = new MemoryStream())
        {
            bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            byte[] byteImage = ms.ToArray();
 
            Convert.ToBase64String(byteImage);
            imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
        }
        plBarCode.Controls.Add(imgBarCode);
    }
}





在ASP.Net中动态生成和显示条形码图像



生成条形码使用C#?




ASP.NET C#项目中的条形码生成


这篇关于我使用了条形码字体并使用代码128显示条形码,如何将此条形码保存为图像..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆