(zxing.net)一维码Codabar的简介、实现与解码

一、简介

一维码Codabar:由4条黑色线条,3条白色线条,合计7条线条所组成,每一个字元与字元之间有一间隙Gap做区隔。

 条形码Codabar包含21个字元:

(1)、10个数字0~9;

(2)、”+”, ”-”,”*”, ”/”, ”$”, .”, ”:”等7个特殊符号;

(3)、A、B、C、D四个英文字母。

Codabar编码方式与125码及Code 39码相同,只有二种粗细比例。

Codabar其起始码/结束码有4*4=16种组合。

Codabar一般应用于物料管理、图书馆、血站和当前的机场包裹发送中,空白区比窄条宽10,非连续性条形码,每个字符表示为4条3空。

二、实现

 1         public ActionResult CODABAR()
 2         {
 3             EncodingOptions options = new EncodingOptions();
 4             options.PureBarcode = false; //是否将内容字符串显示在图片上。false 为显示 true为不显示
 5             options.GS1Format = true;    //是否符合GS1,对CODABAR好像没用
 6             options.Width = 150;    //图片宽度,根据内容的长度会自动增长
 7             options.Height = 75;    //图片高度
 8             options.Margin = 30;    //填充,在图片左右填充空白 30则左右各15
 9 
10             BarcodeWriter writer = new BarcodeWriter();
11             writer.Format = BarcodeFormat.CODABAR;
12             writer.Options = options;
13 
14             //如需设置图片为其它颜色,文字样式,使用此段代码
15             //BitmapRenderer renderer = new BitmapRenderer();
16             //renderer.Foreground = Color.Black;    //前景色
17             //renderer.Background = Color.White;    //背景色
18             //renderer.TextFont = new Font(FontFamily.GenericSansSerif,10);     //内容字体
19             //writer.Renderer = renderer;
20 
21             Bitmap bmp = writer.Write("12345678911111");
22             MemoryStream ms = new MemoryStream();
23             bmp.Save(ms, ImageFormat.Png);
24             ms.Flush();
25             ms.Position = 0;
26             return File(ms, "application/x-png");
27         }

测试图像如下:

      

三、解码

   正在实现中

猜你喜欢

转载自www.cnblogs.com/weiweixiang/p/Barcode_Codabar.html
今日推荐