基于C#的BarCode 39实现
2015-05-13 22:40
316 查看
一、39条码简介
39码是1974年发展出来的条码系统,是一种可供使用者双向扫瞄的分散式条码,也就是说相临两资料码之间,必须包含一个不具任何意义的空白(或细白,其逻辑值为0),且其具有支援文字的能力,故较一般一维条码应用广泛,由于CODE 39支持0~9、A~Z等,目前较主要用于,通常运用于资产管理、会员卡、店内码管理、产品卷标等。
标准的39码是由起始安全空间、起始码、资料码、可忽略不计的检查码、终止安全空间及终止码所构成。
二、39码编码
39码的每一个字元编码方式,都是由九条不同排列的线条编码而得。可区分成如表之四种类型:
View Code
(3)效果图
39码是1974年发展出来的条码系统,是一种可供使用者双向扫瞄的分散式条码,也就是说相临两资料码之间,必须包含一个不具任何意义的空白(或细白,其逻辑值为0),且其具有支援文字的能力,故较一般一维条码应用广泛,由于CODE 39支持0~9、A~Z等,目前较主要用于,通常运用于资产管理、会员卡、店内码管理、产品卷标等。
标准的39码是由起始安全空间、起始码、资料码、可忽略不计的检查码、终止安全空间及终止码所构成。
二、39码编码
39码的每一个字元编码方式,都是由九条不同排列的线条编码而得。可区分成如表之四种类型:
private void btnEncode_Click(object sender, EventArgs e) { string input = this.txtInput.Text.Trim(); string txtwidth = this.txtWidth.Text.Trim(); string txtheight = this.txtHeight.Text.Trim(); if (!string.IsNullOrEmpty(input) && !string.IsNullOrEmpty(txtwidth) && !string.IsNullOrEmpty(txtheight)) { this._width = Int32.Parse(txtwidth); this._height = Int32.Parse(txtheight); barCode = new BarCode(input, true, this._height, this._width, true); string codeValue = string.Empty; pb.Image = barCode.GenerateCodeImage(ref codeValue); //reposition the barcode image to the middle pb.Location = new Point((this.pb.Location.X + this.pb.Width / 2) - this.pb.Width / 2, (this.pb.Location.Y + this.pb.Height / 2) - pb.Height / 2); //txtEncoded.Text = codeValue; } else { MessageBox.Show("请输入完整信息"); } } /// <summary> /// 打印生成的条形码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { PrintDialog printDialog = new PrintDialog(); printDialog.Document = printDocument; if (printDialog.ShowDialog(this) == DialogResult.OK) //到这里会出现选择打印项的窗口 { printDocument.Print(); //到这里会出现给文件命名的窗口,点击确定后进行打印并完成打印 } } /// <summary> /// 使用PrintDocument,并且设置相应的事件监听 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { try { if (pb.Image != null) { Rectangle rect = new Rectangle(50, 50, this._width, this._height);//设置打印起始位置和大小 e.Graphics.DrawImage(pb.Image,rect);//确定要打印的图片及其打印起始位置和大小 e.HasMorePages = false; } } catch (Exception ex) { MessageBox.Show("请先生成条形码!"); } } private void btnSaveAsImg_Click(object sender, EventArgs e) { SaveFileDialog saveFdlg = new SaveFileDialog(); saveFdlg.Filter = "*.png|*.jpg"; if (saveFdlg.ShowDialog() == DialogResult.OK) { string fileName = saveFdlg.FileName; barCode.SaveImage(fileName); } }
View Code
(3)效果图
相关文章推荐
- BarCode条形码基于C# GDI+ 的实现
- BarCode条形码基于C# GDI+ 的实现方法详解
- BarCode条形码基于C# GDI+ 的实现.
- BarCode条形码基于C# GDI+ 的实现.
- C#实现IVR(基于东进的语音卡)-2
- 基于无锁的C#并发队列实现(转载)
- 基于c#实现网站的自动登陆
- 《设计模式——基于C#的工程化实现及扩展》
- TCP/IP协议学习(七) 基于C# Socket的Web服务器---动态通讯实现
- 基于C#实现的仿windows左侧伸缩菜单效果
- 【转载】基于C#的socket编程的TCP同步实现
- C# 基于SharpZipLib 实现 文件压缩,以及解压
- 用C#实现基于用C#实现基于TCP协议的网络通讯
- 基于读取车载RFID标签自动开关车库门c#算法实现
- 基于ASP.NET MVC(C#)和Quartz.Net组件实现的定时执行任务调度
- C#基于Linq和反射实现数据持久化框架Xml4DB
- [每周特惠] 设计模式——基于C#的工程化实现及扩展+博客园2010T恤
- [C# 网络编程系列]专题十一:实现一个基于FTP协议的程序——文件上传下载器
- c#实现基于Tcp协议的网络通讯
- 基于c#实现的九九乘法表(简单实例)