Created
June 9, 2021 08:13
-
-
Save mevsungur/ea23baa7bc5dc77045a512a835397c4c to your computer and use it in GitHub Desktop.
QR code generator with zxing
This file contains 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
public static BufferedImage createQr(String text, Integer length) throws UnsupportedEncodingException, WriterException { | |
MultiFormatWriter writer = new MultiFormatWriter(); | |
text = new String(text.getBytes("UTF-8"),"UTF-8"); | |
BitMatrix matrix = writer.encode( text, | |
BarcodeFormat.QR_CODE, length, length); | |
BufferedImage bufferedImage = MatrixToImageWriter.toBufferedImage(matrix); | |
return bufferedImage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment