解决方法:
1.在DecodeHandler.java中,修改decode方法
PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(data, width, height);
为
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
int tmp = width; // Here we are swapping, that's the difference to #11
width = height;
height = tmp;
PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(rotatedData, width, height);
2.在CameraManager.java中,注释代码:
// rect.left = rect.left * cameraResolution.x / screenResolution.x;
// rect.right = rect.right * cameraResolution.x / screenResolution.x;
// rect.top = rect.top * cameraResolution.y / screenResolution.y;
// rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
修改为
rect.left = rect.left * cameraResolution.y / screenResolution.x;
rect.right = rect.right * cameraResolution.y / screenResolution.x;
rect.top = rect.top * cameraResolution.x / screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;
3.在CameraConfigurationManager.java中,在setDesiredCameraParameters方法中添加一句
camera.setDisplayOrientation(90);
4.在AndroidManifest.xml中,把Activity的属性android:screenOrientation="landscape"
改为
android:screenOrientation="portrait"
分享到:
相关推荐
亲测,完美支持横屏改竖屏,不变形,识别速度还不错! 包含3.2源码包和修改方法。
ZXing1.6改横屏识别为竖屏识别
在两位大神的原有的资源基础上合而为一,快速全屏扫描出二维码,感谢前人的无私。 使用eclipse,java,zxing,android
Android Zxing 扫描条码实现竖屏模式(portrait mode) 摄像头camera 旋转90度 具体实现
zxing 竖屏直接改竖屏时,扫描的框很小,把扫描框拉大,扫描距离不用拉很长
zxing 竖屏 android 快速 精准 适配
仿微信操作文档,详细介绍了在deLphixe 环境下,调用Zxing 显示横屏转换成竖屏扫描的详细操作说明,结合网上一些例子和台北一些前辈指点后进行整理,希望对你有所帮助。
android上使用ZXing识别条形码和二维码,代码简单易懂,相信能帮助读者迅速掌握相关的开发
ZXing Android二维码/条码扫描,2020 Android Studio版本,横竖屏都支持
Android利用zxing用相机识别二维码,以及识别本地图片二维码,解压后用Android可直接打开,附教程:https://blog.csdn.net/mountain_hua/article/details/80699778
zxing主要竖屏自己也可切换横屏,可根据自己需要去进行修改
Zxing的集成就不说了,但是Zxing默认的是横屏扫码,在实际生产中并不适用,需要改为竖屏扫描。 转竖屏步骤: 1>. AndroidManifest.xml中把activity标签CaptureActivity部分的screenOrientation改为portrait。 ...
目前在实现delphi 扫码过程中,调用基本用ZXing 源代码实现,但显示并不友好,都是横屏模式,通过本操作说明,四步可实现竖屏扫码,值得参考。
Android使用Zxing库识别多个二维码
Android利用zxing生成二维码,识别二维码超详细、超简易demo,解压后用Android studio可直接打开,附教程:https://blog.csdn.net/mountain_hua/article/details/80646089
提供Android 的中文乱码解决 提供从相册获取二维码照片解析 横屏切换为竖屏 提供闪光灯功能
blog http://blog.csdn.net/aaawqqq 提供Android 的中文乱码解决 提供从相册获取二维码照片解析 横屏切换为竖屏 提供闪光灯功能
google zxing源码竖屏完美解决,竖屏时二维码图片不改变大小。
Android利用zxing用相机识别二维码,打开闪光灯,以及识别本地图片二维码,解压后用Android可直接打开。附教程:https://blog.csdn.net/mountain_hua/article/details/80699778