0

I am developing an App using Xamarin.Forms and Visual Studio, and I also try to use ZXing.Net.Mobile and ZXing.Net.Mobile.Forms Nuget Packages to scan DataMatrix.

By default everything works fine, except when DataMatrix are printed using inverted colours. That's why I've tried to use TryInverted option, but It seems that this option doesn't work with Apple devices.

Indeed, using Android my app is able to detect DataMatrix even with Inverted colors and iPhone 5S is not, only when colours are not inverted. (I'm pretty sure because I've tried to use the same DataMatrix in both configurations, inverted colours and not). Below is my code,

var scan = DependencyService.Get<IDScan>();

var options = new ZXing.Mobile.MobileBarcodeScanningOptions();
options.TryInverted = true;
options.TryHarder = true; /* Don't really know if it's needed ?*/
options.AutoRotate = true; 
options.PureBarcode = false; /* Don't really know what is it ?*/

options.PossibleFormats = new List<ZXing.BarcodeFormat>() {
  ZXing.BarcodeFormat.DATA_MATRIX, ZXing.BarcodeFormat.QR_CODE
};

var result = await scan.GetResult(options);

if (result != null)
{
    await App.Current.MainPage.DisplayAlert(
               "Scan result",
               "Format :" + result.BarcodeFormat +
               "\nNumBits : " + result.NumBits +
               "\nValue : " + result.Text,
               "OK"
    );
}

And my iOs ScanActivity to get result and scanner,

public class ScanActivity : IDScan
{
    ZXing.Mobile.MobileBarcodeScanner scanner;

    public ScanActivity()
    {
        Debug.WriteLine("Scan Android1");
        var window = UIKit.UIApplication.SharedApplication.KeyWindow;
        var vc = window.RootViewController;
        while (vc.PresentedViewController != null)
        {
            vc = vc.PresentedViewController;
        }
        scanner = new ZXing.Mobile.MobileBarcodeScanner(vc);

    }

    public ZXing.Mobile.MobileBarcodeScanner GetScanner()
    {
        return scanner;
    }

    public async Task<ZXing.Result> GetResult(ZXing.Mobile.MobileBarcodeScanningOptions options)
    {
        var result = await scanner.Scan(options,true);
        return result;
    }
}
Alexis44
  • 1
  • 3
  • It seems like the issue has been solved in this [link](https://github.com/Redth/ZXing.Net.Mobile/issues/33), what's version of ZXing.Net.Mobile are you using? – ColeX Jun 12 '18 at 09:19
  • I'm using the last one, but I have solved the problem. I was using both ZXIng.Net.Mobile and ZXing.Net.Mobile.Forms, so I tried to delete ZXing.Net.Mobile from the project, every things works except Android Project (couldn't build project anymore), so I add back ZXing.Net.Mobile only for Android project and everythings works fine like this. – Alexis44 Jun 14 '18 at 18:21

0 Answers0