導航:首頁 > 編程語言 > 微信二維碼代碼生成

微信二維碼代碼生成

發布時間: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~
真心希望你能採納我的回答,如有不明白,可以繼續追問,若滿意,記得及時採納。

閱讀全文

與微信二維碼代碼生成相關的資料

熱點內容
電腦設置刪除顯示找不到文件 瀏覽:454
中國證券app有哪些 瀏覽:890
天正施工圖教程 瀏覽:428
家庭網路有什麼 瀏覽:126
紅米升級系統找不到私密文件 瀏覽:557
360衛士文件功能描述 瀏覽:350
魅藍e2升級yunos 瀏覽:381
修改ipadID密碼 瀏覽:308
男生去哪裡學編程 瀏覽:772
膩子數據怎麼恢復 瀏覽:699
win10特殊配置文件登錄 瀏覽:55
可視電話電源網站封住了怎麼辦 瀏覽:811
如何列印word批註 瀏覽:152
qq在線表格換成word文件 瀏覽:138
word文檔里找不到文件這欄 瀏覽:969
如何塑造網站內容公信力 瀏覽:502
文件傳閱系統怎麼取消 瀏覽:392
蘋果付費app從哪裡扣費 瀏覽:496
我的咖啡廳快速升級 瀏覽:559
蘋果6手機國行怎麼辨別真假 瀏覽:999

友情鏈接