這個生成的二維碼怎么做才能讓它實現掃碼跳轉到網頁呀,老師講的都是直接顯示出字符串來。。。 Qrcode?x?=?new?Qrcode();
x.setQrcodeErrorCorrect('M');//?糾錯等級
x.setQrcodeEncodeMode('B');//?N代表數字,A代表a-,B代表其他字符
x.setQrcodeVersion(7);//?版本
String?qrData?=?"www.xianlaiwan.cn";
int?width?=?67?+?12?*?(?7?-?1?);
int?height?=?67?+?12?*?(?7?-?1?);
BufferedImage?bufferedImage?=?new?BufferedImage(width,?height,?BufferedImage.TYPE_INT_RGB);
Graphics2D?gs?=?bufferedImage.createGraphics();
gs.setBackground(Color.white);
gs.setColor(Color.black);
gs.clearRect(0,?0,?width,?height);
int?pixoff?=?2;//?偏移量
byte[]?d?=?qrData.getBytes("gb2312");
if?(d.length?>?0?&&?d.length?<?120)?{
boolean[][]?s?=?x.calQrcode(d);
for?(int?i?=?0;?i?<?s.length;?i++)?{
for?(int?j?=?0;?j?<?s.length;?j++)?{
if?(s[j][i])?{
gs.fillRect(j?*?3?+?pixoff,?i?*?3?+?pixoff,?3,?3);
}
}
}
}
//如果要是修改的話是不是得需要把上邊的String改成Url去處理呢?求解答
gs.dispose();
bufferedImage.flush();
ImageIO.write(bufferedImage,?"png",?new?File("D:/code/qrcode.png"));
}
添加回答
舉報
0/150
提交
取消