Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR Correction Level Support #70

Open
gerkata21 opened this issue Dec 13, 2024 · 0 comments
Open

QR Correction Level Support #70

gerkata21 opened this issue Dec 13, 2024 · 0 comments

Comments

@gerkata21
Copy link

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);
       ....
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant