zxing竖屏完整解决方案

1、单纯的让照相机显示竖屏景象,CameraConfigurationManager类中增加方法
protected void setDisplayOrientation(Camera camera, int angle) {
Method downPolymorphic;
try {
downPolymorphic = camera.getClass().getMethod(
"setDisplayOrientation", new Class[] { int.class });
if (downPolymorphic != null)
downPolymorphic.invoke(camera, new Object[] { angle });
} catch (Exception e1) {
}
}

然后在方法void setDesiredCameraParameters(Camera camera){}中调用,
setDisplayOrientation(camera, 90);
具体位置在camera.setParameters(parameters);语句前面。

2、修改取景框大小
1、CameraConfigurationManager中的initFromCameraParameters(Camera camera) {}

// We're landscape-only, and have apparently seen issues with display thinking it's portrait
// when waking from sleep. If it's not landscape, assume it's mistaken and reverse them:
/*if (width < height) {
Log.i(TAG, "Display reports portrait orientation; assuming this is incorrect");
int temp = width;
width = height;
height = temp;
}*/这个判断注释掉,改成竖屏不需要交换width height---kaka modify
2、CameraManager中的getFramingRect()
//framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);


参考:
[url]http://blog.csdn.net/keep__fly/article/details/7403928[/url]
[url]http://www.jianghuimin.com/?p=1476[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值