ligi / PassAndroid

Android App to view passes
GNU General Public License v3.0
802 stars 135 forks source link

QR-Codes blurry #94

Open rgls opened 8 years ago

rgls commented 8 years ago

QR-Codes are blurry (on some devices)

As you can see in the attached image, the generated QR-Code is quite blurry and can't be scanned. The device in question is a Huawei U8860. The installed version of ZXing (as I believe you use this to generate the barcode) is 4.7.3 installed from the f-droid repository. The Pass shown is one of the demo passes from espass.it. Other types of barcodes are not affected. If the Pass contains an PDF417-Barcode, it is generated without any blurryness. If I take the string that is encoded in the QR-code and let ZXing generate the QR-code directly (in it's own app) the result looks nice and sharp.

screenshot_2016-07-21-11-41-12

ligi commented 8 years ago

Thanks for reporting! Unfortunately I am not yet able to reproduce. Do you have the same in the fullscreen barcode activity? ( meaning after you clicked on the barcode )

rgls commented 8 years ago

Am 26.07.2016 um 15:11 schrieb ligi - notifications@github.com:

Thanks for reporting! Unfortunately I am not yet able to reproduce. Do you have the same in the fullscreen barcode activity? ( meaning after you clicked on the barcode )

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ligi/PassAndroid/issues/94#issuecomment-235262370, or mute the thread https://github.com/notifications/unsubscribe-auth/AEMtkW820vwazb3dolGP4VKpQR178aMUks5qZgdngaJpZM4JRrF4.

Yes, the barcode is blurry in all zoom levels and in the full screen view as well.

I found this http://stackoverflow.com/questions/25873997/how-to-fix-an-unclear-qr-code-image-generated-using-zxing-2-1, which seems to describe the same problem, but doesn't offer a solution. I am not familiar with zxings API, but is it possible specify the size of the generated image? What method do you use for scaling the generated image? Maybe you can specify not to use resampling.

Let me know if you need me to try a test version or one with additional debugging output.

ligi commented 8 years ago

I have a theory - it looks a bit like antialias - it should be false by default for BitmapDrawable - but perhaps this default value is true on this particular device - unfortunately I cannot confirm my theory on my own - will release a new beta soon - let me know if this fixes your problem

ligi commented 8 years ago

3.2.2 is now in beta - @rgls could you be so kind to check if the issue is gone on your devices and reopen the issue if not?

rgls commented 8 years ago

@ligi I'm currently nowhere near a development environment. Is there a precompiled apk available?

ligi commented 8 years ago

https://github.com/ligi/PassAndroid/releases/tag/3.2.2

rgls commented 8 years ago

Since you, as the owner, closed this issue, it seems I can't reopen it. The new version didn't solve the problem. I'll probably have to debug it myself when I get back to a development environment. I'll let you know if I come up with anything. Could be a while, though...

ligi commented 8 years ago

Thanks for testing - too bad this is not the issue. There is one obvious fix - but I would rather not go this route. This would be to scale the barcode before drawing - but this would make things slower - been there done that. Perhaps an option would be to do this as a second step - so only devices with this problem would see a difference - for others this is a noop ( just costing some cpu-cycles ) Devices with the problem would see the blurred first and then the real one short after. Ideally somehow we can Identify the devices with the problem or even find a flag we can change so it behaves correctly in the first place ..

emieza commented 1 year ago

Scaling the bitmap worked for me. See here the example https://stackoverflow.com/questions/4837715/how-to-resize-a-bitmap-in-android

qrImage.setImageBitmap(Bitmap.createScaledBitmap(bitmap,200,200, false));