.NET에서 DotCode 바코드를 생성하고 인식합니다.

블로그 카테고리: 바코드.NET

2020/08/13

닷코드(DotCode)는 고속 잉크젯 또는 레이저 도트 인쇄 기술로 인쇄할 때 안정적으로 판독되도록 설계된 2차원 도트 코드 심볼입니다.

닷코드 바코드 예시:
Samples of DotCode barcodes

닷코드는 일반적으로 일정한 격자 구조 내의 선택된 위치에 명목상 서로 떨어져 있는 점들의 배열에 데이터를 인코딩하는 바코드의 한 유형입니다. 닷코드는 높이 "H"(행)와 너비 "W"(열)를 가진 직사각형 모양의 도트 배열을 사용합니다. 체스판의 어두운 사각형처럼 가능한 도트 위치의 정확히 절반만 인쇄에 사용 가능합니다.
닷코드 바코드 매트릭스에는 고정 패턴이나 검색 패턴이 없습니다. 데이터 도트 위치 배열 주변에는 최소 3Y 높이 또는 3X 너비의 콰이어트 영역이 있습니다(아래 이미지 참조).

DotCode 바코드 구조:
Structure of DotCode barcode


DotCode의 일반적인 특징:



VintaSoft Barcode .NET SDK는 DotCode 바코드 읽기 및 쓰기를 지원합니다.

다음은 DotCode 바코드를 래스터 이미지로 생성하는 C# 코드입니다.
/// <summary>
/// Generates DotCode barcode as raster image.
/// </summary>
public void GenerateDotCodeBarcodeAsRasterImage()
{
    // create the barcode writer
    Vintasoft.Barcode.BarcodeWriter barcodeWriter = new Vintasoft.Barcode.BarcodeWriter();

    // set barcode writer settings
    barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.DotCode;
    barcodeWriter.Settings.Value = "abc012345def";

    // get a barcode image
    using (System.Drawing.Image image = barcodeWriter.GetBarcodeAsBitmap())
    {
        // save the barcode image to a file
        image.Save("DotCodeBarcode.png");
    }
}


다음은 DotCode 바코드를 벡터 형식으로 생성하는 C# 코드입니다.
/// <summary>
/// Generates DotCode barcode as graphics path.
/// </summary>
public System.Drawing.Drawing2D.GraphicsPath GenerateDotCodeBarcodeAsGraphicsPath()
{
    // create the barcode writer
    Vintasoft.Barcode.BarcodeWriter barcodeWriter = new Vintasoft.Barcode.BarcodeWriter();

    // set barcode writer settings
    barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.DotCode;
    barcodeWriter.Settings.Value = "012345abcde";

    // return barcode as graphics path
    return barcodeWriter.GetBarcodeAsGraphicsPath();
}


다음은 DotCode 바코드를 SVG 이미지로 생성하는 C# 코드입니다.
/// <summary>
/// Generates DotCode barcode as SVG image.
/// </summary>
public string GenerateDotCodeBarcodeAsSvgImage()
{
    // create the barcode writer
    Vintasoft.Barcode.BarcodeWriter barcodeWriter = new Vintasoft.Barcode.BarcodeWriter();

    // set barcode writer settings
    barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.DotCode;
    barcodeWriter.Settings.Value = "012345abcde";

    // return barcode as SVG image
    return barcodeWriter.GetBarcodeAsSvgFile();
}

다음은 이미지에서 DotCode 바코드를 인식하는 C# 코드입니다.
/// <summary>
/// Recognizes DotCode barcode in image.
/// </summary>
public void RecognizeDotCodeBarcode()
{
    // create barcode reader
    using (Vintasoft.Barcode.BarcodeReader reader = new Vintasoft.Barcode.BarcodeReader())
    {
        // specify that reader must search for DotCode barcodes
        reader.Settings.ScanBarcodeTypes = Vintasoft.Barcode.BarcodeType.DotCode;

        // ScanInterval must be lower than dot size of DotCode barcode, in pixels
        reader.Settings.ScanInterval = 3;

        // read barcodes from image file
        Vintasoft.Barcode.IBarcodeInfo[] barcodeInfos = reader.ReadBarcodes("DotCodeCodeBarcode.png");

        // if barcodes are not detected
        if (barcodeInfos.Length == 0)
        {
            Console.WriteLine("Barcodes are not found.");
        }
        // if barcodes are detected
        else
        {
            // get information about recognized barcodes

            Console.WriteLine(string.Format("{0} barcode(s) found:", barcodeInfos.Length));
            Console.WriteLine();
            for (int i = 0; i &lt; barcodeInfos.Length; i++)
            {
                Vintasoft.Barcode.IBarcodeInfo barcodeInfo = barcodeInfos[i];
                Console.WriteLine(string.Format("[{0}:{1}]", i + 1, barcodeInfo.BarcodeType));
                Console.WriteLine(string.Format("Value:      {0}", barcodeInfo.Value));
                Console.WriteLine(string.Format("Region:     {0}", barcodeInfo.Region));
                Console.WriteLine();
            }
        }
    }
}