zxing 横竖屏的问题
来源:互联网 发布:ubuntu设置ipv6 dns 编辑:程序博客网 时间:2024/05/18 02:59
解决方法:
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"
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
- zxing 横竖屏的问题
- zxing横竖屏问题
- Zxing横竖屏切换方法
- [开源项目]ZXing -横竖屏以及前/后置摄像头问题
- ZXing——二维码扫描案例及横竖屏切换问题
- Android横竖屏的问题
- iOS横竖屏的问题
- 修正Android基于ZXing的二维码扫描——横竖屏自由切换
- 关于Android 横竖屏切换的问题
- 横竖屏-- 公司软件的布局问题
- android 禁止横竖屏转换的问题
- 有关横竖屏显示的问题
- Android横竖屏要解决的问题
- 界面横竖屏的一些问题总结
- 横竖屏切换导致国际化的问题
- android 的横竖屏切换问题
- Android中横竖屏切换的问题
- Android横竖屏切换遇到的问题
- NLP相关
- 关于大学,关于计算机专业,关于ACM那些事
- 给准研究生和在读研究生的一封信
- nginx把post的数据记录到日志中
- VS代码行数统计
- zxing 横竖屏的问题
- Android Service 服务(三)—— bindService与remoteService
- java BIO NIO AIO 理论篇
- POJ 3352 Road Construction
- 代码中执行apk安装、卸载、更新以及静默安装
- java.io.NotSerializableException或者WriteAbortedException错误解决方法
- trie tree
- 关于系统调用、C库和应用程序API
- 职场生存法则之一