mvallim / emv-qrcode

Java Based EMV QR Code Generator and Parser (MPM, CPM)
https://mvallim.github.io/emv-qrcode/
Apache License 2.0
95 stars 46 forks source link

Support for ISO 18004 #24

Closed sloopsight closed 3 years ago

sloopsight commented 3 years ago

Could please confirm if this lib has capability to generate ISO 18004 QR code if not does zing does?

mvallim commented 3 years ago

Hi @sloopsight,

No, it doesn't.

But lib Zing has the ability to do this job easily.

Thanks,

mvallim commented 3 years ago

Hi @sloopsight,

Ex.

pom.xml

<dependency>
  <groupId>com.google.zxing</groupId>
  <artifactId>core</artifactId>
  <version>3.4.1</version>
</dependency>

<dependency>
  <groupId>com.google.zxing</groupId>
  <artifactId>javase</artifactId>
  <version>3.4.1</version>
</dependency>

QRCodeImage.java

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;

public final class QRCodeImage {

  private QRCodeImage() {
    super();
  }

  /**
   * Create QRCode image
   *
   * @param value Base64 string
   * @return array of bytes image
   * @throws IOException
   * @throws WriterException
   */
  public static byte[] create(final String value) throws IOException, WriterException {
    try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
      final QRCodeWriter qrcodeWriter = new QRCodeWriter();
      final BitMatrix bitMatrix = qrcodeWriter.encode(value, BarcodeFormat.QR_CODE, 100, 100);
      final BufferedImage bufferedImage = MatrixToImageWriter.toBufferedImage(bitMatrix);
      ImageIO.write(bufferedImage, "png", outputStream);
      return outputStream.toByteArray();
    }
  }

}
mvallim commented 3 years ago

Closing this issue for being without activity.