首页 > 移动平台 > 详细

ZXing for Android 修改为竖屏模式

时间:2014-05-19 12:06:22      阅读:665      评论:0      收藏:0      [点我收藏+]

zxing github连接:https://github.com/zxing/zxing

以下为修改方法

Step 1: Add following lines to rotate data before buildLuminanceSource(..) in decode(byte[] data, int width, int height)

DecodeHandler.java:

byte[] rotatedData =newbyte[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; width = height; height = tmp;

PlanarYUVLuminanceSource source = activity.getCameraManager().buildLuminanceSource(rotatedData, width, height);

Step 2: Modify getFramingRectInPreview().

CameraManager.java

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;

Step 3: Disable the check for Landscape Mode in initFromCameraParameters(...)

CameraConfigurationManager.java

//remove the following (下面代码新版本,应该是木有了)
if(width < height){Log.i(TAG,"Display reports portrait orientation; assuming this is incorrect");
 int temp = width; width = height; height = temp;
}

Step 4: Add following line to rotate camera insetDesiredCameraParameters(...)

CameraConfigurationManager.java

camera.setDisplayOrientation(90);

Step 5: Do not forget to set orientation of activity to portrait. I.e: manifest

ZXing for Android 修改为竖屏模式,布布扣,bubuko.com

ZXing for Android 修改为竖屏模式

原文:http://www.cnblogs.com/maxinliang/p/3735579.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!