zxing https://code.google.com/p/zxing/

Multi-format 1D/2D barcode image processing library with clients for Android, Java

zxing-client-android屏幕方向默认是landscape模式,修改如下源码,可改为portrait模式:

1、AndroidManifest.xml:

将android:screenOrientation="landscape"改为

android:screenOrientation="portrait"

2、DecodeHandler.java:

在buildLuminanceSource方法调用前增加

    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;    width = height;    height = tmp;    data = rotatedData;

3、CameraManager.java

将已有的计算rect.left/right/top/bottom的代码,替换为

      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;

4、CameraConfigurationManager.java

4.1、在setDesiredCameraParameters方法内新增代码

camera.setDisplayOrientation(90);

4.2、在initFromCameraParameters方法内注解掉代码 (最新代码可能不需要再改动此处 20130907)

    /*if (width < height) {      Log.i(TAG, "Display reports portrait orientation; assuming this is incorrect");      int temp = width;      width = height;      height = temp;    }*/

注,以上改动基于GoogleCode上最新zxing-client-android源码,并验证有效可行。

更多相关文章

  1. Windows环境下Android 源码模块下载
  2. Android关机界面代码
  3. 搭建 android 代码镜像服务
  4. android 解析 xml 文档的三种方法
  5. 几个Android小错误解决方法
  6. android读取assets大于1M文件的解决方法
  7. Android 手电筒 附源码

随机推荐

  1. android apache HTTP demo 互联网访问
  2. Ubuntu编译Android整个系统以及编译指定
  3. android 闪光灯控制
  4. Android中使用Intent实现界面跳转
  5. 【移动开发】Android中各种xml汇总
  6. 关于android.R.id.text1
  7. android界面开发小结——android笔记---
  8. Android Studio解决plugin with id 'andr
  9. 动态绘制CheckedTextView
  10. Android UID 问题 uid 改变进行了覆盖安