ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

JavaÉú³É¶þάÂë·½·¨ÊÂÀý
2014-11-24 07:34:56 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:1´Î
Tags£ºJava Éú³É ¶þά ·½·¨ ÊÂÀý

JavaÉú³É¶þάÂë·½·¨ÊÂÀý


import java.io.*;
import java.util.Date;


import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;


import com.swetake.util.Qrcode;


public class QRCodeEncoderTest {
public QRCodeEncoderTest() {
}


public static void create_image(String sms_info) throws Exception {
try {
Qrcode testQrcode = new Qrcode();
testQrcode.setQrcodeErrorCorrect('M');
testQrcode.setQrcodeEncodeMode('B');
testQrcode.setQrcodeVersion(20);
String testString = sms_info;
byte[] d = testString.getBytes("gbk");
System.out.println(d.length);
BufferedImage bi = new BufferedImage(98, 98,
BufferedImage.TYPE_BYTE_BINARY);
Graphics2D g = bi.createGraphics();
g.setBackground(Color.WHITE);
g.clearRect(0, 0, 98, 98);
g.setColor(Color.BLACK);
// ÏÞÖÆ×î´ó×Ö½ÚÊýΪ120
if (d.length > 0 && d.length < 300) {
boolean[][] s = testQrcode.calQrcode(d);
for (int i = 0; i < s.length; i++) {
for (int j = 0; j < s.length; j++) {
if (s[j][i]) {
g.fillRect(j * 2 + 3, i * 2 + 3, 2, 2);
}
}
}
}
g.dispose();
bi.flush();
File f = new File("D:\\QRCodeTest\\" + sms_info + ".jpg");
if (!f.exists()) {
f.createNewFile();
}
// ´´½¨Í¼Æ¬
ImageIO.write(bi, "jpg", f);


} // end try
catch (Exception e) {
e.printStackTrace();
} // end catch
}


public static void main(String[] args) throws Exception {
System.out.println(new Date());
QRCodeEncoderTest.create_image("QRCode");
System.out.println(new Date());
}
}


Ò»·ÝJava Éú³É¶þάÂëʵÀýÍêÕûÔ´ÂëÏÂÔØ£º


**************************************************************


ÏÂÔØÔÚLinux¹«ÉçµÄ1ºÅFTP·þÎñÆ÷ÀÏÂÔØµØÖ·£º


ÃÜÂ룺www.muu.cc


ÔÚ 2013ÄêLinuxIDC.com\4ÔÂ\JavaÉú³É¶þάÂë·½·¨ÊÂÀý


ÏÂÔØ·½·¨¼û http://www.linuxidc.net/thread-1187-1-1.html


**************************************************************


¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºOK6410-A±àÒëu-bootʱÓöµ½µÄÎÊÌâ.. ÏÂһƪ£ºUbuntuϵĽøÐж¯Ì¬Á´½Ó¿â´´½¨ºÍ..

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ:

¡¤Linuxϵͳ¼ò½é (2025-12-25 21:55:25)
¡¤Linux°²×°MySQL¹ý³Ì (2025-12-25 21:55:22)
¡¤Linuxϵͳ°²×°½Ì³Ì£¨ (2025-12-25 21:55:20)
¡¤HTTP Åc HTTPS µÄ²î„ (2025-12-25 21:19:45)
¡¤ÍøÕ¾°²È«±ØÐ޿ΣºÍ¼ (2025-12-25 21:19:42)