修改qrcode边框大小和解决远距离扫码问题

修改扫描边框大小,在camera包下CameraManager类中修改
  private static final int MIN_FRAME_WIDTH = 240;
  private static final int MIN_FRAME_HEIGHT = 240;
  private static final int MAX_FRAME_WIDTH = 480;
  private static final int MAX_FRAME_HEIGHT = 360;
或者在getFramingRect()方法直接写定width和height;
解决远距离才能扫到问题,在CameraConfigurationManager类中,将方法setDesiredCameraParameters()内容
//    Camera.Parameters parameters = camera.getParameters();
//    Log.d(TAG, "Setting preview size: " + cameraResolution);
//    parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
//    setFlash(parameters);
//    setZoom(parameters);
//    //setSharpness(parameters);
//    //modify here
//    camera.setDisplayOrientation(90);
//    camera.setParameters(parameters);
替换成下面的
 Camera.Parameters parameters = camera.getParameters();
    List supportedPreviewSizes = parameters.getSupportedPreviewSizes();
    int position =0;
    if(supportedPreviewSizes.size()>2){
      position=supportedPreviewSizes.size()/2+1;//supportedPreviewSizes.get();
    }else {
      position=supportedPreviewSizes.size()/2;
    }

    int width = supportedPreviewSizes.get(position).width;
    int height = supportedPreviewSizes.get(position).height;
    Log.d(TAG, "Setting preview size: " + cameraResolution);
    camera.setDisplayOrientation(90);
    cameraResolution.x=width;
    cameraResolution.y=height;
    parameters.setPreviewSize(width,height);
    setFlash(parameters);
    setZoom(parameters);
    camera.setParameters(parameters);


你可能感兴趣的:(修改qrcode边框大小和解决远距离扫码问题)