QRCode encoding : ErrorCorrectionLevel

Added by carikube over 6 years ago

Hi,

With the MessagingToolkit.Barcode library, is it possible to generate a QR-Code, giving in parameter the error correction capacity (L / M / Q / H) ?
I found in the sources the following class : MessagingToolkit.Barcode.QrCode.Decoders.ErrorCorrectionLevel, but I don't know how to use it.
Is it used only to decode and not to encode ?
Would you have a sample ?

Thank you


Replies (4)

RE: QRCode encoding : ErrorCorrectionLevel - Added by admin over 6 years ago

Hi,

The error correction level is specified when you generate the QR Code.

During decoding, this format information is read and used to decode the QR code information.

Thanks
Regards
admin

RE: QRCode encoding : ErrorCorrectionLevel - Added by carikube over 6 years ago

Thank you for your response.
But I still have a problem when using this level.
I can't get the result correctly.
This is my code :

QRCode qrCodeResult = new QRCode();
MessagingToolkit.Barcode.QrCode.Encoders.Encoder.Encode(textToEncode, level, qrCodeResult);
ByteMatrix bt = qrCodeResult.Matrix;
return ConvertByteMatrixToImage(bt);

All I get is a black squarrel.

For information, this is working well (I found it in your sample) :

MultiFormatWriter barcodeWriter = new MultiFormatWriter();
ByteMatrix bt = barcodeWriter.Encode(textToEncode, BarcodeFormat.QrCode, width, height);
return ConvertByteMatrixToImage(bt);

Thanks again
Regards
C.

RE: QRCode encoding : ErrorCorrectionLevel - Added by admin over 6 years ago

Hi,

You use use the MultiFormatWriter, and pass in the hints containing the error correction level

MultiFormatWriter barcodeWriter = new MultiFormatWriter();
Hashtable hints = new Hashtable();
hints.Add(EncodeHintType.ErrorCorrection, MessagingToolkit.Barcode.QrCode.Decoders.ErrorCorrectionLevel.M);

ByteMatrix bt = barcodeWriter.Encode(textToEncode, BarcodeFormat.QrCode, width, height, hints);

return ConvertByteMatrixToImage(bt);

RE: QRCode encoding : ErrorCorrectionLevel - Added by carikube over 6 years ago

GREAT !!!
It's working !
Thanks a lot !

Is there somewhere a documentation that explains how using these hints ?

C.

(1-4/4)