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

微信二維碼代碼生成

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

閱讀全文

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

熱點內容
不同平台數據集如何合並 瀏覽:599
網路主播是什麼軟體 瀏覽:939
thinkpad編程用什麼系列 瀏覽:172
ps照片導出電腦桌面丟失文件 瀏覽:976
好看的旅遊網站模板下載 瀏覽:72
手機里excel文件導出 瀏覽:577
holo手機文件管理器 瀏覽:198
XLS1個文件夾能存多少kB 瀏覽:703
revit2014建築設計教程 瀏覽:723
如何把圖片放到word文件中去 瀏覽:704
開通微信原創是不是每一篇文章 瀏覽:528
編程在大學什麼專業學的好 瀏覽:692
學生文件櫃多少錢 瀏覽:229
文件夾進入cmd 瀏覽:357
數據線編程軟體哪個最好 瀏覽:734
你說什麼美女做什麼的app 瀏覽:596
jsp實現資料庫管理系統 瀏覽:968
電腦word文件怎麼弄到桌面 瀏覽:425
ps文件夾解鎖方法 瀏覽:863
phpsocket多個連接資料庫 瀏覽:87

友情鏈接