qrbuilder

qrcode generator

License

License

GroupId

GroupId

club.lemos
ArtifactId

ArtifactId

qrbuilder
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

qrbuilder
qrcode generator
Project URL

Project URL

https://github.com/lemos1235/qrbuilder
Source Code Management

Source Code Management

https://github.com/lemos1235/qrbuilder

Download qrbuilder

How to add to project

<!-- https://jarcasting.com/artifacts/club.lemos/qrbuilder/ -->
<dependency>
    <groupId>club.lemos</groupId>
    <artifactId>qrbuilder</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/club.lemos/qrbuilder/
implementation 'club.lemos:qrbuilder:1.0.1'
// https://jarcasting.com/artifacts/club.lemos/qrbuilder/
implementation ("club.lemos:qrbuilder:1.0.1")
'club.lemos:qrbuilder:jar:1.0.1'
<dependency org="club.lemos" name="qrbuilder" rev="1.0.1">
  <artifact name="qrbuilder" type="jar" />
</dependency>
@Grapes(
@Grab(group='club.lemos', module='qrbuilder', version='1.0.1')
)
libraryDependencies += "club.lemos" % "qrbuilder" % "1.0.1"
[club.lemos/qrbuilder "1.0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
com.google.zxing : core jar 3.4.0
com.google.zxing : javase jar 3.4.0

test (1)

Group / Artifact Type Version
org.testng : testng jar 6.8

Project Modules

There are no modules declared in this project.

This is a simple qrcode builder that is copied from https://github.com/skrymer/qrbuilder

QRCodeBuilder

The builder is very simple to use, as the following example will shows.

Add the following dependency in pom.xml.

<!-- replace here with the latest version -->
<dependency>
  <groupId>club.lemos</groupId>
  <artifactId>qrbuilder</artifactId>
  <version>1.0.1</version>
</dependency>

Create a QRCode with dimensions 250*250, a image overlay and some data:

public class Main {
  public static final float TRANSPARENCY = 0.20f;
  public static final float OVERLAY_RATIO = 1f;
  public static final int WIDTH = 250;
  public static final int HEIGHT = 250;

  public static void main(String[] args) throws Exception {
    QRCode.ZXingBuilder.build(builder ->
        builder
            .withSize(WIDTH, HEIGHT)
            .and()
            .withData(loremIpsum)
            .and()
            .withDecorator(ColoredQRCode.colorizeQRCode(Color.green.darker()))
            .and()
            .withDecorator(ImageOverlay.addImageOverlay(readImage("src/test/resources/images/skull_bw.png"), TRANSPARENCY, OVERLAY_RATIO))
            .and()
            .withCharSet(StandardCharsets.UTF_8)
            .verify(true)

    ).toFile("./qrCode.png", "PNG");
  }

  public static BufferedImage readImage(String path) {
    try {
      return ImageIO.read(new File(path));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }

  private static final String loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam scelerisque dictum ipsum, mollis faucibus neque. Vestibulum suscipit eu urna eget lobortis.";
}

The following qrCode is then generated:

alt text

Decorators

The builder uses the decorators to decorate(obviously) the generated QRCode.

Decorators currently available:

  • ImageOverlay
  • ColoredQRCode

You can create new Decorators by implementing the Decorator interface

Versions

Version
1.0.1