BlogAll Blog Posts | Next Post | Previous Post
Two lines of code to add QR, UPC, EAN code scanning in iOS Delphi applicationsBookmarks:
Friday, December 20, 2013
Note on June 1, 2018:
This technique is deprecated as the zbar library is no longer maintained and does not have 64bit version. We recommend to use the native iOS barcode scanner component that is included in TMS iCL now.
For an internal project, we looked at integrating QR code scanning in an iOS application. As we didn't feel like reinventing the wheel and deal with the complexities of deciphering a QR code, we searched for existing code and after trying out several solutions, found ZBar to be one of the most solid libraries. The project is at : http://zbar.sourceforge.net/
After doing this evaluation in XCode with ObjectiveC, the next duty was to find out how we could use an ObjectiveC library from a Delphi FireMonkey project. There are several important details to pay attention to when doing this, but finally this also proved to work and in the typical Delphi RAD philosophy, we decided to create a wrapper Delphi component for this. With this wrapper component, scanning a QR, UPC or EAN code from Delphi is as simple as two lines of code:
procedure TForm1136.Button1Click(Sender: TObject); begin // line1: activate the code scanner. This shows the camera that should be aimed at the QR or UPC code TMSFMXZBarReader1.Show; end; procedure TForm1136.TMSFMXZBarReader1GetResult(Sender: TObject; AResult: string); begin //line 2: the OnGetResult event is triggered when the code was retrieved and this returns it as a text ListBox1.Items.Insert(0, AResult); end;
Open the package file TMSFMXZBarReaderPkgDXE*.dproj from Delphi XE* (* = 5,6,7,8) and compile & install this package. This will add the component TTMSFMXZBarReader on the tool palette. Then you can drop this component in an iOS Delphi appplication and start using it in 1,2, 3 ...
This blog post has received 31 comments.
If you can extend this to Android I would pay for this.
van Dijk Bart
Yes, we need an Android version. :)
Brian Long has a solution that works well but it''s not an elegant solution and there are lots of challenges to get it to work in an app. A component set would be much more productive.
great example !!
I tested the example on my Iphone 5 ... works fine but:
the camera is slow to make a focus .. it''s normal ?
I have touched the display, but does not focus the image.. why ?
Our wrapper component is not responsible for focus control. You might direct your question at the developers of the ZBar class itself.
Are we persuading you to consider the Android version :)
Will be watching the webinar on programing devices next Wednesday. With your wrapper skills do you think this may be an area TMS could address
re android, check out
as maybe a starting point for an android component
(this uses zbar as well)
>Android Version Please :-)
Your wish is grandet. ;-)
For the iOS part "my code" is using the TMS component, so this works for Android and iOS as well.
Installed your component and compiled the example all went well (after I copied FMX.TKRBarCodeScanner.pas into the sample directory. but clicking the scan button crashes the phone.
I am testing on Galaxy S4, any suggestions.
Found the problem the solution requires the installation of zxing as well. Was really after the same elegant solution Bruno had done for IOS
This component installs and compiles into XE8 isoS 32
but not for iOS64 bit
[DCC Error] E2597 ld: missing required architecture arm64 in file ZBarSDK\libzbar.a (3 slices) for architecture arm64
i.e the zbar library looks like its missing 64 bit compiled versions of the files?
Could you sent me your working your working Application. Always get the message of "current platform is not supported". No problem with install and compile....
I am using XE8
This component is iOS 32 bit only as the ZBar lib is iOS 32 only.
I try to install TMSFMXZBarReaderPkgDXE8.dproj package in EX8 update 1 but I don''t be able to install.
I tried with IOS32, IOS64 and Simulator but the "Install" button is not active.
Have you a suggestion ?
is an android version for scanning available at the moment? We have an scanner-handheld with datawedge on it. i''m searching for a simple way to get scanner results.
I try to install the package and it works, but when I run with android device 6.0, the button doesn''t show anything.
Thanks For Share....
Line scan camera new york
It''s running okay in my iPod, but in my iPhone 6 with iOS 10.0.2 when I click at the camera icon button crashes the application.
Alternatively, I''d suggest to have a look at the new components TTMSFMXNativeBarCodeScanner that is included in TMS iCL: http://www.tmssoftware.com/site/tmsicl.asp that can do barcode scanning without needing any external libs.
Can you try to add the NSCameraUsageDescription key in the project version info? This is a requirement when deploying to iOS 10. More information can be found in the manual of TMS iCL on page 183 (http://www.tmssoftware.biz/Download/Manuals/tmsicldevguide.pdf)
Is there any way to set Front Camera or Back Camera?
gaspar ramirez jorge
All Blog Posts | Next Post | Previous Post
I am sure like me others would not mind paying for this. I have seen a number of requests.