Skip to main content

QRCodeErrorCorrectionLevel Enum

Lists values that indicate the error correction level for QR Codes.

Declaration

public enum QRCodeErrorCorrectionLevel extends Enum<QRCodeErrorCorrectionLevel> implements IIntEnum

Members

Name Description
H

(High): Restores up to 30% of encoded data.

L

(Low): Restores up to 7% of encoded data.

M

(Medium): Restores up to 15% of encoded data.

Q

(Quartile): Restores up to 25% of encoded data.

fromValue(int value)

Returns the QRCodeErrorCorrectionLevel enumeration constant with the specified integer value.

getName()

Returns the name of the QRCodeErrorCorrectionLevel enumeration constant.

getValue()

Returns the integer value associated with the QRCodeErrorCorrectionLevel enumeration constant.

toString()

Returns the string representation of the QRCodeErrorCorrectionLevel enumeration constant.

valueOf(String name)

Returns the QRCodeErrorCorrectionLevel enumeration constant with the specified name.

values()

Returns an array of all QRCodeErrorCorrectionLevel enumeration constants.

Remarks

QR Codes use the Reed-Solomon error correction algorithm and support four error correction levels. Higher error correction levels improve damage resistance but reduce storage capacity.

The following code snippet creates a QR Code barcode and customizes its encoding parameters:

import com.devexpress.drawing.*;
import com.devexpress.docs.barcode.*;
import com.devexpress.system.drawing.*;
import com.devexpress.docs.Padding;

import java.io.*;
import java.nio.file.*;

public class Main {
    public static void main(String[] args) throws Exception {

        byte[] logoBytes = Files.readAllBytes(Path.of("images/devexpress-logo.png"));

        try (DXImage logo = DXImage.fromStream(new ByteArrayInputStream(logoBytes))) {

            // Customize QR Code parameters.
            QRCodeOptions options = new QRCodeOptions();
            options.setErrorCorrectionLevel(QRCodeErrorCorrectionLevel.H);
            options.setCompactionMode(QRCodeCompactionMode.AUTO);
            options.setVersion(QRCodeVersion.VERSION_10);
            options.setIncludeQuietZone(true);
            options.setLogo(logo);
            options.setPadding(new Padding(10));
            options.setModuleSize(10);
            options.setShowText(false);

            // Customize QR Code frame parameters.
            RectangleQRFrameOptions frameOptions = new RectangleQRFrameOptions();
            frameOptions.setPadding(new Padding(10));
            frameOptions.setFrameColor(Color.getOrange());
            frameOptions.setFrameWidth(10);
            frameOptions.setText("DevExpress");
            frameOptions.setCornerRadius(10);
            frameOptions.setTextAlignment(QRFrameTextAlignment.CENTER);
            frameOptions.setTextColor(Color.getBlack());
            frameOptions.setTextPosition(QRFrameTextPosition.BOTTOM);

            options.setFrameOptions(frameOptions);

            Path outputDir = Path.of("output");
            Files.createDirectories(outputDir);

            try (FileOutputStream fileStream = new FileOutputStream(
                    outputDir.resolve("qrcode.png").toFile());
                    BarcodeGenerator barcodeGenerator = new BarcodeGenerator(options)) {
                        barcodeGenerator.export(
                                "https://www.devexpress.com",
                                fileStream,
                                DXImageFormat.getPng());
            }
        }
    }
}

Refer to the following help topic for additional information: QR Code.

Implements

com.devexpress.java.enums.IIntEnum

Inherited Members

java.lang.Enum.<T>valueOf(java.lang.Class<T>,java.lang.String)
java.lang.Enum.clone()
java.lang.Enum.compareTo(E)
java.lang.Enum.describeConstable()
java.lang.Enum.equals(java.lang.Object)
java.lang.Enum.finalize()
java.lang.Enum.getDeclaringClass()
java.lang.Enum.hashCode()
java.lang.Enum.name()
java.lang.Enum.ordinal()
java.lang.Enum.toString()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
java.lang.Enum
QRCodeErrorCorrectionLevel