VintaSoft Barcode .NET SDK Discussions

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

Board index < VintaSoft Barcode < VintaSoft Barcode .NET SDK Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

Get Barcode128 Dimension from Vintasoft



Get Barcode128 Dimension from Vintasoft

Post by IAmByB »

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 :
(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));

        }
    }
}


Re: Get Barcode128 Dimension from Vintasoft

Post by Alex »

Hello,

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

Best regards, Alexander


Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB »

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).


Re: Get Barcode128 Dimension from Vintasoft

Post by Alex »

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:
https://www.vintasoft.com/docs/vsbarcode ... Count.html

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

Best regards, Alexander


Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB »

OK, I found the needed information. Thank you !


Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB »

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 :
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.


Re: Get Barcode128 Dimension from Vintasoft

Post by Alex »

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:
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


Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB »

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.


Re: Get Barcode128 Dimension from Vintasoft

Post by Alex »

Hello,
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:
https://www.vintasoft.com/docs/vsbarcode ... Width.html

Best regards, Alexander


Re: Get Barcode128 Dimension from Vintasoft

Post by IAmByB »

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.


Page 1 from 2: 1 2