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

微信二維碼代碼生成

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

閱讀全文

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

熱點內容
文件名很長會怎樣 瀏覽: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
網站設計大專工資多少 瀏覽:526
如何操作創業之星app 瀏覽:124
李克克qq 瀏覽:627
文件的規格有哪些 瀏覽:645

友情鏈接