-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to decode from gallery image (null result) #495
Comments
Make sure you receive a RGB888 byte array from the bitmap. you need your byte array like { r, g, b, r, g, b, r, g, b ... }. It may contain an unessessary alpha component like { r, g, b, a, r, g, b, a, r, g, b, a ... } or worse, be 16-Bit and compressed to two bytes (5 bit per color). You can specify the format by using the constructor overload of RGBLuminanceSource with |
I did another test using an API (sending the byte array of the image in data.image class)
This way im able to decode correctly the image, getting the string that i expect from the QR Code image. Tried to do the same on my app but reader.decode doesnt have a overload that takes a bitmap as parameter. |
Have a look at the byte array. If the image is 640x480, the resulting byte array length have to be 640 * 480 * 3 = 921600 bytes |
Im using a 400x400 image, the byte array length is 21.246, not even close to 400x400x(something) |
There is your problem. A 400x400 pixel image should have a bytes length of 480000, when passed to RGBLuminanceSource. You need to do something like this:
So in your Code you need to do this:
Here is the sample code There might be a faster build in feature to do this in Android though, like Bitmap.GetBuffer(). |
any code for ios side please |
Thanks for reporting this issue! Unforunately it took me way too long to respond 😭. Sorry, I apologize! Recently the source code for this project was completely refactored to modernize it. Many PR's were included in this effort, and many bugs were hopefully fixed. Please try out the latest 3.x series of NuGet packages (currently in prerelease). To try and make the project more maintainable in my spare time going forward, I've decided to close all existing issues to start with a clean slate. If you're still experiencing this issue on the newest version, please open a new issue with as much detail as possible. Thank you for your patience and understanding! Happy scanning! |
Good evening, the sample code doesn’t seem to be available anymore - could you kindly re-upload? I am currently facing this issue on iOS and really need help on how to address this issue - would really appreciate. Thanks |
@ognamala Check this out github.com//issues/981 Let me know if that helps |
I recently created a new project on Xamarin Forms PCL using this library. Im able to scan any code without problem, but another functionality that i need is to decode an image from the dispositive gallery, im retrieving the image in a byte[] (100% sure that the image is correct and obviously is a QR image that im able to scan). This is my code:
I have tested in so many ways but still cant figure why this isnt working.
I was following this unit test https://github.com/Redth/ZXing.Net.Mobile/blob/master/Tests/ZXing.Net.Mobile.NUnit/Test.cs
The text was updated successfully, but these errors were encountered: