修改zxing扫描二维码区域大小
来源:互联网 发布:淘宝天猫积分怎么用 编辑:程序博客网 时间:2024/09/21 09:19
zxing原生demo种的获取扫描区域大小的代码在getFramingRect()中
/** * Calculates the framing rect which the UI should draw to show the user where to place the * barcode. This target helps with alignment as well as forces the user to hold the device * far enough away to ensure the image will be in focus. * * @return The rectangle to draw on screen in window coordinates. */ public Rect getFramingRect() { Point screenResolution = configManager.getScreenResolution(); if (framingRect == null) { if (camera == null) { return null; } //原生 int width = screenResolution.x * 3 / 4; if (width < MIN_FRAME_WIDTH) { width = MIN_FRAME_WIDTH; } else if (width > MAX_FRAME_WIDTH) { width = MAX_FRAME_WIDTH; } int height = screenResolution.y * 3 / 4; if (height < MIN_FRAME_HEIGHT) { height = MIN_FRAME_HEIGHT; } else if (height > MAX_FRAME_HEIGHT) { height = MAX_FRAME_HEIGHT; } int leftOffset = (screenResolution.x - width) / 2; int topOffset = (screenResolution.y - height) / 2; framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height); Log.d(TAG, "Calculated framing rect: " + framingRect); } return framingRect; }
根据屏幕大小调整 大家可以增大这些数值 : 最小的宽 高 ; 最大宽高
参数实际在 getFramingRect() 方法中起作用
以下是原本Demo中提供的
我为了适配不同的屏幕大小将代码改成了
宽高 我占据了屏幕的 7/10
public Rect getFramingRect() {Point screenResolution = configManager.getScreenResolution();if (framingRect == null) {if (camera == null) {return null;}// ??????int width = screenResolution.x * 7 / 10;int height = screenResolution.y * 7 / 10;int leftOffset = (screenResolution.x - width) / 2;int topOffset = (screenResolution.y - height) / 3;framingRect = new Rect(leftOffset, topOffset, leftOffset + width,topOffset + height);Log.d(TAG, "Calculated framing rect: " + framingRect);}return framingRect;}
当然...取图改的这么大 会多占一点内存....相应的扫描的时候快得多
以上是实际读取图片的大小
实际的界面美化 在ViewfinderView 这个类当中进行绘制
不足之处请在下方留言 谢谢
0 1
- 修改zxing扫描二维码区域大小
- Android二维码ZXing扫描区域大小的调整,提高扫描速度
- 使用Google的zxing组件识别二维码时,调整扫描区域和取景框的大小
- android zxing二维码扫描界面参数修改
- ZXing进行二维码扫描
- ZXing二维码扫描
- zxing扫描二维码
- Zxing 近距离扫描二维码
- Zxing扫描二维码
- zxing二维码扫描
- Zxing仿微信二维码扫描
- zxing实现二维码扫描
- zxing 二维码扫描心得
- zxing实现二维码扫描
- 二维码扫描ZXing简化
- zxing二维码扫描功能
- Zxing二维码的扫描
- Zxing二维码扫描生成
- 关于IDataReader的释放
- java内存机制说明(简单明了)
- poj解题报告——1067
- MyEclipse10 SVN(subclipse) 笔记
- bzoj-1188 分裂游戏
- 修改zxing扫描二维码区域大小
- C++获取Lua全局变量和执行Lua多参数多返回值函数
- JS 日期时间比较 值类型和引用类型
- hdu1671 trie树
- AJAX笔记_001_第二次提交不调用后台方法
- 人工智能之梦
- root权限的获取
- Visual Studio 2013搭建phoneGap(Apache Cordova)开发环境
- 关于Unity音乐音效管理