QRGenerator
QRGenerator copied to clipboard
QR Correction Level Support
Currently there is not support to be able to set the QR correction level, Would it be possible to add this please find proposed solution
public enum ErrorCorrection {
LOW,
MEDIUM,
QUARTILE,
HIGH
}
private ErrorCorrectionLevel getCorrectionLevel(ErrorCorrection errorCorrectionLevel) {
switch (errorCorrectionLevel) {
case LOW:
return ErrorCorrectionLevel.L;
case MEDIUM:
return ErrorCorrectionLevel.M;
case QUARTILE:
return ErrorCorrectionLevel.Q;
case HIGH:
return ErrorCorrectionLevel.H;
default:
throw new IllegalArgumentException("Unknown error correction level: " + errorCorrectionLevel);
}
}
public Bitmap getBitmap(int margin) {
return getBitmap(margin, null);
}
public Bitmap getBitmap(int margin, ErrorCorrection errorCorrectionLevel) {
....
if (encoding != null) {
hints.put(EncodeHintType.CHARACTER_SET, encoding);
}
if (errorCorrectionLevel != null) {
hints.put(EncodeHintType.ERROR_CORRECTION, getCorrectionLevel(errorCorrectionLevel));
}
hints.put(EncodeHintType.MARGIN, margin);
....
}