PDF417 barcode generation - ErrorCorrectionLevel error with 3.2.1 Android

58 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Chuck Preston

ungelesen,
15.04.2016, 19:52:0415.04.16
an zxing
Setting the error correction level to ErrorCorrectionLevel.L in 3.2.1 seems to be broken in Android.

hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
throws the error: java.lang.ClassCastException: com.google.zxing.qrcode.decoder.ErrorCorrectionLevel cannot be cast to java.lang.Number

You can set it to an integer and it works fine.
hintMap.put(EncodeHintType.ERROR_CORRECTION, 2); // this works

The problem code is in the PDF417Writer class.
I believe this:
if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
errorCorrectionLevel = ((Number) hints.get(EncodeHintType.ERROR_CORRECTION)).intValue();
}
should be this:
if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
errorCorrectionLevel = ((int) hints.get(EncodeHintType.ERROR_CORRECTION)).intValue();
}

Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten