交叉二五碼實(shí)驗(yàn)報(bào)告_第1頁
交叉二五碼實(shí)驗(yàn)報(bào)告_第2頁
交叉二五碼實(shí)驗(yàn)報(bào)告_第3頁
交叉二五碼實(shí)驗(yàn)報(bào)告_第4頁
交叉二五碼實(shí)驗(yàn)報(bào)告_第5頁
已閱讀5頁,還剩9頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、交叉二五碼實(shí)驗(yàn)報(bào)告專 業(yè) 班 級 姓 名 學(xué) 號 課 程 物流供應(yīng)鏈管理與編碼技術(shù)指導(dǎo)教師 一、實(shí)驗(yàn)題目交叉二五碼實(shí)驗(yàn)二、實(shí)驗(yàn)?zāi)康氖煜げ⒄莆战徊娑宕a的編碼方式,在編碼實(shí)驗(yàn)的過程中體現(xiàn)編碼原則,最終生成交叉二五碼。三、實(shí)驗(yàn)原理交叉25碼是一種高密度的,可以嵌入任意數(shù)量數(shù)字的,長度可變化的數(shù)字條形碼。該條形碼是基于標(biāo)準(zhǔn)25碼的規(guī)范改進(jìn)而得來,它比標(biāo)準(zhǔn)25碼有更高的密度與數(shù)據(jù)存儲能力。交叉25碼主要運(yùn)用在物流行業(yè)與倉儲業(yè)中。標(biāo)準(zhǔn)25碼只用黑色條碼代表數(shù)字0-9,而交叉25碼既使用黑色條碼也使用白色條碼來代表0-9的數(shù)字。例如,標(biāo)準(zhǔn)25碼會用前五個(gè)黑色條碼表示第一個(gè)數(shù)字,用緊接著的五個(gè)黑色條碼表示第

2、二個(gè)數(shù)字;而交叉25碼是使用前五條黑色條碼表示第一個(gè)數(shù)字,而用介于前五個(gè)黑色條碼中的白色條碼表示第二個(gè)數(shù)字。這也是交叉25碼名稱的來源。交叉25碼是連續(xù)型、非定長、具有自動校驗(yàn)功能的雙向條碼,交叉25碼的編碼是以兩個(gè)字符為一組(上下各一個(gè))進(jìn)行編碼,其中一個(gè)字符以條編碼,另一個(gè)字符以空編碼,每個(gè)字符由5個(gè)單元組成(3個(gè)窄單元,2個(gè)寬單元),兩個(gè)字符的條空相互交叉組合在一起。交叉25碼的起始符為:窄條-窄空-窄條-窄空,0000交叉25碼的終止符為:寬條-窄空-窄條,100交插25碼的字符集包括數(shù)字0到9如下圖示:起始符:0000,非條碼字符 ,終止符:100,非條碼字符。奇數(shù):條;偶數(shù)位:空字

3、符集;數(shù)字09寬度調(diào)節(jié)編碼法:編碼方法以窄單元(條或空)表示邏輯值“0”,寬單元(條或空)表示邏輯值“1”。寬單元通常是窄單元的23倍。09與條或空的關(guān)系分析例子如下:0偶數(shù)位用空表示:窄窄寬寬窄 001101奇數(shù)位用條表示:寬窄窄窄寬 100012偶數(shù)位用空表示:窄寬窄窄寬 010013奇數(shù)位用條表示:寬寬窄窄窄 110004偶數(shù)位用空表示:窄窄寬窄寬 001015奇數(shù)位用條表示:寬窄寬窄窄 101006奇數(shù)位用空表示:窄寬寬窄窄 011007奇數(shù)位用條表示:窄窄窄寬寬 000118偶數(shù)位用空表示:寬窄窄寬窄 100109奇數(shù)位用條表示:窄寬窄寬窄 01010總結(jié):起始0000 110001

4、 201001 311000 400101510100 601100 700011 810010 901010000110 終止100四、實(shí)驗(yàn)步驟1. 先打開visual c+并新建項(xiàng)目。在lib目錄下輸入編好的代碼,如下圖:2.點(diǎn)擊運(yùn)行調(diào)試3.輸入我的學(xué)號“2011115040415”后點(diǎn)擊Encode按鍵,生成一個(gè)交叉二五碼:五、實(shí)驗(yàn)主要代碼1.Program.cs :using System;using System.Collections.Generic;using System.Windows.Forms;namespace Barcoder static class Program

5、 / / The main entry point for the application. / STAThread static void Main() Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(); 2.MainForm.cs :using System;using System.Collections.Generic;using System.ComponentModel;using System.

6、Data;using System.Drawing;using System.Text;using System.Windows.Forms;using BarcoderLib;namespace Barcoder public partial class MainForm : Form public MainForm() InitializeComponent(); private void exitToolStripMenuItem_Click(object sender, EventArgs e) this.Close(); private void aboutToolStripMenu

7、Item_Click(object sender, EventArgs e) AboutBox aboutBox1 = new AboutBox(); aboutBox1.ShowDialog(); private void MainForm_Load(object sender, EventArgs e) private void cmdEncode_Click(object sender, EventArgs e) cmdSave.Enabled = false; try switch (cboFormat.Text.Trim() case Interleaved 2 of 5: Barc

8、odeInter2of5 encoderInter2of5 = new BarcodeInter2of5(); picOutput.Image = encoderInter2of5.Encode(txtMessage.Text.Trim(); cmdSave.Enabled = true; break; catch (Exception ex) MessageBox.Show(ex.Message, Error, MessageBoxButtons.OK); private void cmdSave_Click(object sender, EventArgs e) saveFileDialo

9、g1.ShowDialog(); if (saveFileDialog1.FileName != ) / Saves the Image via a FileStream created by the OpenFile method. System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile(); / Saves the Image in the appropriate ImageFormat based upon the / File type selected in the dialog box. /

10、NOTE that the FilterIndex property is one-based. switch (saveFileDialog1.FilterIndex) case 1: picOutput.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg); break; case 2: picOutput.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Bmp); break; case 3: picOutput.Image.Save(fs, System.Drawing.Ima

11、ging.ImageFormat.Gif); break; fs.Close(); private void cboFormat_SelectedIndexChanged(object sender, EventArgs e) if (cboFormat.SelectedItem.ToString().Trim() = MSI) cboModulo.Visible = true; if (cboModulo.SelectedItem.ToString() = Modulo 11) | (cboModulo.SelectedItem.ToString() = Modulo 1011) | (cb

12、oModulo.SelectedItem.ToString() = Modulo 1110) cboWeightType.Visible = true; else cboWeightType.Visible = false; else cboModulo.Visible = false; cboWeightType.Visible = false; private void cboModulo_SelectedIndexChanged(object sender, EventArgs e) if (cboModulo.SelectedItem.ToString() = Modulo 11) |

13、 (cboModulo.SelectedItem.ToString() = Modulo 1011) | (cboModulo.SelectedItem.ToString() = Modulo 1110) cboWeightType.Visible = true; else cboWeightType.Visible = false; 3.BarcodeInter2of5.cs :using System;using System.Collections.Generic;using System.Text;using System.Drawing;using System.Text.Regul

14、arExpressions;namespace BarcoderLib public class BarcodeInter2of5 private string gLeftGuard = 1010; private string gRightGuard = 01101; private string gOdd = 1011001, 1101011, 1001011, 1100101, 1011011, 1101101, 1001101, 1010011, 1101001, 1001001 ; private string gEven = 0100110, 0010100, 0110100, 0

15、011010, 0100100, 0010010, 0110010, 0101100, 0010110, 0110110 ; public Bitmap Encode(string message) string encodedMessage; Bitmap barcodeImage = new Bitmap(250, 100); Graphics g = Graphics.FromImage(barcodeImage); Validate(message); encodedMessage = EncodeBarcode(message); PrintBarcode(g, encodedMes

16、sage, message, 350, 100); return barcodeImage; private void Validate(string message) Regex reNum = new Regex(d+$); if (reNum.Match(message).Success = false) throw new Exception(Encode string must be numeric); private void PrintBarcode(Graphics g, string encodedMessage, string message, int width, int

17、 height) SolidBrush whiteBrush = new SolidBrush(Color.White); SolidBrush blackBrush = new SolidBrush(Color.Black); Font textFont = new Font(FontFamily.GenericMonospace, 10, FontStyle.Regular); g.FillRectangle(whiteBrush, 0, 0, width, height); int xPos = 20; int yTop = 10; int barHeight = 50; for (in

18、t i = 0; i encodedMessage.Length; i+) if (encodedMessagei = 1) g.FillRectangle(blackBrush, xPos, yTop, 1, barHeight); xPos += 1; xPos = 20; yTop += barHeight - 2; for (int i = 0; i message.Length; i+) g.DrawString(messagei.ToString().Trim(), textFont, blackBrush, xPos, yTop); xPos += 7; private string EncodeBarcode(string message) int i; string encodedString = gLeftGuard; for (i = 0; i message.Length; i+) if (i % 2) = 0) encodedString += gOddConvert.ToInt32(messagei.ToString(); else encodedString += gEvenConvert.ToInt32(messagei.ToString(); encodedString += gRightGuard; return en

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論