提交 f1d1144c authored 作者: zhoushaopan's avatar zhoushaopan

[二维码]解析二维码

上级 e8964dbe
...@@ -37,74 +37,11 @@ public class ZXingUtil { ...@@ -37,74 +37,11 @@ public class ZXingUtil {
/** /**
* 解析二维码 * 解析二维码
* *
* @param name 文件名 * @param file 文件名
* @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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论