What format does Zbar need?

0

short explanation: I'm grabbing a bitmap from a TextureViwe. The format of the image is ARGB_8888. I convert this image and put it in the MainLooper. The picture there then in the Zbar scanner. The scanner supports to my knowledge, Gray and Y800. My problem is that all conversion attempts have so far failed. My question is, how do I set up the byte array that the Zbar functions in?

I have tried the following things:

private byte[] getGray(Bitmap image) {
        int width = image.getWidth();
        int height = image.getHeight();

        int[] pixels = new int[height * width];
        byte grayIm[] = new byte[height * width];

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

        int pixel = 0;
        int count = width * height;

        while (count-- > 0) {
            int inVal = pixels[pixel];

            //Get the pixel channel values from int
            double r = (double) ((inVal & 0x00ff0000) >> 16);
            double g = (double) ((inVal & 0x0000ff00) >> 8);
            double b = (double) (inVal & 0x000000ff);

            grayIm[pixel++] = (byte) (0.2989 * r + 0.5870 * g + 0.1140 * b);
        }

        return grayIm;
    }

With:

Image barcode = new Image(size.width, size.height, "GRAY");
barcode.setData(data);
int result = iScanner.scanImage(barcode);

Or:

ByteArrayOutputStream stream = new ByteArrayOutputStream();                  
newBitmap1.compress(Bitmap.CompressFormat.JPEG, 100, stream);
tempByteArray = stream.toByteArray();
newBitmap1.recycle();

Or:

Bitmap newBitmap1;
Bitmap.Config config = Bitmap.Config.RGB_565;
newBitmap1 = bitmap.copy(config, true);

And:

int size = bitmap.getRowBytes() * bitmap.getHeight();
ByteBuffer byteBuffer = ByteBuffer.allocate(size);
bitmap.copyPixelsToBuffer(byteBuffer);
byteArray = byteBuffer.array();

With:

Image barcode = new Image(size.width, size.height, "RGB4");
barcode.setData(data);
int result = iScanner.scanImage(barcode.convert("Y800"));

I have encountered the following error messages so far:

A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0xcf491000 in tid 5810

And:

java.lang.UnsupportedOperationException: unsupported image format

Unfortunately I have no further ideas so far. I hope you can help me.

java
android
format
zbar
asked on Stack Overflow Jul 17, 2019 by FrankenDerStein

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0