No result from barcode scan

king0fpain
2012-03-15
2013-09-05
  • king0fpain

    king0fpain - 2012-03-15

    I'm trying to scan this image using native library. I'm always getting "0" from scanner.scanImage(barcode):

    [Java Code/url]

    LogCat

    Thanks to bring ZBar to Android.](http://paste2.org/p/1940529)

     
  • king0fpain

    king0fpain - 2012-03-15
     
  • Lisa Huang

    Lisa Huang - 2012-03-15

    I suspect there's an issue with the data formats not matching (ie: we can't just assume it's Y800).
    Try this out, it worked for me.

                        Bitmap barcodeBmp = BitmapFactory.decodeResource(getResources(),
                                                                         R.drawable.barcode);
                     
                        int width = barcodeBmp.getWidth();
                        int height = barcodeBmp.getHeight();
                        int pixels = new int;

                        barcodeBmp.getPixels(pixels, 0, width, 0, 0, width, height);

                        Image barcode = new Image(width, height, "RGB4");
                        barcode.setData(pixels);

                        int result = scanner.scanImage(barcode.convert("Y800"));

    I'll add this test to the examples.

     
  • king0fpain

    king0fpain - 2012-03-15

    It works! Thank you!

     
  • Heba Othman Elzaree

    Hey i am new to scanning and i have the same problem but i couldn't fix it it gives me java.lang.ArrayIndexOutOfBoundsException
    can u help me Lisa Huang plz?

     
    Last edit: Heba Othman Elzaree 2013-05-21

Log in to post a comment.