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

微信二维码代码生成

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

阅读全文

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

热点内容
文件夹书包 浏览:367
android判断xml文件是否存在 浏览:701
word2010左边文字右边图片 浏览:884
文件放在桌面却找不到 浏览:903
文件名很长会怎样 浏览:541
js获取文本框的位置 浏览:242
源文件名如何定 浏览:294
word工具栏的文件图标在哪里 浏览:297
win10cmd安装系统文件位置 浏览:705
文件拷进u盘乱码 浏览:992
网上恢复数据的哪些网站 浏览:800
86版本召唤满暴击多少 浏览:245
封条样式图片文件 浏览:198
xsmas如何设置让网络更快 浏览:933
word怎么删除符号 浏览:785
文件夹图片名字统一 浏览:75
破解收费网站密码 浏览:123
编程组用英文怎么说 浏览:707
android获取json数据 浏览:427
头条别人发文件过来在哪里看 浏览:922

友情链接