g0dkar / qrcode-kotlin

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

Circle QR code not recognized #130

Open Arclud opened 2 months ago

Arclud commented 2 months ago

Describe the bug I created a QR code with the following code val circleQRCode = QRCode.ofCircles().build("https://sample/alphaskfhdbfebwhnewnew/sdjnbchbwdhvbewhbvhuew") val circlePngData = circleQRCode.render()

To save image on .png format I use the following code (it will be works for android 13 and newest version) internal class SavePhotoTask(private val context: Context) : AsyncTask<ByteArray?, String?, String?>() { protected override fun doInBackground(vararg jpeg: ByteArray?): String? { val photo = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).toString(), "photo.png") if (photo.exists()) { photo.delete() } try { val fos = FileOutputStream(photo.path) fos.write(jpeg[0]) fos.close() } catch (e: IOException) { Log.e("PictureDemo", "Exception in photoCallback", e) } return null } }

Note: No problem with scanning if I generate rectangle QR instead of circle , also your QR with name example01-circles.png was scanned perfectly but I do not now why since i used same code

Generated following QR photo

Additional context

Finally, I accept that the generated image is not detected fast, for example, I use Google Scanner, the default application scanner but there are not working perfectly, freeze

I use for testing following devices: Google pixel 7 (android 14) Redmi not 9s (android 12)

g0dkar commented 2 months ago

Heya! Thanks for bringing this up!

I think I know what the issue is: those outer squares should have a larger center one. And they should be slightly smaller. I'll tune it out and let you know when the new version is out =D

g0dkar commented 2 months ago

Hello again ^^

I've adjusted the Android rendering and got this QRCode here:

image

It should decode to example - Google's ZXing Online Decoder seems able to process it:

image

Let me know if this QRCode is working with your device. If it is NOT readable, I'll try tune it a bit more ❤️

Arclud commented 2 months ago

@g0dkar Thank you for your hard work , I really appreciate 🙇 I confirm your QR code scanned very well (tested on Google Pixel , Redmi note 9s) I guess we can close this issue ❤️

g0dkar commented 2 months ago

Glad to know its working =D

I'll leave it open for now so it can be closed when #131 is merged :)