欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C# 如何生成 DataMatrix 格式的二維碼

 更新時(shí)間:2021年11月03日 10:28:30   作者:艾野草  
該文主要是利用OnBarcode.dll 生成DataMatrix 格式的二維碼的一些簡(jiǎn)單方法和操作技巧,對(duì)C# 如何生成 DataMatrix 格式的二維碼相關(guān)知識(shí)感興趣的朋友一起看看吧

該文主要是利用OnBarcode.dll 生成DataMatrix 格式的二維碼的一些簡(jiǎn)單方法和操作技巧。關(guān)于QrBarcode的二維碼比較常見和簡(jiǎn)單,網(wǎng)上有很多資源。

1、附件為dll

2、利用上述控件生成二維碼的核心代碼:

(a)C#代碼:

 DataMatrix datamatrix = new DataMatrix();
   datamatrix.Data = "0123456789";
	        
   // Create Data Matrix and encode barcode to Jpeg format
   datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
   datamatrix.drawBarcode("C://csharp-datamatrix.jpg");

(b)VB.NET代碼:

 Dim datamatrix As OnBarcode.Barcode.DataMatrix
   datamatrix = New OnBarcode.Barcode.DataMatrix()
   datamatrix.Data = "0123456789"
	        
   ' Create Data Matrix and encode barcode to Jpeg format
   datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
   datamatrix.drawBarcode("C://vbnet-datamatrix.jpg")

(c)其他函數(shù)接口(分別是C#和VB):

public void drawBarcode(Graphics graphics);

   public void drawBarcode(string filename);

   public Bitmap drawBarcode();

   public void drawBarcode(Stream fileStream);
   Public Sub drawBarcode(ByRef graphics As Graphics)

   Public Sub drawBarcode(ByVal filename As String)

   Public Function drawBarcode() As Bitmap

   Public Sub drawBarcode(ByRef fileStream As Stream)

3、實(shí)踐部分:

創(chuàng)建如下界面:按鈕按下,生產(chǎn)條碼。

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using OnBarcode.Barcode;

using System.Drawing.Imaging;

namespace DataMatrix1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

        {

            DataMatrix datamatrix = new DataMatrix();

            // Barcode data to encode

            datamatrix.Data = "OnBarcode";

            // Data Matrix data mode

            datamatrix.DataMode = DataMatrixDataMode.ASCII;

            // Data Matrix format mode

            datamatrix.FormatMode = DataMatrixFormatMode.Format_10X10;

            /*

            * Barcode Image Related Settings

            */

            // Unit of meature for all size related setting in the library. 

            datamatrix.UOM = UnitOfMeasure.PIXEL;

            // Bar module size (X), default is 3 pixel;

            datamatrix.X = 3;

            // Barcode image left, right, top, bottom margins. Defaults are 0.

            datamatrix.LeftMargin = 0;

            datamatrix.RightMargin = 0;

            datamatrix.TopMargin = 0;

            datamatrix.BottomMargin = 0;

            // Image resolution in dpi, default is 72 dpi.

            datamatrix.Resolution = 72;

            // Created barcode orientation. 

            // Rotate0 = 0,

            // Rotate90 = 1,

            // Rotate180 = 2,

            // Rotate270 = 3,

            // 4 options are: facing left, facing right, facing bottom, and facing top

            datamatrix.Rotate = Rotate.Rotate0;

            // Geneat data matrix and encode barcode to gif format

            datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Bmp;

            datamatrix.drawBarcode("C:\\datamatrix.jpg");   //以保存特定格式方法生產(chǎn)二維碼

            //You can also call other drawing methods to generate barcodes

            //public void drawBarcode(Graphics graphics);

            //public void drawBarcode(string filename);

            //public Bitmap drawBarcode();

            //public void drawBarcode(Stream stream);       //將該種編碼的格式,寫入文件流之中

            this.pictureBox1.Image = datamatrix.drawBarcode();  //調(diào)用其中一個(gè)接口,將圖片以bitmap形式顯示出來

        }

    }

}

測(cè)試結(jié)果:

當(dāng)初只是隨便分享一下,沒想到大家使用條碼的這么多,評(píng)論也有很多,謝謝大家支持。

這里附上幾個(gè)條碼常用的dll。

可在這里下載:https://i.cnblogs.com/Files.aspx

事實(shí)上:生成條碼的方法有很多種,庫(kù)也有很多,大家可以多去琢磨琢磨,不能局限一種,就我所知所用過的就有五個(gè)庫(kù)。

網(wǎng)上也有很多對(duì)條碼底層的開源研究,可自行。

到此這篇關(guān)于C# 如何生成 DataMatrix 格式的二維碼的文章就介紹到這了,更多相關(guān)C# DataMatrix 格式二維碼內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • C#關(guān)鍵字Check簡(jiǎn)單介紹

    C#關(guān)鍵字Check簡(jiǎn)單介紹

    這篇文章主要介紹了C#關(guān)鍵字Check功能描述及注意事項(xiàng),checke關(guān)鍵字主要用于對(duì)整型類型算術(shù)運(yùn)算和轉(zhuǎn)換顯式啟用溢出檢查,本文通過程序演示給大家詳細(xì)介紹,需要的朋友一起看看吧
    2022-04-04
  • C#中的尾遞歸與Continuation詳解

    C#中的尾遞歸與Continuation詳解

    這篇文章主要介紹了C#中的尾遞歸與Continuation詳解,本文講解了遞歸與尾遞歸、尾遞歸與Continuation、Continuation的改進(jìn)等內(nèi)容,需要的朋友可以參考下
    2015-06-06
  • 詳解C#多線程編程之進(jìn)程與線程

    詳解C#多線程編程之進(jìn)程與線程

    這篇文章主要介紹了詳解C#多線程編程之進(jìn)程與線程的的相關(guān)資料,文中講解非常細(xì)致,代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-06-06
  • WPF實(shí)現(xiàn)繪制3D圖形的示例代碼

    WPF實(shí)現(xiàn)繪制3D圖形的示例代碼

    WPF的3D功能可以在不編寫任何c#代碼的情況下進(jìn)行繪制,只需要使用xaml即可完成3D圖形的渲染。本文主要講述了WPF-3D中的關(guān)鍵概念, 以及常用到的命中測(cè)試、2d控件如何在3D對(duì)象中進(jìn)行渲染,希望大家有所幫助
    2023-03-03
  • C#遞歸實(shí)現(xiàn)回文判斷算法

    C#遞歸實(shí)現(xiàn)回文判斷算法

    這篇文章主要介紹了C#遞歸實(shí)現(xiàn)回文判斷算法,方法簡(jiǎn)單實(shí)用,需要的朋友可以參考下
    2014-10-10
  • 淺析C# 函數(shù)的傳值與傳址

    淺析C# 函數(shù)的傳值與傳址

    這篇文章主要介紹了C# 函數(shù)的傳值與傳址,幫助大家更好的理解和學(xué)習(xí)c#,感興趣的朋友可以了解下
    2020-11-11
  • Unity3D創(chuàng)建圓柱體的方法

    Unity3D創(chuàng)建圓柱體的方法

    這篇文章主要為大家詳細(xì)介紹了Unity3D創(chuàng)建圓柱體的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-02-02
  • C# 中使用 Exceptionless的方法

    C# 中使用 Exceptionless的方法

    這篇文章主要介紹了C# 中使用 Exceptionless的方法,幫助大家更好的理解和使用c#,感興趣的朋友可以了解下
    2020-12-12
  • Unity實(shí)現(xiàn)蘋果手機(jī)Taptic震動(dòng)

    Unity實(shí)現(xiàn)蘋果手機(jī)Taptic震動(dòng)

    這篇文章主要介紹了Unity實(shí)現(xiàn)蘋果手機(jī)Taptic震動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-10-10
  • C#8.0默認(rèn)接口實(shí)現(xiàn)的詳細(xì)實(shí)例

    C#8.0默認(rèn)接口實(shí)現(xiàn)的詳細(xì)實(shí)例

    Microsoft使用C#8.0發(fā)布了許多新功能,他們引入的主要功能之一是默認(rèn)接口方法。這篇文章主要給大家介紹了關(guān)于C#8.0默認(rèn)接口實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下
    2021-05-05

最新評(píng)論