Package com.swetake.util

Examples of com.swetake.util.Qrcode


  }
  private BufferedImage qRCodeCommon(String content, String imgType, int size) { 
            BufferedImage bufImg = null
            try
                Qrcode qrcodeHandler = new Qrcode()
               // ���ö�ά���Ŵ��ʣ���ѡL(7%)��M(15%)��Q(25%)��H(30%)���Ŵ���Խ�߿ɴ洢����ϢԽ�٣����Զ�ά�������ȵ�Ҫ��ԽС 
                qrcodeHandler.setQrcodeErrorCorrect('M')
                qrcodeHandler.setQrcodeEncodeMode('B')
                // �������ö�ά��ߴ磬ȡֵ��Χ1-40��ֵԽ��ߴ�Խ�󣬿ɴ洢����ϢԽ�� 
                qrcodeHandler.setQrcodeVersion(size)
               // ������ݵ��ֽ����飬���ñ����ʽ 
               byte[] contentBytes = content.getBytes("utf-8")
                // ͼƬ�ߴ� 
               int imgSize = 67 + 12 * (size - 1)
                bufImg = new BufferedImage(imgSize, imgSize, BufferedImage.TYPE_INT_RGB)
                Graphics2D gs = bufImg.createGraphics()
                // ���ñ�����ɫ 
               gs.setBackground(Color.WHITE)
               gs.clearRect(0, 0, imgSize, imgSize)
   
               // �趨ͼ����ɫ> BLACK 
               gs.setColor(Color.BLACK)
                // ����ƫ�����������ÿ��ܵ��½������� 
               int pixoff = 2
                // �������> ��ά�� 
               if (contentBytes.length > 0 && contentBytes.length < 800) { 
                  boolean[][] codeOut = qrcodeHandler.calQrcode(contentBytes)
                    for (int i = 0; i < codeOut.length; i++) { 
                      for (int j = 0; j < codeOut.length; j++) { 
                           if (codeOut[j][i]) { 
                           gs.fillRect(j * 3 + pixoff, i * 3 + pixoff, 3, 3)
                           
View Full Code Here

TOP

Related Classes of com.swetake.util.Qrcode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.