ネットワークから
ImageIOを使用して、ネットワーク画像(QRコード)またはローカル画像を読み取ります
1つの読み取りネットワーク画像
public static String analysisReadQRCode(String path){
MultiFormatReader multiFormatReader=new MultiFormatReader();
HashMap hints=new HashMap();
hints.put(EncodeHintType.CHARACTER_SET,"GBK");
try{
URL url = new URL(path);
BufferedImage source= ImageIO.read(url);
BinaryBitmap binaryImg=new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(source)));
Result result=multiFormatReader.decode(binaryImg,hints);
return result.getText();
}catch (Exception e){
e.printStackTrace();
}
return "";
}
2つの読み取りネットワーク画像
public static String analysisReadQRCode(String path){
MultiFormatReader multiFormatReader=new MultiFormatReader();
HashMap hints=new HashMap();
hints.put(EncodeHintType.CHARACTER_SET,"GBK");
try{
BufferedImage source= ImageIO.read(new File(path));
BinaryBitmap binaryImg=new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(source)));
Result result=multiFormatReader.decode(binaryImg,hints);
return result.getText();
}catch (Exception e){
e.printStackTrace();
}
return "";
}