Search code examples
c#compact-frameworkzxing

ZXing.Net Encode string to QR Code in CF


How could I encode my string into a QR Code using ZXing.Net?

I can already decode, but having problems in encoding. It has an error that says: no encoder available for format AZTEC.

Here is my code:

IBarcodeWriter writer = new BarcodeWriter();
Bitmap barcodeBitmap;
var result = writer.Encode("Hello").ToBitmap();
barcodeBitmap = new Bitmap(result);
pictureBox1.Image = barcodeBitmap;

Solution

  • You don'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;