Get Barcode128 Dimension from Vintasoft

Questions, comments and suggestions concerning VintaSoft Barcode .NET SDK.

Moderator: Alex

IAmByB
Posts: 15
Joined: Thu Jan 19, 2017 2:01 pm

Get Barcode128 Dimension from Vintasoft

Post by IAmByB » Fri Jan 20, 2017 1:49 pm

Hello,

I am trying to develop an application in C# / Windows Form with Vintasoft to read a barcode 128 and know the Dimension (min width of narrow black bar).
For this I use the above code, but I do not find any information of the Dimension value behind the informations collected in the infos value obtained from IBarcodeInfo[] infos = reader.ReadBarcodes(barcodeImage);

Is Vintasoft able to find and display this information (1 px, 2px, 3px etc.) ?

Thank you for your help.

Code used is the following :

Code: Select all

(lbInfos is a ListBox on my form).
public void ReadBarcodesFromImage(Image barcodeImage)
{
    lbInfos.Items.Clear();

    // create barcode reader
    BarcodeReader reader = new BarcodeReader();

    // specify that reader must search for Code39, Code39Extended,
    // Code128, SSCC18 and DataMatrix barcodes
    reader.Settings.ScanBarcodeTypes =
        BarcodeType.Code39 |
        BarcodeType.Code128 |
        BarcodeType.DataMatrix;
    reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.Code39Extended);
    reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.SSCC18);

    // specify that reader must search for horizontal and vertical barcodes only
    reader.Settings.ScanDirection = ScanDirection.Horizontal | ScanDirection.Vertical;

    // use Automatic Recognition
    reader.Settings.AutomaticRecognition = true;

    // read barcodes from image
    IBarcodeInfo[] infos = reader.ReadBarcodes(barcodeImage);

    // if barcodes are not detected
    if (infos.Length == 0)
    {
        Console.WriteLine("No barcodes found.");
    }
    // if barcodes are detected
    else
    {
        // get information about extracted barcodes
        Console.WriteLine(string.Format("{0} barcodes found:", infos.Length));
        Console.WriteLine();
        for (int i = 0; i < infos.Length; i++)
        {
            IBarcodeInfo info = infos[i];
            lbInfos.Items.Add(string.Format("[{0}:{1}]", i + 1, info.BarcodeType));
            lbInfos.Items.Add(string.Format("Value:      {0}", info.Value));
            lbInfos.Items.Add(string.Format("Region:     {0}", info.Region));

        }
    }
}

Alex
Site Admin
Posts: 1464
Joined: Thu Jul 10, 2008 2:21 pm

Re: Get Barcode128 Dimension from Vintasoft

Post by Alex » Fri Jan 20, 2017 2:13 pm

Hello,

Do you want to get the bar width of the recognized barcode?

Best regards, Alexander

IAmByB
Posts: 15
Joined: Thu Jan 19, 2017 2:01 pm

Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB » Fri Jan 20, 2017 2:39 pm

Yes, I want to get the bar width value of the recognized barcode (I understand it is the MinWidth value I can set in the Vintasoft barcode writer).

Alex
Site Admin
Posts: 1464
Joined: Thu Jul 10, 2008 2:21 pm

Re: Get Barcode128 Dimension from Vintasoft

Post by Alex » Fri Jan 20, 2017 2:52 pm

IAmByB wrote:Yes, I want to get the bar width value of the recognized barcode (I understand it is the MinWidth value I can set in the Vintasoft barcode writer).
The BarcodeInfo1D.NarrowBarCount property returns the bar count in the recognized barcode:
http://www.vintasoft.com/docs/vsbarcode ... Count.html

The BarcodeInfo1D.NarrowBarSize property returns the bar width in pixels:
http://www.vintasoft.com/docs/vsbarcode ... rSize.html

Best regards, Alexander

IAmByB
Posts: 15
Joined: Thu Jan 19, 2017 2:01 pm

Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB » Fri Jan 20, 2017 6:21 pm

OK, I found the needed information. Thank you !

IAmByB
Posts: 15
Joined: Thu Jan 19, 2017 2:01 pm

Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB » Mon Jan 23, 2017 2:03 pm

Hello,

Please can you tell me what is the unit of the NarrowSizeBar value obtained when reading a barcode 128 with Vintasoft ? I assumed that it was in pixels, but I'd like to have a confirmation from your part ?


I try to generate a barcode 128 with a NarrowBar Size of 0,375 millimeters, at a resolution of 72 dpi. For that, I use the following statement :

Code: Select all

writer.Settings.SetMinWidth(0.375, UnitOfMeasure.Millimeters);
but when I read the barcode I created, the NarrowBar Size value read by Vintasoft is 4.6.
If the 4.6 value is in pixels, the result in millimeters is (4.6 / 72) x 25.4 = 1.62 mm, which is very different from the 0.375 value I expected.

Can you help me in this point ? Thank you.

Alex
Site Admin
Posts: 1464
Joined: Thu Jul 10, 2008 2:21 pm

Re: Get Barcode128 Dimension from Vintasoft

Post by Alex » Mon Jan 23, 2017 2:30 pm

Hello,

Here is a console application that creates Code128 barcode (bar width is set to 2 pixels) and reads Code128 barcode (bar width is 2 pixels) from created image:

Code: Select all

using System;
using System.Drawing;
using Vintasoft.Barcode;
using Vintasoft.Barcode.BarcodeInfo;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            BarcodeWriter barcodeWriter = new BarcodeWriter();
            barcodeWriter.Settings.Barcode = BarcodeType.Code128;
            barcodeWriter.Settings.Value = "1234567890";
            barcodeWriter.Settings.Resolution = 72;
            barcodeWriter.Settings.SetMinWidth(0.375, UnitOfMeasure.Millimeters);
            if (barcodeWriter.Settings.MinWidth != 2)
                throw new ApplicationException();

            using (Bitmap bitmap = barcodeWriter.GetBarcodeAsBitmap())
            {
                using (BarcodeReader barcodeReader = new BarcodeReader())
                {
                    barcodeReader.Settings.ScanBarcodeTypes = BarcodeType.Code128;
                    IBarcodeInfo[] infos = barcodeReader.ReadBarcodes(bitmap);

                    if (infos.Length != 1)
                        throw new ApplicationException();

                    BarcodeInfo1D info1D = infos[0] as BarcodeInfo1D;
                    if (info1D.NarrowBarSize != 2)
                        throw new ApplicationException();
                }
            }
        }
    }
}
Please try to use this code and let me know if you will have any question or problem.

Best regards, Alexander

IAmByB
Posts: 15
Joined: Thu Jan 19, 2017 2:01 pm

Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB » Tue Jan 24, 2017 1:24 pm

Thank you very much for your code. I tried it and it works perfectly. It helped me to check that my own code is correct.

Can you please tell me what is the measurement unit of the MinWidth value (not the 0.375 value but the 2 value) ?

Thank you again for your help.

Alex
Site Admin
Posts: 1464
Joined: Thu Jul 10, 2008 2:21 pm

Re: Get Barcode128 Dimension from Vintasoft

Post by Alex » Tue Jan 24, 2017 2:05 pm

Hello,
IAmByB wrote:Can you please tell me what is the measurement unit of the MinWidth value (not the 0.375 value but the 2 value) ?
The WriterSettings.MinWidth property value is specified in pixels:
http://www.vintasoft.com/docs/vsbarcode ... Width.html

Best regards, Alexander

IAmByB
Posts: 15
Joined: Thu Jan 19, 2017 2:01 pm

Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB » Tue Jan 31, 2017 8:57 pm

Hello,

I have one more question about Vintasoft barcodes writer :

If I create a barcode 128 with :
SetMinWidth(0.375,MeasurementUnit.Millimeters);
the value of MinWidth property is 2 px

If I create a barcode 128 with :
SetMinWidth(0.7,MeasurementUnit.Millimeters);
the value of MinWidth property is the same (2 px)

I thought that the MinWidth value was going to change when I change the value used in SetMinWidth().

Can you explain me why is the MinWidth value the same in both cases, and how can I make vary ?

Thank you very much.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests