Search code examples
androidqr-codezxing

How to create QR not using zxing in android?


I need to create a QR Code following configuration below:

 - Model 2
 - Version 10
 - Size 57 x 57 
 - Level H (30%)
 - Max 174 alphanumeric characters or 119 binary
 - Modules size 0.03 inch

Actually, I'm using zxing to create the QR but I can't figure out how to set these 3 configurations

- Model 2
- Max 174 alphanumeric characters or 119 binary
- Modules size 0.03 inch

And this the code I'm using (Kotlin)


        imgQrCode.run{setImageBitmap(BarcodeEncoder().createBitmap(
             MultiFormatWriter().encode(content, 
                                        BarcodeFormat.QR_CODE, 
                                        57, 57,
                                        mapOf<EncodeHintType, Any>(
                                           Pair(EncodeHintType.QR_VERSION, 10),
                                           Pair(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H)

    ))))}

Any idea how can I set those configurations with zxing or is there any alternative option to archive all the factors above?


Solution

  • Model 2

    1. ZXing appears to be supporting Model 2 QR Code as the code: https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/qrcode/encoder/Encoder.java#L280

      seems to handle versions 1 through 40. Model 1 only goes up to version 14.

    Max 174 alphanumeric characters or 119 binary

    1. Count? Or use the rough metric from QR Code Storage section which lists 5.5 bits for Alphanumeric and 8 bits for binary. Do realize that changing error correction will change the number of bits/modules used in the image.

    Modules size 0.03 inch

    1. This is a display density question, calculate via Getting the screen density programmatically in android?.