Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public BufferedImage crearQR(String datos, int ancho, int altura) throws WriterException {
  2. BitMatrix matrix;
  3. Writer escritor = new QRCodeWriter();
  4. matrix = escritor.encode(datos, BarcodeFormat.QR_CODE, ancho, altura);
  5.  
  6. BufferedImage imagen = new BufferedImage(ancho, altura, BufferedImage.TYPE_INT_RGB);
  7.  
  8. for(int y = 0; y < altura; y++) {
  9. for(int x = 0; x < ancho; x++) {
  10. int grayValue = (matrix.get(x, y) ? 0 : 1) & 0xff;
  11. imagen.setRGB(x, y, (grayValue == 0 ? 0 : 0xFFFFFF));
  12. }
  13. }
  14.  
  15. return imagen;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement