`

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);


参考:
http://blog.csdn.net/keep__fly/article/details/7403928
http://www.jianghuimin.com/?p=1476
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics