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

微信二维码代码生成

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

阅读全文

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

热点内容
电脑开机后桌面文件全都没有了 浏览:666
wap网站论坛 浏览:55
荣耀4版本信息显示什么字母 浏览:30
dnf虫链怎么升级 浏览:956
将16进制文件读到数组中 浏览:899
caa中怎么提取框选范围数据 浏览:38
为什么用数据登不上王者 浏览:92
yaffs2根文件系统 浏览:477
剑侠情缘微信活动礼包 浏览:985
ipad版本我的世界怎么学赋魔 浏览:571
如何做好网站管理 浏览:280
汤姆猫是什么网站 浏览:913
失易得数据恢复怎么把照片 浏览:185
电脑只显示1个网络 浏览:607
数控加工与编程专业怎么样 浏览:4
西安程序员工资 浏览:389
表格怎么添加一行数据 浏览:35
旅游网站开发怎么选 浏览:669
properties文件位置 浏览:679
不想学编程可以做什么 浏览:22

友情链接