g0dkar / qrcode-kotlin

QRCode Generator implemented in pure Kotlin
https://qrcodekotlin.com/
MIT License
160 stars 13 forks source link

Qrcode Version #115

Open mimai-hen opened 6 months ago

mimai-hen commented 6 months ago

Hi :-)

I'm very interested in your library. But for the same string, the QRcode generated by your library is in version 10 (= 57 columns/lines) although the old library I've been currently using (AwesomeQRCode) generates a version 7 (= 45 columns/lines).

I wonder why this difference ? is it a question of EC level used ? If yes, would it be possible to make this level configurable in your library ?

Thank you for your answer

mimai-hen commented 5 months ago

Hi, Looking at your code, I think it would be very easy to add this function in QRCodeBuilder: /* Error correction level used to generate QR code / fun withErrorCorrectionLevel(level: ErrorCorrectionLevel): QRCodeBuilder { errorCorrectionLevel = level return this }

And then use this errorCorrectionLevel new parameter in QrCode class instead of hard-coded ErrorCorrectionLevel.H : /* The underlying [QRCodeProcessor] object that'll do all calculations / val qrCodeProcessor: QRCodeProcessor = QRCodeProcessor(data, errorCorrectionLevel, graphicsFactory = graphicsFactory)

/** Computed type number for the given [data] parameter */
val typeNum = QRCodeProcessor.typeForDataAndECL(data, **errorCorrectionLevel**).coerceAtLeast(6)

Unfortunately I can't build your project on my mac :-/ so if you mind adding this new errorCorrectionLevel customization it would be great.

Have a nice day