本文实例讲述了C#生成条形码图片的简单方法。分享给大家供大家参考。具体实现方法如下:
 
 实现原理:
 
 其实Windows本身就有一个字体是用来显示条形码的。
 
 只要将数字改为这种字体就变成了条形码。
 windows字体库下,有如下八种字体可以用来将数字转换成条形码:
 
 Code39AzaleaNarrow1
 
 Code39AzaleaNarrow2
 
 Code39AzaleaNarrow3
 
 Code39AzaleaRegular1
 
 Code39AzaleaRegular2
 
 Code39AzaleaWide1
 
 Code39AzaleaWide2
 
 Code39AzaleaWide3
 把代码贴给大家参考:
 
 代码如下:
 Bitmap b=new Bitmap(200,200);
 
Graphics g = Graphics.FromImage(b);
 
Font font = new Font(“Code39AzaleaRegular2”, 32);
 
g.DrawString(“123456”, font, Brushes.Black, new PointF(100,100));
 
pictureBox1.BackgroundImage = b;
 
pictureBox1.BackgroundImageLayout = ImageLayout.Zoom
Graphics g = Graphics.FromImage(b);
Font font = new Font(“Code39AzaleaRegular2”, 32);
g.DrawString(“123456”, font, Brushes.Black, new PointF(100,100));
pictureBox1.BackgroundImage = b;
pictureBox1.BackgroundImageLayout = ImageLayout.Zoom
希望本文所述对大家的C#程序设计有所帮助。
 
        
