zoukankan      html  css  js  c++  java
  • ZXing for Android 修改为竖屏模式

    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

  • 相关阅读:
    转载__Java内部类
    Fragment之介绍(转)
    转载__Android-屏幕适配需要注意的地方
    转载__广播机制
    Activity的启动模式--总结
    图片_ _Android--加载大分辨率图片到内存
    转载—— android 瀑布流的实现详解,附源码
    转载_安卓性能优化
    C# Byte[] 数组操作
    C# 测算代码运行时间 Stopwatch
  • 原文地址:https://www.cnblogs.com/maxinliang/p/3735579.html
Copyright © 2011-2022 走看看