首先,我阅读了所有这些主题如何在Java中使用Zxing,但总是遇到错误,因为缺少com.google.zxing.client.j2se.*(我在eclipse中加载了zxing core-3.2.1.jar和其他所有zxing包工作除非j2se)或刚刚找到创建qr图像的解决方案......
我的目标是编写一个单独的方法,它获取一个图像文件在这个图像中找到qr代码,解码qr代码并返回字符串,基本上它应该是如下所示:
import com.google.zxing.*;
public class QRCode {
/*
* ...
*/
public String getDecodedString(SomeStandardImageType photo){
// detect the qr code in a photo
// create qr image from detected area in photo
// decode the new created qr image and return the string
return "This is the decoded dataString from the qr code in the photo";
}
}
Run Code Online (Sandbox Code Playgroud)
总结一下该方法应该得到如下图像文件
并且应该返回url或者如果失败只是"".
代码应与Zxing 3.2.1兼容.
编辑:问题解决了.对于对此感兴趣的其他人,我想说,将外部罐子core-3.2.1.jar 和 javase-3.2.1.jar外部罐子都添加起来非常重要.我的答案没有后者,但取决于android图像库.