Skip to main content

CornerQRFrameOptions Class

Contains options that customize a frame and associated text around a QR code.

Declaration

public class CornerQRFrameOptions extends QRFrameOptions

Remarks

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

QR Code with Corner Frame, DevExpress Barcode Generation API for Java

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.
            CornerQRFrameOptions frameOptions = new CornerQRFrameOptions();
            frameOptions.setPadding(new Padding(10));
            frameOptions.setFrameColor(Color.getOrange());
            frameOptions.setFrameWidth(10);
            frameOptions.setText("DevExpress");
            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());
            }
        }
    }
}

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
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
JavaObject
QRFrameOptions
CornerQRFrameOptions

CornerQRFrameOptions()

Initializes a new instance of the CornerQRFrameOptions class.

Declaration

public CornerQRFrameOptions()

Methods

getFrameColor() Method

Gets a QR code’s frame color.

Declaration

public Color getFrameColor()

Returns

Type Description
Color

The frame color.

getFrameWidth() Method

Gets a QR code’s frame width.

Declaration

public float getFrameWidth()

Returns

Type Description
float

The frame width.

getPadding() Method

Gets a QR code’s padding.

Declaration

public Padding getPadding()

Returns

Type Description
Padding

The padding.

getText() Method

Gets a QR code’s frame text.

Declaration

public String getText()

Returns

Type Description
String

The frame text.

getTextAlignment() Method

Gets a QR code’s frame text alignment.

Declaration

public QRFrameTextAlignment getTextAlignment()

Returns

Type Description
QRFrameTextAlignment

The frame text alignment.

getTextColor() Method

Gets a QR code’s frame text color.

Declaration

public Color getTextColor()

Returns

Type Description
Color

The frame text color.

getTextPosition() Method

Gets a QR code’s frame text position.

Declaration

public QRFrameTextPosition getTextPosition()

Returns

Type Description
QRFrameTextPosition

The frame text position.

setFrameColor(Color value) Method

Sets a QR code’s frame color.

Declaration

public void setFrameColor(Color value)

Parameters

Name Type Description
value Color

The frame color.

setFrameWidth(float value) Method

Sets a QR code’s frame width.

Declaration

public void setFrameWidth(float value)

Parameters

Name Type Description
value float

The frame width.

setPadding(Padding value) Method

Sets a QR code’s padding.

Declaration

public void setPadding(Padding value)

Parameters

Name Type Description
value Padding

The padding.

setText(String value) Method

Sets a QR code’s frame text.

Declaration

public void setText(String value)

Parameters

Name Type Description
value String

The frame text.

setTextAlignment(QRFrameTextAlignment value) Method

Sets a QR code’s frame text alignment.

Declaration

public void setTextAlignment(QRFrameTextAlignment value)

Parameters

Name Type Description
value QRFrameTextAlignment

The frame text alignment.

setTextColor(Color value) Method

Sets a QR code’s frame text color.

Declaration

public void setTextColor(Color value)

Parameters

Name Type Description
value Color

The frame text color.

setTextPosition(QRFrameTextPosition value) Method

Sets a QR code’s frame text position.

Declaration

public void setTextPosition(QRFrameTextPosition value)

Parameters

Name Type Description
value QRFrameTextPosition

The frame text position.