Troubleshooting Barcode Issues Using ZXing Big Data Library

I need to generate a 128A barcode with data: 900000588548001100001305000000000207201512345.6 | 12345.7

I am using ZXing library and here is my method:

private void barcodeGenerator(String data)
{
    try
    {
        com.google.zxing.MultiFormatWriter writer = new MultiFormatWriter();

        BitMatrix bm = writer.encode(data, BarcodeFormat.CODE_128, 700, 200);
        Bitmap ImageBitmap = Bitmap.createBitmap(700, 200, Config.ARGB_8888);

        for (int i = 0; i < 700; i++)
        {//width
            for (int j = 0; j < 200; j++)
            {//height
                ImageBitmap.setPixel(i, j, bm.get(i, j) ? Color.BLACK : Color.WHITE);
            }
        }

        File f = new File(Environment.getExternalStorageDirectory() + "/barcode1.png");


        FileOutputStream fos = new FileOutputStream(f);
        ImageBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}

      

This method generates and saves a barcode image in SDCard, which is performed with a ZXing barcode scanner.

The barcode is scanned successfully when the data is small. for example: 123.4 | 456.7

enter image description here

But if the data is large, for example: 900000588548001100001305000000000207201512345.6 | 12345.7

It looks like an invalid barcode is being generated and the scanner is unable to scan the generated barcode.

enter image description here

Thanks in advance for your help.

Edit: added generated barcode images

+3


source to share


1 answer


You can upload the barcode image you created into the ZXing Online decoder to confirm if it is valid:

http://zxing.org/w/decode.jspx

There is no internal code length limit of 128 barcode and all the characters you have are valid.

Having said that, with Code 128A barcodes encoded over 20 characters, the resulting barcode is very wide and difficult to scan.



It is likely that the barcode is valid, but the scanner camera cannot get a clear enough image of such a large barcode.

Take a look at this question for more information: Unable to scan code 128

If possible, it would be desirable to use an alternative barcode format, such as a QR code, which can store more data without increasing the barcode size.

0


source







All Articles