Skip to content
/ zbar Public

AIR Native Extension for ZBar Bar Code Reader library

Notifications You must be signed in to change notification settings

airext/zbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zbar

AIR Native Extension for ZBar Bar Code Reader library

This ANE allows to asynchronously scan BitmapData for barcodes, under the hood it uses ZBar a well known Bar Code reader.

Dependencies

It uses ANXBridge extension for asynchronous calls.

Installation

  1. Download zbar.ane and anx-bridge.ane ANEs and add them as dependencies to your project.

  2. Edit your Application Descriptor file with registering two native extensions like this:

<extensions>
    <extensionID>com.github.airext.ZBar</extensionID>
    <extensionID>com.github.airext.Bridge</extensionID>
</extensions>

Set iOS minimum version to 8.0 in iPhone InfoAdditions:

<iPhone>
    <!-- A list of plist key/value pairs to be added to the application Info.plist -->
    <InfoAdditions>
        <![CDATA[
        <key>MinimumOSVersion</key>
        <string>8.0</string>
        ]]>
    </InfoAdditions>
</iPhone>

Note: In fact iOS 8.0 is not required, but Objective-C files are compiled targeting it, if you really need to support lower versions of iOS you could recompile and repackage this ANE and it will work.

  1. You probably want to use it to scan barcodes using Camera, if so let Android to understand that by registering Camera permission in Android Manifest additoins, like this:
<android>
    <manifestAdditions>
        <![CDATA[
        <manifest android:installLocation="auto">
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.CAMERA"/>
        </manifest>
        ]]>
    </manifestAdditions>
</android>

it seems to be final step, but before to use it you check if ZBar extension is available on the current platform:

if (ZBar.isSupported()) {
  // we're set
}

Usage example

The interface is prety straightforward, it contains one scan(bmd: BitmapData, callback: Function):void method that performs scan and notify about result in callback:

if (ZBar.isSupported()) {
  var bmd: BitmapData = drawCameraToBitmapData();
  ZBar.sharedInstance().scan(bmd, function(error: Error, results: Array):void {
    if (error) {
      trace("Error:", error);
    } else if (results.lenght > 0) {
      trace("Barcodes found:", results);
    }
  });
}