Search code examples
androidqr-codezxingencodesave-image

QR code can be decoded by some of scanners, but not others?


I'm encoding from text to qr code by zxing in Android, and I've got the bitmap then save it as jpg/png.

The result qr code cannot be decoded by most scanners, it can be only decoded by zxing itself (http://zxing.org/w/decode.jspx). I know there are many different ways to do the encoding, but I guess the generated qr code should be recognized by most scanners for convenient use?

Also, I hope to know whether the compression procedure changed the original information a little?

Code :

      FileOutputStream stream = new FileOutputStream(path);    
      bitmap.compress(CompressFormat.PNG, 100, stream);

Bellows are two images -- the first image is the qr code generated from program -- I put plain text "hello" in it; the second one is one of the qr code for "hello", which can be recognized by most scanners.

Thanks!

the qr code generated from program -- I put plain text "hello" in it.

the qr code can be decoded by most scanners


Solution

  • Both barcodes look valid to me and decode with zxing.

    These are definitely different barcodes. That is, it is certainly not somehow an artifact of the image format or compression.

    The first barcode contains an ECI segment specifying UTF-8 encoding. It is correct and valid, and zxing reads it. I would not be surprised if not all readers support ECI.

    For the string "hello" you do not need an ECI segment, since the default encoding works fine. Just don't do that, and the resulting QR code will work anywhere. But, both are valid.