這個生成的二維碼怎么做才能讓它實現(xiàn)掃碼跳轉(zhuǎn)到網(wǎng)頁呀,老師講的都是直接顯示出字符串來。。。 Qrcode?x?=?new?Qrcode();
x.setQrcodeErrorCorrect('M');//?糾錯等級
x.setQrcodeEncodeMode('B');//?N代表數(shù)字,A代表a-,B代表其他字符
x.setQrcodeVersion(7);//?版本
String?qrData?=?"idcbgp.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"));
}
1 回答
已采納

iHelin
TA貢獻(xiàn)5條經(jīng)驗 獲得超1個贊
String?qrData?=?"http://idcbgp.cn";,其實這個也是app自己實現(xiàn)的識別跳轉(zhuǎn),本質(zhì)上其實還是一段文本
添加回答
舉報
0/150
提交
取消