Skip to content

QR Correction Level Support #70

Description

@gerkata21

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);
       ....
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions