Forum Xamarin.Android

Barcode generator library

Hi all!

For first, I want to sorry for my bad English - I'm from Poland (it's not English country), I want to sorry if I put this thread on wrong forum, this is my first post here.

Do you know any good barcode generator library (That will work with Xamarin.Android - min API 15)?
No, not ZXing - it's too big and has too many not used by my application features, additionally it adds to my AndroidManifest.xml Camera permission that I don't want to use, I need generator not scanner... :neutral:

I need small, lightweight (open source if possible) library that will generare datamatrix or qrcode image and then I will call
imageview1.SetImageDrawable(code); //(or something like this)

Please suggest me your favourites. Thanks! :)

Posts

  • NashZhouNashZhou USMember ✭✭✭
    edited August 2017

    Edit: Misread what you wanted...A lot of open source libraries seem to use ZXing.

  • MichaelJahnMichaelJahn DEMember

    I think you mean the ZXing.Net.Mobile library. You can try the pure ZXing.Net library. That one doesn't add anything to your AndroidManifest.xml. ZXing.Net.Mobile is built on top of ZXing.Net.
    https://github.com/micjahn/ZXing.Net
    Not sure if it fits your needs.

  • sham3103sham3103 PKMember

    1-change extension of these files to .dll from .txt and include in project
    2- write a dependency service

    in pcl -

    byte[] GenerateQrImage(string content, int width, int height);

    in android

    public byte[] GenerateQrImage(string content, int width, int height)
    {
    var options = new QrCodeEncodingOptions
    {
    Height = height,
    Width = width,
    Margin = 0,
    PureBarcode = true
    };

            var writer = new BarcodeWriter
            {
                Format = BarcodeFormat.QR_CODE,
                Options = options
            };
    
            // Generate bitmap
            var bitmap = writer.Write(content);
            if (bitmap != null)
            {
                // Get bytes from bitmap
                using (var stream = new MemoryStream())
                {
                    bitmap.Compress(Bitmap.CompressFormat.Png, 100, stream);
                    return stream.ToArray();
                }
            }
    
            return null;
        }
    

    3-Generate qr-code in your code as follow

    var stream = DependencyService.Get().GenerateQrImage(qrcodetext, 300, 300);
    Stream strm = new MemoryStream(stream);
    qrcodeImage.Source = ImageSource.FromStream(() => strm);

    note- Author of this library/plugin have removed this from NUGET packages. so this is the only possibilities to generate qr code

  • ThamaraiThamarai Member ✭✭

    Hi Michael Jahn,
    Currently I am developing an android mobile application in Xamarin.Android (not Xamarin.Forms), in which I need the feature of scanning barcode through device camera. Is it possible with ZXing.Net ? If it is possible, how can I use this ? Because I searched in 'https://github.com/micjahn/ZXing.Net' and it has a lot of files and it was difficult to find the functionality for my requirements. It will be helpful if you narrate me.

Sign In or Register to comment.