网上找了一下发现大部分都是关于39的,没事就收集了一些其他方式的……

简单代码(有时间上源码)附件下载

 Bitmap image = new Bitmap(image_width, barMaxHeight + ((int)new Font("@宋体", 13).Height));
            
			using (Graphics dc = Graphics.FromImage(image))
			{
				Rectangle bounds = new Rectangle((image.Width-totalImageWidth)/2, 0, totalImageWidth, barMaxHeight);
				Render(barcode, dc, bounds, interGlyphSpace, barMinHeight, barMinWidth, barMaxWidth);
                
                dc.DrawString(text, new Font("@宋体", 13), Brushes.Black, (image.Width-(int)textPosition.Width)/2, image.Height-(int)textPosition.Height,StringFormat.GenericDefault);
			}
            image.Save(@"G:\barcode.png");
			return image;

调用示例:
        private void button1_Click(object sender, EventArgs e)
        {
            BarcodeDraw draw = null;
            draw = InstallBarcodeDraw(draw);
            pictureBox1.Image = draw.Draw(textBox1.Text, 80);
            //x draw.Draw(textBox1.Text,80).Save(@"G:\barcode.png");
        }

        private BarcodeDraw InstallBarcodeDraw(BarcodeDraw draw)
        {
            switch (comboBox1.Text)
            {
                case "Code11C":
                    draw = BarcodeDrawFactory.GetSymbology(BarcodeSymbology.Code11C); break;
                case "Code39NC":
                    draw = BarcodeDrawFactory.GetSymbology(BarcodeSymbology.Code11NC); break;
//省略……
            }
            return draw;
        }
 Bitmap image = new Bitmap(image_width, barMaxHeight + ((int)new Font("@宋体", 13).Height));
            
using (Graphics dc = Graphics.FromImage(image))
{
Rectangle bounds = new Rectangle((image.Width-totalImageWidth)/2, 0, totalImageWidth, barMaxHeight);
Render(barcode, dc, bounds, interGlyphSpace, barMinHeight, barMinWidth, barMaxWidth);
                
                dc.DrawString(text, new Font("@宋体", 13), Brushes.Black, (image.Width-(int)textPosition.Width)/2, image.Height-(int)textPosition.Height,StringFormat.GenericDefault);
}
            image.Save(@"G:\barcode.png");
return image;
1 Bitmap image = new Bitmap(image_width, barMaxHeight + ((int)new Font("@宋体", 13).Height));
2
3 using (Graphics dc = Graphics.FromImage(image))
4 {
5 Rectangle bounds = new Rectangle((image.Width-totalImageWidth)/2, 0, totalImageWidth, barMaxHeight);
6 Render(barcode, dc, bounds, interGlyphSpace, barMinHeight, barMinWidth, barMaxWidth);
7
8 dc.DrawString(text, new Font("@宋体", 13), Brushes.Black, (image.Width-(int)textPosition.Width)/2, image.Height-(int)textPosition.Height,StringFormat.GenericDefault);
9 }
10 image.Save(@"G:\barcode.png");
11 return image;
posted on 2011-03-19 12:04  穿梭老李  阅读(14474)  评论(38编辑  收藏  举报