Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

ZXing BarcodeWriter to Image not displaying

$
0
0

Hello guys,
I've been trying to display my barcode in a Content Page but it doesn't seem to be working.
I'm using the BarcodeWriter from the ZXing.Net.Mobile Nuget package.
The code compiles without error but the iOS Simulator does not display the barcode.
Is there something I'm missing or am I using the wrong image method?

public BarcodePage
{
    var barcodeWriter = new BarcodeWriter {
        //Format = BarcodeFormat.QR_CODE,
        Format = BarcodeFormat.CODE_128,
        Options = new ZXing.Common.EncodingOptions {
            Width = 300,
            Height = 50,
            Margin = 30
        }

    };

    byte[] barcode = barcodeWriter.Write ("ABC12345678");

    ImageSource imageSource = ImageSource.FromStream (() => {
        MemoryStream ms = new MemoryStream (barcode);
        ms.Position = 0;
        return ms;
    });

    Image imageBarcode = new Image { Aspect = Aspect.AspectFill };
    imageBarcode.Source = imageSource; 

    Content = imageBarcode;
}

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>