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

微信二维码代码生成

发布时间: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~
真心希望你能采纳我的回答,如有不明白,可以继续追问,若满意,记得及时采纳。

阅读全文

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

热点内容
没有网络怎么定位 浏览:972
剪切到优盘文件找不到了 浏览:764
电脑管家的文件名 浏览:910
如何将扫描文件转换为电子版 浏览:4
u盘的h246文件怎么播放 浏览:203
如何用阿里云服务器学习数据库 浏览:84
华为文件管理找不到下载文件 浏览:409
word模板dot的使用 浏览:466
春节车找人app哪个好 浏览:618
文件管理电脑找不到了怎么办 浏览:516
如何改变app图标图片 浏览:767
什么是大数据结构的最低层 浏览:575
pdf文件给对方后期改密码收回 浏览:295
word2010怎么画箭头 浏览:184
win10的自动备份文件在哪个目录 浏览:843
文件夹打包成jar 浏览:456
卸载鲁大师找不到文件 浏览:173
汇编程序不知道哪里有错误 浏览:821
ai视频教程cs5 浏览:379
亿林网络怎么样 浏览:102

友情链接