ZXing.Net Encode string to QR Code in CF

眉间皱痕 提交于 2019-11-30 08:52:32
Michael

You doesn't fully initialize the BarcodeWriter. You have to set the barcode format. Try the following code snippet:

IBarcodeWriter writer = new BarcodeWriter
{ Format = BarcodeFormat.QR_CODE };
var result = writer.Write("Hello");
var barcodeBitmap = new Bitmap(result);
pictureBox1.Image = barcodeBitmap;

@dizzytri99er

Seems that I have sucessfully encoded a message with ZXing.net therefore I think it does support Aztec encoding

This is the code I have used;

    static void Main(string[] args)
    {
        IBarcodeWriter writer = new BarcodeWriter
            {
                Format = BarcodeFormat.AZTEC
            };
        Bitmap aztecBitmap;
        var result = writer.Write("I love you ;)");
        aztecBitmap = new Bitmap(result);

        using (var stream = new FileStream("test.bmp", FileMode.OpenOrCreate, FileAccess.ReadWrite))
        {
            var aztecAsBytes = ImageToByte(aztecBitmap);
            stream.Write(aztecAsBytes, 0, aztecAsBytes.Length);
        }
    }


    public static byte[] ImageToByte(Image img)
    {
        ImageConverter converter = new ImageConverter();
        return (byte[])converter.ConvertTo(img, typeof(byte[]));
    }

could it possibly be the size of the codes your are scanning?

take a look here

best way to generate and encode QR codes would be...

QR code encoder and Zbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!