前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >How to crop scanned barcode using Zbar?

How to crop scanned barcode using Zbar?

作者头像
阿新
发布2018-04-12 15:09:02
4860
发布2018-04-12 15:09:02
举报
文章被收录于专栏:c#开发者c#开发者

http://pastebin.com/wSVW1tRc

CGRect scanCrop The region of the video image that will be scanned, in normalized image coordinates. Note that the video image is in landscape mode (default {{0, 0}, {1, 1}})

The coordinates for all of the arguments is in a normalized float, which is from 0 - 1. So, in normalized value, theView.width is 1.0, and theView.height is 1.0. Therefore, the default rect is {{0,0},{1,1}}.

So for example, if I have a transparent UIView named scanView as a scanning region for myreaderView. Rather than do :

代码语言:javascript
复制
readerView.scanCrop = scanView.frame;

We should do this, normalizing every arguments first :

代码语言:javascript
复制
CGFloat x,y,width,height;  
x = scanView.frame.origin.x / readerView.bounds.size.width;
y = scanView.frame.origin.y / readerView.bounds.size.height;
width = scanView.frame.size.width / readerView.bounds.size.width;
height = scanView.frame.size.height / readerView.bounds.size.height;

readerView.scanCrop =CGRectMake(x, y, width, height);

It works for me. Hope that helps.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2012-12-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档