ZXing.Net Encode string to QR Code in CF

SleepNot picture SleepNot · Nov 8, 2012 · Viewed 35.3k times · Source

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;

Answer

Michael picture Michael · Nov 8, 2012

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;