Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public BufferedImage crearQR(String datos, int ancho, int altura) throws WriterException {
- BitMatrix matrix;
- Writer escritor = new QRCodeWriter();
- matrix = escritor.encode(datos, BarcodeFormat.QR_CODE, ancho, altura);
- BufferedImage imagen = new BufferedImage(ancho, altura, BufferedImage.TYPE_INT_RGB);
- for(int y = 0; y < altura; y++) {
- for(int x = 0; x < ancho; x++) {
- int grayValue = (matrix.get(x, y) ? 0 : 1) & 0xff;
- imagen.setRGB(x, y, (grayValue == 0 ? 0 : 0xFFFFFF));
- }
- }
- return imagen;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement