B4A Library ZXingLib by icefairy333 - modified by Johan Schoeman (Scan QR Codes and other 1D/2D Barcodes)

Johan Schoeman

Expert
Licensed User
Mm, one of the old versions had a cancel event generated when the back button was pressed. Sure I can do it in resume.

Other questions, do you have the settings you use when compiling with SLC? Cannot get the correct result when creating the folder structure.
Cancel and timeout will both return a "null" in Sub myzx_noscan - in both cases nothing was found. But we can add to the code in order to raise a separate event when the back button is pressed.
 

Johan Schoeman

Expert
Licensed User
OK - set up your project as follows (for eg):
Create a directory structure on your c: or d: or whatever drive that looks as follows:

BlueDudeZxingLib
src
......all the files and directories in the src folder​

Then copy all the files and directories as is into the src folder (else just drop the complete src folder - once unzipped - into the BlueDudeZxingLib folder without making an additional src folder.

Then start Simple Library Compiler (SLC)

1. In the first line of SLC you browse to the BlueDudeZxingLib folder
2. In the second line you put the name of whatever you want the library to be (this is the name that will appear in you B4A project library list). Put in for eg BlueDudeZxingLib if that is the name that you want it to be
3. In the -b4aignore field you enter com

Click on compile and then sit back and relax for a few seconds. The jar and xml will be added to you additional library folder.

No pics required - it is as simple as this. Give it a try and let me know
See pics attached
 

Attachments

Johan Schoeman

Expert
Licensed User
The attached project keeps all previously added functionality but adds the option of beep and vibrate upon a successful scan. New lib files are in the /files folder of the attached project. Also posting the updated java source files (complete src folder)

B4X:
zx.mustBeep = True
zx.mustVibrate = True
Also note that:
B4X:
zx.theBitMapLeft = 40%x
zx.theBitMapTop = 10%y
zx.theBitMapWidth = 20%x
zx.theBitMapHeight = 20%x
are now replaced by:
B4X:
zx.theBitmapPosition(40%x, 10%y, 20%x, 20%x)
 

Attachments

Last edited:

Johan Schoeman

Expert
Licensed User
Aztec.png


This update adds back the ability to scan Aztec codes too (see attached pic) - it was missing from the original Icefaire333 java source code.

Just posting the zipped library files (jar and xml). Use them with the project posted in post #24 above (i.e replace your current jar and xml files with this in case you have down loaded the project(s). Also posting src_4.zip - the updated java source code. It will compile as is with SLC.
 

Attachments

Last edited:

Johan Schoeman

Expert
Licensed User
PDF417.png


This update adds back the ability to also scan PDF417 codes (see attached pic) - it was also missing from the original Icefaire333 java source code. I am of the opinion that there is an error in the original Zxing code (core library) as far as the decoding of PDF417 codes are concerned. It sometimes generates a NPE error and for the same PDF417 code NeoReader returns a "?" - basically an invalid code but this version of the Zxing core library does not seem to handle an invalid PDF417 code correctly. It nevertheless scans valid codes perfectly. This error to be investigated and corrected so that the scanner does not "hang" due to the NPE error.

Just posting the zipped library files (jar and xml). Use them with the project posted in post #24 above (i.e replace your current jar and xml files with this in case you have down loaded the project(s)). Also posting src_5.zip - the updated java source code. It will compile as is with SLC.
 

Attachments

Last edited:

bluedude

Well-Known Member
Licensed User
In the latest version the bottom text is suddenly Italic :) I can probably fix and compile myself but just informing.
 

Johan Schoeman

Expert
Licensed User
In the latest version the bottom text is suddenly Italic :) I can probably fix and compile myself but just informing.
Yes, that is correct. Was playing around with the text. Look in the view folder for ViewFinderView.java and see where I have made the changes for italic. Just comment it out and text will revert back to normal.
 
Last edited:

chaiwatt

Member
Licensed User
I'm not sure is method 'zx.isportrait = False' work. It immediately display on portrait layout once scan executed. Although I set Module Attributes to '#SupportedOrientations: landscape'. Regarding help to check, Thanks.
 

Johan Schoeman

Expert
Licensed User
This update fixes the "hanging" issue (NPE error) experienced with scanning of some PDF417 codes (see issue reported on in post #26 above). Have tested it by scanning various PDF417 codes that used to generate the NPE error. It was an error in the older version of the PDF417 java code. I have replaced the java class that generated the error with the latest version of that class that is posted on GitHub. Posting the updated zipped library files (jar and xml) and the updated zipped src folder. Replace your library files or recompile the attached src folder to generate the same library files.
 

Attachments

TheMightySwe

Active Member
Licensed User
Hi,

a question. It seems that the 'zx.isportrait = False' is a bit strange, the camera output seems to be 90 degrees fault, but the text shows OK.

The picture is also distorted like it's a portrait picture in landscape with Gravity.FILL
 

Johan Schoeman

Expert
Licensed User
This update returns a bitmap image of the scanned barcode to the B4A project. You can add the necessary code in the B4A project to save it or manipulate it or whatever else it is that you want to do with the bitmap image. All previously added functionality that was added to the library is maintained. Posting the updated B4A project, the zipped jar and xml files (jar and xml are also in the /files folder of the attached project), and the zipped src folder (the java code).
 

Attachments

Johan Schoeman

Expert
Licensed User
Hi,

a question. It seems that the 'zx.isportrait = False' is a bit strange, the camera output seems to be 90 degrees fault, but the text shows OK.

The picture is also distorted like it's a portrait picture in landscape with Gravity.FILL
I am aware of it - it is how the original code of this specific library seems to have been created. I have only added some additional functionality/appearances to it. Will look into it at some stage and see if it can be resolved. Best to use it in portrait mode for now. I am posting the updated source code as I go along - so, if someone wants to look into this issue they are more than welcome. Please just post the amended source code if someone manages to fix it so that the source code can be available for all B4A members that want to make use of it.
 
Last edited:

TheMightySwe

Active Member
Licensed User
I am aware of it - it is how the original code of this specific library seems to have been created. I have only added some additional functionality/appearances to it. Will look into it at some stage and see if it can be resolved. Best to use it in portrait mode for now. I am posting the updated source code as I go along - so, if someone wants to look into this issue they are more than welcome. Please just post the amended source code if someone manages to fix it so that the source code can be available for all B4A members that want to make use of it.

I found some code online, you can check it out if you want.

http://www.wenda.io/questions/3311875/zxing-camera-portrait-mode-and-landscape-on-android.html
 

Johan Schoeman

Expert
Licensed User
Will look into it. The code in the (base) java source files that I am working from is very different to the standard Zxing files. It has been adapted to suite a specific purpose. On first view the code in your link can't just be copied in. (Base) code needs some serious "surgery" to accommodate it. There might be an easier approach to this rather than trying to do a heart transplant.
 

TheMightySwe

Active Member
Licensed User
Have you any idea why I don't come back to my project when Scanning a QR-Code? The ZXing-screen gets green and then I don't come back to the program.
 

Johan Schoeman

Expert
Licensed User
Have you any idea why I don't come back to my project when Scanning a QR-Code? The ZXing-screen gets green and then I don't come back to the program.
No, have not experienced it. What does the project in post #32 do when you run it on your device? Does it behave the same or does it return back to the B4A project?
 

bluedude

Well-Known Member
Licensed User
If mustBeep and mustVibrate are set to false there are no results returned, must be a bug.
 
Top