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

微信二维码代码生成

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

阅读全文

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

热点内容
岳阳微信公司 浏览:96
win10如何从备份中恢复出厂设置密码 浏览:659
什么软件修改wifi密码错误 浏览:582
遇见不安全网站怎么办 浏览:251
哪个app有庆余年电视剧 浏览:420
iphone5s视频时很黑 浏览:601
js获取端口号 浏览:347
手机短息发的链接病毒苹果手机 浏览:724
win10专业忘记家庭组密码 浏览:176
南宁applestore几楼 浏览:296
java字符串怎么初始化 浏览:349
医美哪个app好 浏览:768
代码编程和机器人编程哪个好 浏览:875
90版本男法 浏览:796
win10桌面字体难看 浏览:848
三菱fx5u支持哪些编程 浏览:7
优酷在文件夹在哪里 浏览:91
趣打印的数据文件是什么 浏览:871
linuxjava程序 浏览:483
苹果6splus数据线图片 浏览:98

友情链接