/** * 图片解析 */ protected ShadowSocksDetailsEntity parseURL(String imgURL) throws IOException, NotFoundException { Connection.Response resultImageResponse = getConnection(imgURL).execute(); Map<DecodeHintType, Object> hints = new LinkedHashMap<>(); // 解码设置编码方式为:utf-8, hints.put(DecodeHintType.CHARACTER_SET, StandardCharsets.UTF_8.name()); //优化精度 hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); //复杂模式,开启PURE_BARCODE模式 hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE); try (BufferedInputStream bytes = resultImageResponse.bodyStream()) { BufferedImage image = ImageIO.read(bytes); Binarizer binarizer = new HybridBinarizer(new BufferedImageLuminanceSource(image)); BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer); Result res = new MultiFormatReader().decode(binaryBitmap, hints); return parseLink(res.toString()); } }