推荐安卓开发神器(里面有各种UI特效和android代码库实例)
解决方法:
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"
编译运行即可!
参考:
http://code.google.com/p/zxing/issues/detail?id=178#c46
代码:
https://github.com/pplante/zxing-android
相关推荐
ZXing1.6改横屏识别为竖屏识别
亲测,完美支持横屏改竖屏,不变形,识别速度还不错! 包含3.2源码包和修改方法。
zxing 竖屏直接改竖屏时,扫描的框很小,把扫描框拉大,扫描距离不用拉很长
在两位大神的原有的资源基础上合而为一,快速全屏扫描出二维码,感谢前人的无私。 使用eclipse,java,zxing,android
目前在实现delphi 扫码过程中,调用基本用ZXing 源代码实现,但显示并不友好,都是横屏模式,通过本操作说明,四步可实现竖屏扫码,值得参考。
zxing主要竖屏自己也可切换横屏,可根据自己需要去进行修改
Android Zxing 扫描条码实现竖屏模式(portrait mode) 摄像头camera 旋转90度 具体实现
二维码扫描Zxing横竖屏都支持,还可以切换激光线。花了不少时间阅读Zxing源码,相比之下,比百度,淘宝,京东的二维码扫描功能要强,适合大家把这个功能添加到你们的项目中.
Zxing二维码扫描,竖屏仿QQ扫一扫
zxing3.2.1修改成横屏源代码
zxing完美竖屏扫码实现,小米2测试通过
google zxing源码竖屏完美解决,竖屏时二维码图片不改变大小。
在精简zxing的基础上,矫正扫描变形;增加闪光灯功能;增加屏幕适配控制;控制扫描识别区和扫描框的位置(之前是默认居中,先改为偏上);修改扫描动画为横线掉落动画。
仿微信操作文档,详细介绍了在deLphixe 环境下,调用Zxing 显示横屏转换成竖屏扫描的详细操作说明,结合网上一些例子和台北一些前辈指点后进行整理,希望对你有所帮助。
zxing 竖屏 android 快速 精准 适配
ZXing Android二维码/条码扫描,2020 Android Studio版本,横竖屏都支持
基准环境:Android studio 3.1.3 gradle:4.4 通过将资源库图片转化为Bitmap,使用Zxing的接口完成二维码识别。
Zxing的集成就不说了,但是Zxing默认的是横屏扫码,在实际生产中并不适用,需要改为竖屏扫描。 转竖屏步骤: 1>. AndroidManifest.xml中把activity标签CaptureActivity部分的screenOrientation改为portrait。 ...
Android对zxing的集成,长按识别二维码相关
http://blog.csdn.net/nie312122330/article/details/40923723