Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
f1d1144c
提交
f1d1144c
authored
7月 20, 2021
作者:
zhoushaopan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[二维码]解析二维码
上级
e8964dbe
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
75 行删除
+11
-75
ZXingUtil.java
...c/main/java/com/tykj/dev/device/zxing/util/ZXingUtil.java
+11
-75
没有找到文件。
dev-zxing/src/main/java/com/tykj/dev/device/zxing/util/ZXingUtil.java
浏览文件 @
f1d1144c
...
@@ -37,74 +37,11 @@ public class ZXingUtil {
...
@@ -37,74 +37,11 @@ public class ZXingUtil {
/**
/**
* 解析二维码
* 解析二维码
*
*
* @param
nam
e 文件名
* @param
fil
e 文件名
* @return 二维码内容
* @return 二维码内容
* @throws IOException
* @throws IOException
* @throws NotFoundException
* @throws NotFoundException
*/
*/
// public ResponseEntity upload(HttpServletRequest request) {
// MultipartRequest multiRequest = (MultipartRequest) request;
// MultipartFile file = multiRequest.getFile("file");
// return ResponseEntity.ok(fileUpload(file));
// }
// private void fileUpload(MultipartFile file) {
// String originalFilename = file.getOriginalFilename();
// File file1 = new File(url);
// if (!file1.exists()) {
// file1.mkdirs();
// }
// FileOutputStream fos = null;
// InputStream inputStream = null;
// OutputStream os = null;
//
// String[] split = originalFilename.split("\\.");
// String newName = UUID.randomUUID().toString().replace("-", "") + "." + split[split.length - 1];
// byte[] typeByte = new byte[1024 * 1024 * 10];
// try {
// inputStream = file.getInputStream();
// fos = new FileOutputStream(url + newName);
// int i = 0;
// while ((i = inputStream.read(typeByte)) != -1) {
// fos.write(typeByte, 0, i);
// }
// fos.flush();
// } catch (IOException e) {
// e.printStackTrace();
// }
// if (inputStream != null) {
// try {
// inputStream.close();
// } catch (IOException e) {
// e.printStackTrace();
// } finally {
// inputStream = null;
// }
// }
//
// if (fos != null) {
// try {
// fos.close();
// } catch (IOException e) {
// e.printStackTrace();
// } finally {
// fos = null;
// }
// }
//
// if (os != null) {
// try {
// os.close();
// } catch (IOException e) {
// e.printStackTrace();
// } finally {
// os = null;
// }
// }
//
// return new FileRet(originalFilename, url + newName, preview + newName);
// }
// public static String decode(String name) throws IOException, com.google.zxing.NotFoundException {
// public static String decode(String name) throws IOException, com.google.zxing.NotFoundException {
// String filepath = codePath + name + ".png";
// String filepath = codePath + name + ".png";
// BufferedImage bufferedImage = ImageIO.read(new FileInputStream(filepath));
// BufferedImage bufferedImage = ImageIO.read(new FileInputStream(filepath));
...
@@ -116,17 +53,16 @@ public class ZXingUtil {
...
@@ -116,17 +53,16 @@ public class ZXingUtil {
// Result result = new MultiFormatReader().decode(bitmap, decodeHints);
// Result result = new MultiFormatReader().decode(bitmap, decodeHints);
// return result.getText();
// return result.getText();
// }
// }
// public static String decode() throws IOException, com.google.zxing.NotFoundException {
public
static
String
decode
(
MultipartFile
file
)
throws
IOException
,
com
.
google
.
zxing
.
NotFoundException
{
// String filepath = codePath + name + ".png";
BufferedImage
bufferedImage
=
ImageIO
.
read
(
new
FileInputStream
((
File
)
file
));
// BufferedImage bufferedImage = ImageIO.read(new FileInputStream(filepath));
LuminanceSource
source
=
new
BufferedImageLuminanceSource
(
bufferedImage
);
// LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
Binarizer
binarizer
=
new
HybridBinarizer
(
source
);
// Binarizer binarizer = new HybridBinarizer(source);
BinaryBitmap
bitmap
=
new
BinaryBitmap
(
binarizer
);
// BinaryBitmap bitmap = new BinaryBitmap(binarizer);
HashMap
<
DecodeHintType
,
Object
>
decodeHints
=
new
HashMap
<
DecodeHintType
,
Object
>();
// HashMap<DecodeHintType, Object> decodeHints = new HashMap<DecodeHintType, Object>();
decodeHints
.
put
(
DecodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
// decodeHints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
Result
result
=
new
MultiFormatReader
().
decode
(
bitmap
,
decodeHints
);
// Result result = new MultiFormatReader().decode(bitmap, decodeHints);
return
result
.
getText
();
// return result.getText();
}
// }
/**
/**
* 生成二维码
* 生成二维码
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论