在網(wǎng)上看到一些人寫關(guān)于條形碼的代碼都很長(zhǎng),有的甚至拿來(lái)賣,所以查了下資料,希望能對(duì)大家有幫助。
我的實(shí)現(xiàn)原理是:
其實(shí)Windows本身就有一個(gè)字體是用來(lái)顯示條形碼的。
只要將數(shù)字改為這種字體就變成了條形碼。
windows字體庫(kù)下,有如下八種字體可以用來(lái)將數(shù)字轉(zhuǎn)換成條形碼:
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。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注