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

微信二維碼代碼生成

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

閱讀全文

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

熱點內容
表格怎麼添加一行數據 瀏覽:35
旅遊網站開發怎麼選 瀏覽:669
properties文件位置 瀏覽:679
不想學編程可以做什麼 瀏覽:22
手機照片一鍵壓縮成文件 瀏覽:962
女生微信霸氣個性簽名 瀏覽:626
微博如何看別人一個月的數據 瀏覽:14
萬能小組件怎麼點擊就進入app應用 瀏覽:817
蘋果5s變形怎麼恢復 瀏覽:286
電腦里文件密碼忘了咋辦啊 瀏覽:315
輸入文件夾 瀏覽:31
extjsgrid刪除列 瀏覽:43
gdx文件怎麼打開 瀏覽:759
如何更新大數據量表 瀏覽:311
特殊量產工具 瀏覽:980
安卓網路顯示h2是什麼意思 瀏覽:90
哪個拍照app好 瀏覽:70
文件被設置隱藏屬性如何顯示 瀏覽:142
網路電視的好處 瀏覽:657
cf槍戰王者手游下載官網下載最新版本下載 瀏覽:925

友情鏈接