foxitsoftware / DelphiZXingQRCode

Delphi port of QR Code functionality from ZXing, a barcode image processing library.
Apache License 2.0
198 stars 115 forks source link

Please expose the error tolerance for QR codes #1

Open CWBudde opened 10 years ago

CWBudde commented 10 years ago

Currently we're using the Google API to generate QR codes. It offers an error correction level of 'L', 'M', 'Q' and 'H' (according to the specs, see https://en.wikipedia.org/wiki/QR_code#Error_correction).

With this library an TErrorCorrectionLevel class is available, that probably control this option. However, it is not exposed by GenerateQRCode(..), which is used by the TDelphiZXingQRCode class. The value is hard-coded to 1 ("Level.FBits := 1;").

I guess adding a variable parameter should do the trick:

function GenerateQRCode(const Input: WideString; EncodeOptions: Integer; ErrorCorrectionBits: Integer = 1): T2DBooleanArray;

[...]

Level.FBits := ErrorCorrectionBits;

Then, just add a property for error correction bits that defaults to 1 in the TDelphiZXingQRCode class.

From what I have read I'm not sure if (and what) the bits setting corresponds to the predefined error levels. In the original ZXing library some information can be found here:

http://code.google.com/p/zxing/source/browse/trunk/core/src/main/java/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java

I hope this helps to get this added to this library.

This77 commented 7 years ago

Even if they did expose the ErrorCorrectionLevel (which I did just to test): It seems that QRCodes generated by this unit with Level.Bits other = 1 can not be interpreted by any QRScanner.

ajasja commented 7 years ago

PR #8 should solve this. See also https://stackoverflow.com/questions/44160153/qr-codes-encoded-by-delphizxingqrcode-not-decodable-with-errorcorrectionlevel

Best, Ajasja