Last active
March 31, 2022 06:37
-
-
Save Iltwats/98dde00eb29dc04739e37fa64822369d to your computer and use it in GitHub Desktop.
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
private void qrGeneration(String qrText) { | |
QRCodeWriter writer = new QRCodeWriter(); | |
try { | |
BitMatrix bitMatrix = writer.encode(qrText, BarcodeFormat.QR_CODE, 564, 564); | |
int width = bitMatrix.getWidth(); | |
int height = bitMatrix.getHeight(); | |
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); | |
for (int x = 0; x < width; x++) { | |
for (int y = 0; y < height; y++) { | |
bmp.setPixel(x, y, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE); | |
} | |
} | |
bitmap = bmp; | |
((ImageView) findViewById(R.id.qrImage)).setImageBitmap(bmp); | |
} catch (WriterException e) { | |
e.printStackTrace(); | |
} | |
} | |
// Just set the bitmap to any imageView you want it to show. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment