欧美free性护士vide0shd,老熟女,一区二区三区,久久久久夜夜夜精品国产,久久久久久综合网天天,欧美成人护士h版

首頁綜合 正文
目錄

柚子快報激活碼778899分享:java 二維碼制作與解析

柚子快報激活碼778899分享:java 二維碼制作與解析

http://yzkb.51969.com/

文章目錄

前言一、加入依賴二、二維碼制作三、二維碼解析總結(jié)

前言

掃碼跳轉(zhuǎn)地址,解析二維碼,連接wifi。

一、加入依賴

? ? ? ? ? ? com.google.zxing

? ? ? ? ? ? core

? ? ? ? ? ? 3.3.0

? ? ? ?

? ? ? ?

? ? ? ? ? ? com.google.zxing

? ? ? ? ? ? android-core

? ? ? ? ? ? 3.3.0

? ? ? ?

? ? ? ?

? ? ? ? ? ? com.google.zxing

? ? ? ? ? ? android-integration

? ? ? ? ? ? 3.3.0

? ? ? ?

? ? ? ?

? ? ? ? ? ? com.google.zxing

? ? ? ? ? ? javase

? ? ? ? ? ? 3.3.0

? ? ? ?

二、二維碼制作

//圖片的寬度和高度

int width = 300;

int height = 300;

//圖片的格式

String format = "png";

//內(nèi)容,此處放你想要放的內(nèi)容(例如網(wǎng)頁鏈接),若是網(wǎng)址鏈接,要加上 "http://" 才能被微信識別,

//地址:"http://baidu.com"

//掃碼連接wife需要特定的字符串,自行搜索

String content = "這里填你想輸入的信息";

//定義二維碼的參數(shù)

HashMap hints = new HashMap();

//編碼

hints.put(EncodeHintType.CHARACTER_SET, "utf-8");

//容錯等級,與二維碼存儲的大小有關(guān),一般選擇M

hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);

//邊距

hints.put(EncodeHintType.MARGIN, 2);

//生成二維碼

try {

BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);

//存放二維碼路徑

Path file = new File("E:/img.png").toPath();

MatrixToImageWriter.writeToPath(bitMatrix, format, file);

} catch (Exception e) {

e.printStackTrace();

}

三、二維碼解析

try {

MultiFormatReader multiFormatReader = new MultiFormatReader();

//二維碼的存放位置

File file = new File("E:/img.png");

//創(chuàng)建一個圖片緩沖區(qū)

BufferedImage image = ImageIO.read(file);

//對圖片進(jìn)行解析

BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(image)));

//定義二維碼的參數(shù)

HashMap hints = new HashMap();

//編碼

hints.put(EncodeHintType.CHARACTER_SET, "utf-8");

//得到解析后的result

Result result = multiFormatReader.decode(binaryBitmap, hints);

System.out.println("解析結(jié)果:" + result.toString());

System.out.println("二維碼格式類型·:" + result.getBarcodeFormat());

} catch (NotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

?把代碼拷貝到mian方法里面直接跑就行。

總結(jié)

以上就是今天要講的內(nèi)容,本文僅僅簡單介紹了二維碼的使用。

柚子快報激活碼778899分享:java 二維碼制作與解析

http://yzkb.51969.com/

推薦文章

評論可見,查看隱藏內(nèi)容

本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場。

轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。

本文鏈接:http://gantiao.com.cn/post/18964667.html

發(fā)布評論

您暫未設(shè)置收款碼

請在主題配置——文章設(shè)置里上傳

掃描二維碼手機(jī)訪問

文章目錄