Last active
August 6, 2019 08:36
-
-
Save thieunguyenhung/da8ca16adc281f6b7d0ee6be89ab2e35 to your computer and use it in GitHub Desktop.
Example how to create BitMatrix of QR code with Google ZXing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.zxing.BarcodeFormat; | |
import com.google.zxing.EncodeHintType; | |
import com.google.zxing.WriterException; | |
import com.google.zxing.common.BitMatrix; | |
import com.google.zxing.qrcode.QRCodeWriter; | |
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; | |
import java.util.HashMap; | |
import java.util.Map; | |
//....... | |
private BitMatrix createBitMatrix(String qrCodeText, int size) throws WriterException { | |
Map<EncodeHintType, Object> hints = new HashMap<>(); | |
hints.put(EncodeHintType.MARGIN, DEFAULT_MARGIN); | |
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); | |
return new QRCodeWriter().encode(qrCodeText, BarcodeFormat.QR_CODE, size, size, hints); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment