alexzhirkevich / custom-qr-generator

Android library for creating QR codes with logo, custom shapes, colors, background image. Powered by ZXing
MIT License
173 stars 18 forks source link

Support the different standard encodings #37

Closed michaelWuensch closed 1 year ago

michaelWuensch commented 1 year ago

Is your feature request related to a problem? Please describe. I want my QR codes to be as small as possible. I have to encode 64 character hex strings.

Describe the solution you'd like The QR code specification defines 4 standard ways of encoding the data. Numeric, Alphanumeric, binary & kanji. I could encode hex strings way more efficiently if I just upper case them and then use Alphanumeric as encoding. So in short: It would be awesome if we could set the encoding option somehow.

Describe alternatives you've considered The alterative are ugly big codes 😀

Additional context Please see this page for more information: https://www.thonky.com/qr-code-tutorial/data-encoding

alexzhirkevich commented 1 year ago

I guess ZXing encoder automatically picks most suitable mode.

michaelWuensch commented 1 year ago

Hm, okay. I tried it with a 64 char hex string that I uppercased and at least it did not become smaller (same amount of pixels). I haven't checked though if the encoded data was actually different. I will give it another go later.

alexzhirkevich commented 1 year ago

Large codes is a bug with automatic error correction level. It mistakenly decides that you have logo with default size even when you don't have it and increases ECL. Try change errorCorrectionLevel in options from Auto to Low. I think it will help to reduce the QR code size.

michaelWuensch commented 1 year ago

I do not use auto for error correction. I use Medium for for that 64 char string. Setting it to low made a difference in size of the QR code while uppercasing the hex string had no effect. Right now I need to stick with medium error correction to have them scan reliably. I'll do some more tests later.

alexzhirkevich commented 1 year ago

So this method form ZXing should automatically select alphanumeric mode. It can't be controlled by the user.

michaelWuensch commented 1 year ago

Yes, I have already seen that function and it looks good. I will close the issue for now and only reopen if I can proof it does actually not use the correct encoding. Thanks for your support! 👍

michaelWuensch commented 1 year ago

@alexzhirkevich I just looked at it again and I can confirm that it works and uses the standard encodings automatically. I added the .toUppercase() function on the wrong line and it was actually still lower case... Big facepalm moment! Sorry for wasting your time. But the good news is everything works as expected!