导航:首页 > 编程语言 > 微信二维码代码生成

微信二维码代码生成

发布时间:2023-07-05 05:57:49

『壹』 怎么把一串代码变成二维码

亲,我写了一段代码可以供你参考:
public static void main(String[] args) {
String myCodeText = "http://Crunchify.com/";
String filePath = "/Users/appshah/Documents/eclipsewp/CrunchifyQR.png";
int size = 125;
String fileType = "png";
File myFile = new File(filePath);
try {
Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix byteMatrix = qrCodeWriter.encode(myCodeText,BarcodeFormat.QR_CODE, size, size, hintMap);
int CrunchifyWidth = byteMatrix.getWidth();
BufferedImage image = new BufferedImage(CrunchifyWidth, CrunchifyWidth,
BufferedImage.TYPE_INT_RGB);
image.createGraphics();

Graphics2D graphics = (Graphics2D) image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, CrunchifyWidth, CrunchifyWidth);
graphics.setColor(Color.BLACK);

for (int i = 0; i < CrunchifyWidth; i++) {
for (int j = 0; j < CrunchifyWidth; j++) {
if (byteMatrix.get(i, j)) {
graphics.fillRect(i, j, 1, 1);
}
}
}
ImageIO.write(image, fileType, myFile);
} catch (WriterException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("\n\nYou have successfully created QR Code.");
}

O(∩_∩)O~温馨提示O(∩_∩)O~
真心希望你能采纳我的回答,如有不明白,可以继续追问,若满意,记得及时采纳。

阅读全文

与微信二维码代码生成相关的资料

热点内容
电脑应用程序怎么关 浏览:986
微信上链接在哪个文件夹 浏览:691
欧姆龙安装打开找不到密钥文件 浏览:302
苹果基本表情 浏览:128
我的世界教育版编程在哪里 浏览:842
pong文件夹找不到 浏览:759
69版本黑切 浏览:997
杭州道富java 浏览:635
知道qq号查微博账号和密码 浏览:294
红手指自带哪些app 浏览:103
手机用公司网络会被监控哪些 浏览:409
什么叫py编程 浏览:370
微信红包尾数作弊器ios 浏览:280
ipad备份文件夹 浏览:555
vivo手机qq下载的文件在哪里 浏览:303
如何导出ug的编程档 浏览:343
编程课如何提到游戏 浏览:430
微信里怎么帮别人集赞 浏览:20
灵犀语音motox锁屏密码 浏览:336
w7怎么添加网络打印机 浏览:463

友情链接