Java 类com.google.zxing.client.android.camera.open.OpenCamera 实例源码

项目:weex-3d-map    文件:CameraManager.java   
/**
 * Convenience method for {@link com.google.zxing.client.android.CaptureActivity}
 *
 * @param newSetting if {@code true}, light should be turned on if currently off. And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
  OpenCamera theCamera = camera;
  if (theCamera != null) {
    if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
      boolean wasAutoFocusManager = autoFocusManager != null;
      if (wasAutoFocusManager) {
        autoFocusManager.stop();
        autoFocusManager = null;
      }
      configManager.setTorch(theCamera.getCamera(), newSetting);
      if (wasAutoFocusManager) {
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
        autoFocusManager.start();
      }
    }
  }
}
项目:BarcodeReaderView    文件:CameraManager.java   
/**
 * @param newSetting if {@code true}, light should be turned on if currently off. And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
    OpenCamera theCamera = camera;
    if (theCamera != null) {
        if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
            boolean wasAutoFocusManager = autoFocusManager != null;
            if (wasAutoFocusManager) {
                autoFocusManager.stop();
                autoFocusManager = null;
            }
            configManager.setTorch(theCamera.getCamera(), newSetting);
            if (wasAutoFocusManager) {
                autoFocusManager = new AutoFocusManager(theCamera.getCamera(), mUseAutoFocus);
                autoFocusManager.start();
            }
        }
    }
}
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Convenience method for
 * {@link com.google.zxing.client.android.CaptureActivity}
 *
 * @param newSetting
 *            if {@code true}, light should be turned on if currently off.
 *            And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
    OpenCamera theCamera = camera;
    if (theCamera != null) {
        if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
            boolean wasAutoFocusManager = autoFocusManager != null;
            if (wasAutoFocusManager) {
                autoFocusManager.stop();
                autoFocusManager = null;
            }
            configManager.setTorch(theCamera.getCamera(), newSetting);
            if (wasAutoFocusManager) {
                autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
                autoFocusManager.start();
            }
        }
    }
}
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Convenience method for
 * {@link com.google.zxing.client.android.CaptureActivity}
 *
 * @param newSetting
 *            if {@code true}, light should be turned on if currently off.
 *            And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
    OpenCamera theCamera = camera;
    if (theCamera != null) {
        if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
            boolean wasAutoFocusManager = autoFocusManager != null;
            if (wasAutoFocusManager) {
                autoFocusManager.stop();
                autoFocusManager = null;
            }
            configManager.setTorch(theCamera.getCamera(), newSetting);
            if (wasAutoFocusManager) {
                autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
                autoFocusManager.start();
            }
        }
    }
}
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Convenience method for
 * {@link com.google.zxing.client.android.CaptureActivity}
 *
 * @param newSetting
 *            if {@code true}, light should be turned on if currently off.
 *            And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
    OpenCamera theCamera = camera;
    if (theCamera != null) {
        if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
            boolean wasAutoFocusManager = autoFocusManager != null;
            if (wasAutoFocusManager) {
                autoFocusManager.stop();
                autoFocusManager = null;
            }
            configManager.setTorch(theCamera.getCamera(), newSetting);
            if (wasAutoFocusManager) {
                autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
                autoFocusManager.start();
            }
        }
    }
}
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Convenience method for
 * {@link com.google.zxing.client.android.CaptureActivity}
 *
 * @param newSetting
 *            if {@code true}, light should be turned on if currently off.
 *            And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
    OpenCamera theCamera = camera;
    if (theCamera != null) {
        if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
            boolean wasAutoFocusManager = autoFocusManager != null;
            if (wasAutoFocusManager) {
                autoFocusManager.stop();
                autoFocusManager = null;
            }
            configManager.setTorch(theCamera.getCamera(), newSetting);
            if (wasAutoFocusManager) {
                autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
                autoFocusManager.start();
            }
        }
    }
}
项目:weex-analyzer-android    文件:CameraManager.java   
/**
 * Convenience method for {@link com.google.zxing.client.android.CaptureActivity}
 *
 * @param newSetting if {@code true}, light should be turned on if currently off. And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
  OpenCamera theCamera = camera;
  if (theCamera != null) {
    if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
      boolean wasAutoFocusManager = autoFocusManager != null;
      if (wasAutoFocusManager) {
        autoFocusManager.stop();
        autoFocusManager = null;
      }
      configManager.setTorch(theCamera.getCamera(), newSetting);
      if (wasAutoFocusManager) {
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
        autoFocusManager.start();
      }
    }
  }
}
项目:weex-3d-map    文件:CameraManager.java   
/**
 * Convenience method for {@link com.google.zxing.client.android.CaptureActivity}
 *
 * @param newSetting if {@code true}, light should be turned on if currently off. And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
  OpenCamera theCamera = camera;
  if (theCamera != null) {
    if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
      boolean wasAutoFocusManager = autoFocusManager != null;
      if (wasAutoFocusManager) {
        autoFocusManager.stop();
        autoFocusManager = null;
      }
      configManager.setTorch(theCamera.getCamera(), newSetting);
      if (wasAutoFocusManager) {
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
        autoFocusManager.start();
      }
    }
  }
}
项目:Weex-TestDemo    文件:CameraManager.java   
/**
 * Convenience method for {@link com.google.zxing.client.android.CaptureActivity}
 *
 * @param newSetting if {@code true}, light should be turned on if currently off. And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
  OpenCamera theCamera = camera;
  if (theCamera != null) {
    if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
      boolean wasAutoFocusManager = autoFocusManager != null;
      if (wasAutoFocusManager) {
        autoFocusManager.stop();
        autoFocusManager = null;
      }
      configManager.setTorch(theCamera.getCamera(), newSetting);
      if (wasAutoFocusManager) {
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
        autoFocusManager.start();
      }
    }
  }
}
项目:weex    文件:CameraManager.java   
/**
 * Convenience method for {@link com.google.zxing.client.android.CaptureActivity}
 *
 * @param newSetting if {@code true}, light should be turned on if currently off. And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
  OpenCamera theCamera = camera;
  if (theCamera != null) {
    if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
      boolean wasAutoFocusManager = autoFocusManager != null;
      if (wasAutoFocusManager) {
        autoFocusManager.stop();
        autoFocusManager = null;
      }
      configManager.setTorch(theCamera.getCamera(), newSetting);
      if (wasAutoFocusManager) {
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
        autoFocusManager.start();
      }
    }
  }
}
项目:fotorecarga    文件:CameraManager.java   
/**
 *
 * @param newSetting if {@code true}, light should be turned on if currently off. And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
  OpenCamera theCamera = camera;
  if (theCamera != null) {
    if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
      boolean wasAutoFocusManager = autoFocusManager != null;
      if (wasAutoFocusManager) {
        autoFocusManager.stop();
        autoFocusManager = null;
      }
      configManager.setTorch(theCamera.getCamera(), newSetting);
      if (wasAutoFocusManager) {
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
        autoFocusManager.start();
      }
    }
  }
}
项目:ProjectX    文件:CameraManager.java   
/**
 * Convenience method
 *
 * @param newSetting if {@code true}, light should be turned on if currently off. And vice versa.
 */
public synchronized void setTorch(boolean newSetting) {
    OpenCamera theCamera = camera;
    if (theCamera != null) {
        if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
            boolean wasAutoFocusManager = autoFocusManager != null;
            if (wasAutoFocusManager) {
                autoFocusManager.stop();
                autoFocusManager = null;
            }
            configManager.setTorch(theCamera.getCamera(), newSetting);
            if (wasAutoFocusManager) {
                autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
                autoFocusManager.start();
            }
        }
    }
}
项目:weex-3d-map    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
  OpenCamera theCamera = camera;
  if (theCamera != null && !previewing) {
    theCamera.getCamera().startPreview();
    previewing = true;
    autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
  }
}
项目:BarcodeReaderView    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
    OpenCamera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.getCamera().startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(theCamera.getCamera(), mUseAutoFocus);
    }
}
项目:BarcodeReaderView    文件:CameraManager.java   
/**
 * 设置摄像头的自动对焦功能. 前提:设备需要支持自动对焦,否则无效。
 */
public synchronized void setUseAutoFocus(boolean newSetting) {
    this.mUseAutoFocus = newSetting;
    OpenCamera theCamera = camera;
    if (theCamera != null) {
        if (autoFocusManager != null) {
            autoFocusManager.stop();
            autoFocusManager = new AutoFocusManager(theCamera.getCamera(), mUseAutoFocus);
        }
    }
}
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
    OpenCamera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.getCamera().startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
    }
}
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
    OpenCamera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.getCamera().startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
    }
}
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
    OpenCamera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.getCamera().startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
    }
}
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
    OpenCamera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.getCamera().startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
    }
}
项目:weex-analyzer-android    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
  OpenCamera theCamera = camera;
  if (theCamera != null && !previewing) {
    theCamera.getCamera().startPreview();
    previewing = true;
    autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
  }
}
项目:weex-3d-map    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
  OpenCamera theCamera = camera;
  if (theCamera != null && !previewing) {
    theCamera.getCamera().startPreview();
    previewing = true;
    autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
  }
}
项目:Weex-TestDemo    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
  OpenCamera theCamera = camera;
  if (theCamera != null && !previewing) {
    theCamera.getCamera().startPreview();
    previewing = true;
    autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
  }
}
项目:weex    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
  OpenCamera theCamera = camera;
  if (theCamera != null && !previewing) {
    theCamera.getCamera().startPreview();
    previewing = true;
    autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
  }
}
项目:fotorecarga    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
  OpenCamera theCamera = camera;
  if (theCamera != null && !previewing) {
    theCamera.getCamera().startPreview();
    previewing = true;
    autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
  }
}
项目:ProjectX    文件:CameraManager.java   
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
    OpenCamera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.getCamera().startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
    }
}
项目:weex-3d-map    文件:CameraManager.java   
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
  OpenCamera theCamera = camera;
  if (theCamera == null) {
    theCamera = OpenCameraInterface.open(requestedCameraId);
    if (theCamera == null) {
      throw new IOException("Camera.open() failed to return object from driver");
    }
    camera = theCamera;
  }

  if (!initialized) {
    initialized = true;
    configManager.initFromCameraParameters(theCamera);
    if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
      setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
      requestedFramingRectWidth = 0;
      requestedFramingRectHeight = 0;
    }
  }

  Camera cameraObject = theCamera.getCamera();
  Camera.Parameters parameters = cameraObject.getParameters();
  String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
  try {
    configManager.setDesiredCameraParameters(theCamera, false);
  } catch (RuntimeException re) {
    // Driver failed
    Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
    Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
    // Reset:
    if (parametersFlattened != null) {
      parameters = cameraObject.getParameters();
      parameters.unflatten(parametersFlattened);
      try {
        cameraObject.setParameters(parameters);
        configManager.setDesiredCameraParameters(theCamera, true);
      } catch (RuntimeException re2) {
        // Well, darn. Give up
        Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
      }
    }
  }
  cameraObject.setPreviewDisplay(holder);

}
项目:weex-3d-map    文件:CameraConfigurationManager.java   
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {

    Camera theCamera = camera.getCamera();
    Camera.Parameters parameters = theCamera.getParameters();

    if (parameters == null) {
      Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
      return;
    }

    Log.i(TAG, "Initial camera parameters: " + parameters.flatten());

    if (safeMode) {
      Log.w(TAG, "In camera config safe mode -- most settings will not be honored");
    }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    initializeTorch(parameters, prefs, safeMode);

    CameraConfigurationUtils.setFocus(
        parameters,
        prefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true),
        prefs.getBoolean(PreferencesActivity.KEY_DISABLE_CONTINUOUS_FOCUS, true),
        safeMode);

    if (!safeMode) {
      if (prefs.getBoolean(PreferencesActivity.KEY_INVERT_SCAN, false)) {
        CameraConfigurationUtils.setInvertColor(parameters);
      }

      if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_BARCODE_SCENE_MODE, true)) {
        CameraConfigurationUtils.setBarcodeSceneMode(parameters);
      }

      if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_METERING, true)) {
        CameraConfigurationUtils.setVideoStabilization(parameters);
        CameraConfigurationUtils.setFocusArea(parameters);
        CameraConfigurationUtils.setMetering(parameters);
      }

    }

    parameters.setPreviewSize(bestPreviewSize.x, bestPreviewSize.y);

    theCamera.setDisplayOrientation(90);
    theCamera.setParameters(parameters);

    theCamera.setDisplayOrientation(cwRotationFromDisplayToCamera);

    Camera.Parameters afterParameters = theCamera.getParameters();
    Camera.Size afterSize = afterParameters.getPreviewSize();
    if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
      Log.w(TAG, "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y +
          ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
      bestPreviewSize.x = afterSize.width;
      bestPreviewSize.y = afterSize.height;
    }
  }
项目:BarcodeReaderView    文件:CameraManager.java   
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
    OpenCamera theCamera = camera;
    if (theCamera == null) {
        theCamera = OpenCameraInterface.open(requestedCameraId);
        if (theCamera == null) {
            throw new IOException("Camera.open() failed to return object from driver");
        }
        camera = theCamera;
    }

    if (!initialized) {
        initialized = true;
        configManager.initFromCameraParameters(theCamera, view.getWidth(), view.getHeight());
        if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
            setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight, requestedFramingRectTopOffset);
            requestedFramingRectWidth = 0;
            requestedFramingRectHeight = 0;
        }
    }

    Camera cameraObject = theCamera.getCamera();
    Camera.Parameters parameters = cameraObject.getParameters();
    String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
    try {
        configManager.setDesiredCameraParameters(theCamera, false, mUseAutoFocus);
    } catch (RuntimeException re) {
        // Driver failed
        LogEx.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
        LogEx.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
        // Reset:
        if (parametersFlattened != null) {
            parameters = cameraObject.getParameters();
            parameters.unflatten(parametersFlattened);
            try {
                cameraObject.setParameters(parameters);
                configManager.setDesiredCameraParameters(theCamera, true, mUseAutoFocus);
            } catch (RuntimeException re2) {
                // Well, darn. Give up
                LogEx.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
            }
        }
    }
    cameraObject.setPreviewDisplay(holder);

}
项目:BarcodeReaderView    文件:CameraConfigurationManager.java   
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode, boolean autoFocus) {

        Camera theCamera = camera.getCamera();
        Camera.Parameters parameters = theCamera.getParameters();

        if (parameters == null) {
            LogEx.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
            return;
        }

        LogEx.i(TAG, "Initial camera parameters: " + parameters.flatten());

        if (safeMode) {
            LogEx.w(TAG, "In camera config safe mode -- most settings will not be honored");
        }

        initializeTorch(parameters, safeMode);

        CameraConfigurationUtils.setFocus(
                parameters,
                autoFocus,
                false,
                safeMode);

//        if (!safeMode) {
//            if (prefs.getBoolean(PreferencesActivity.KEY_INVERT_SCAN, false)) {
//                CameraConfigurationUtils.setInvertColor(parameters);
//            }
//
//            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_BARCODE_SCENE_MODE, true)) {
//                CameraConfigurationUtils.setBarcodeSceneMode(parameters);
//            }
//
//            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_METERING, true)) {
//                CameraConfigurationUtils.setVideoStabilization(parameters);
//                CameraConfigurationUtils.setFocusArea(parameters);
//                CameraConfigurationUtils.setMetering(parameters);
//            }
//
//        }

        parameters.setPreviewSize(bestPreviewSize.x, bestPreviewSize.y);

        theCamera.setParameters(parameters);

        theCamera.setDisplayOrientation(cwRotationFromDisplayToCamera);

        Camera.Parameters afterParameters = theCamera.getParameters();
        Camera.Size afterSize = afterParameters.getPreviewSize();
        if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
            LogEx.w(TAG, "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y +
                    ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
            bestPreviewSize.x = afterSize.width;
            bestPreviewSize.y = afterSize.height;
        }
    }
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder
 *            The surface object which the camera will draw preview frames
 *            into.
 * @throws IOException
 *             Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
    OpenCamera theCamera = camera;
    if (theCamera == null) {
        theCamera = OpenCameraInterface.open(requestedCameraId);
        if (theCamera == null) {
            throw new IOException("Camera.open() failed to return object from driver");
        }
        camera = theCamera;
    }

    if (!initialized) {
        initialized = true;
        configManager.initFromCameraParameters(theCamera);
        if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
            setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
            requestedFramingRectWidth = 0;
            requestedFramingRectHeight = 0;
        }
    }

    Camera cameraObject = theCamera.getCamera();
    Camera.Parameters parameters = cameraObject.getParameters();
    String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save
                                                                                    // these,
                                                                                    // temporarily
    try {
        configManager.setDesiredCameraParameters(theCamera, false);
    } catch (RuntimeException re) {
        // Driver failed
        Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
        Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
        // Reset:
        if (parametersFlattened != null) {
            parameters = cameraObject.getParameters();
            parameters.unflatten(parametersFlattened);
            try {
                cameraObject.setParameters(parameters);
                configManager.setDesiredCameraParameters(theCamera, true);
            } catch (RuntimeException re2) {
                // Well, darn. Give up
                Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
            }
        }
    }
    cameraObject.setPreviewDisplay(holder);

}
项目:PortraitZXing    文件:CameraConfigurationManager.java   
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {

        Camera theCamera = camera.getCamera();
        Camera.Parameters parameters = theCamera.getParameters();

        if (parameters == null) {
            Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
            return;
        }

        Log.i(TAG, "Initial camera parameters: " + parameters.flatten());

        if (safeMode) {
            Log.w(TAG, "In camera config safe mode -- most settings will not be honored");
        }

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

        initializeTorch(parameters, prefs, safeMode);

        CameraConfigurationUtils.setFocus(parameters, prefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true),
                prefs.getBoolean(PreferencesActivity.KEY_DISABLE_CONTINUOUS_FOCUS, true), safeMode);

        if (!safeMode) {
            if (prefs.getBoolean(PreferencesActivity.KEY_INVERT_SCAN, false)) {
                CameraConfigurationUtils.setInvertColor(parameters);
            }

            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_BARCODE_SCENE_MODE, true)) {
                CameraConfigurationUtils.setBarcodeSceneMode(parameters);
            }

            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_METERING, true)) {
                CameraConfigurationUtils.setVideoStabilization(parameters);
                CameraConfigurationUtils.setFocusArea(parameters);
                CameraConfigurationUtils.setMetering(parameters);
            }

        }

        parameters.setPreviewSize(bestPreviewSize.x, bestPreviewSize.y);

        theCamera.setParameters(parameters);

//      theCamera.setDisplayOrientation(cwRotationFromDisplayToCamera);
        /**
         * @author MichaelX(xiong_it) modified. {@link https://github.com/xiong-it}
         * force preview orientation to portrait.这句代码作用是旋转镜头90度,使相机预览方向正确显示  
         */
        theCamera.setDisplayOrientation(90);
        // added end.

        Camera.Parameters afterParameters = theCamera.getParameters();
        Camera.Size afterSize = afterParameters.getPreviewSize();
        if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
            Log.w(TAG, "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y
                    + ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
            bestPreviewSize.x = afterSize.width;
            bestPreviewSize.y = afterSize.height;
        }
    }
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder
 *            The surface object which the camera will draw preview frames
 *            into.
 * @throws IOException
 *             Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
    OpenCamera theCamera = camera;
    if (theCamera == null) {
        theCamera = OpenCameraInterface.open(requestedCameraId);
        if (theCamera == null) {
            throw new IOException("Camera.open() failed to return object from driver");
        }
        camera = theCamera;
    }

    if (!initialized) {
        initialized = true;
        configManager.initFromCameraParameters(theCamera);
        if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
            setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
            requestedFramingRectWidth = 0;
            requestedFramingRectHeight = 0;
        }
    }

    Camera cameraObject = theCamera.getCamera();
    Camera.Parameters parameters = cameraObject.getParameters();
    String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save
                                                                                    // these,
                                                                                    // temporarily
    try {
        configManager.setDesiredCameraParameters(theCamera, false);
    } catch (RuntimeException re) {
        // Driver failed
        Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
        Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
        // Reset:
        if (parametersFlattened != null) {
            parameters = cameraObject.getParameters();
            parameters.unflatten(parametersFlattened);
            try {
                cameraObject.setParameters(parameters);
                configManager.setDesiredCameraParameters(theCamera, true);
            } catch (RuntimeException re2) {
                // Well, darn. Give up
                Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
            }
        }
    }
    cameraObject.setPreviewDisplay(holder);

}
项目:PortraitZXing    文件:CameraConfigurationManager.java   
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {

        Camera theCamera = camera.getCamera();
        Camera.Parameters parameters = theCamera.getParameters();

        if (parameters == null) {
            Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
            return;
        }

        Log.i(TAG, "Initial camera parameters: " + parameters.flatten());

        if (safeMode) {
            Log.w(TAG, "In camera config safe mode -- most settings will not be honored");
        }

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

        initializeTorch(parameters, prefs, safeMode);

        CameraConfigurationUtils.setFocus(parameters, prefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true),
                prefs.getBoolean(PreferencesActivity.KEY_DISABLE_CONTINUOUS_FOCUS, true), safeMode);

        if (!safeMode) {
            if (prefs.getBoolean(PreferencesActivity.KEY_INVERT_SCAN, false)) {
                CameraConfigurationUtils.setInvertColor(parameters);
            }

            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_BARCODE_SCENE_MODE, true)) {
                CameraConfigurationUtils.setBarcodeSceneMode(parameters);
            }

            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_METERING, true)) {
                CameraConfigurationUtils.setVideoStabilization(parameters);
                CameraConfigurationUtils.setFocusArea(parameters);
                CameraConfigurationUtils.setMetering(parameters);
            }

        }

        parameters.setPreviewSize(bestPreviewSize.x, bestPreviewSize.y);

        theCamera.setParameters(parameters);

        theCamera.setDisplayOrientation(cwRotationFromDisplayToCamera);

        Camera.Parameters afterParameters = theCamera.getParameters();
        Camera.Size afterSize = afterParameters.getPreviewSize();
        if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
            Log.w(TAG, "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y
                    + ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
            bestPreviewSize.x = afterSize.width;
            bestPreviewSize.y = afterSize.height;
        }
    }
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder
 *            The surface object which the camera will draw preview frames
 *            into.
 * @throws IOException
 *             Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
    OpenCamera theCamera = camera;
    if (theCamera == null) {
        theCamera = OpenCameraInterface.open(requestedCameraId);
        if (theCamera == null) {
            throw new IOException("Camera.open() failed to return object from driver");
        }
        camera = theCamera;
    }

    if (!initialized) {
        initialized = true;
        configManager.initFromCameraParameters(theCamera);
        if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
            setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
            requestedFramingRectWidth = 0;
            requestedFramingRectHeight = 0;
        }
    }

    Camera cameraObject = theCamera.getCamera();
    Camera.Parameters parameters = cameraObject.getParameters();
    String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save
                                                                                    // these,
                                                                                    // temporarily
    try {
        configManager.setDesiredCameraParameters(theCamera, false);
    } catch (RuntimeException re) {
        // Driver failed
        Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
        Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
        // Reset:
        if (parametersFlattened != null) {
            parameters = cameraObject.getParameters();
            parameters.unflatten(parametersFlattened);
            try {
                cameraObject.setParameters(parameters);
                configManager.setDesiredCameraParameters(theCamera, true);
            } catch (RuntimeException re2) {
                // Well, darn. Give up
                Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
            }
        }
    }
    cameraObject.setPreviewDisplay(holder);

}
项目:PortraitZXing    文件:CameraConfigurationManager.java   
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {

        Camera theCamera = camera.getCamera();
        Camera.Parameters parameters = theCamera.getParameters();

        if (parameters == null) {
            Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
            return;
        }

        Log.i(TAG, "Initial camera parameters: " + parameters.flatten());

        if (safeMode) {
            Log.w(TAG, "In camera config safe mode -- most settings will not be honored");
        }

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

        initializeTorch(parameters, prefs, safeMode);

        CameraConfigurationUtils.setFocus(parameters, prefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true),
                prefs.getBoolean(PreferencesActivity.KEY_DISABLE_CONTINUOUS_FOCUS, true), safeMode);

        if (!safeMode) {
            if (prefs.getBoolean(PreferencesActivity.KEY_INVERT_SCAN, false)) {
                CameraConfigurationUtils.setInvertColor(parameters);
            }

            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_BARCODE_SCENE_MODE, true)) {
                CameraConfigurationUtils.setBarcodeSceneMode(parameters);
            }

            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_METERING, true)) {
                CameraConfigurationUtils.setVideoStabilization(parameters);
                CameraConfigurationUtils.setFocusArea(parameters);
                CameraConfigurationUtils.setMetering(parameters);
            }

        }

        parameters.setPreviewSize(bestPreviewSize.x, bestPreviewSize.y);

        theCamera.setParameters(parameters);

        theCamera.setDisplayOrientation(cwRotationFromDisplayToCamera);

        Camera.Parameters afterParameters = theCamera.getParameters();
        Camera.Size afterSize = afterParameters.getPreviewSize();
        if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
            Log.w(TAG, "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y
                    + ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
            bestPreviewSize.x = afterSize.width;
            bestPreviewSize.y = afterSize.height;
        }
    }
项目:PortraitZXing    文件:CameraManager.java   
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder
 *            The surface object which the camera will draw preview frames
 *            into.
 * @throws IOException
 *             Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
    OpenCamera theCamera = camera;
    if (theCamera == null) {
        theCamera = OpenCameraInterface.open(requestedCameraId);
        if (theCamera == null) {
            throw new IOException("Camera.open() failed to return object from driver");
        }
        camera = theCamera;
    }

    if (!initialized) {
        initialized = true;
        configManager.initFromCameraParameters(theCamera);
        if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
            setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
            requestedFramingRectWidth = 0;
            requestedFramingRectHeight = 0;
        }
    }

    Camera cameraObject = theCamera.getCamera();
    Camera.Parameters parameters = cameraObject.getParameters();
    String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save
                                                                                    // these,
                                                                                    // temporarily
    try {
        configManager.setDesiredCameraParameters(theCamera, false);
    } catch (RuntimeException re) {
        // Driver failed
        Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
        Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
        // Reset:
        if (parametersFlattened != null) {
            parameters = cameraObject.getParameters();
            parameters.unflatten(parametersFlattened);
            try {
                cameraObject.setParameters(parameters);
                configManager.setDesiredCameraParameters(theCamera, true);
            } catch (RuntimeException re2) {
                // Well, darn. Give up
                Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
            }
        }
    }
    cameraObject.setPreviewDisplay(holder);

}
项目:PortraitZXing    文件:CameraConfigurationManager.java   
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {

        Camera theCamera = camera.getCamera();
        Camera.Parameters parameters = theCamera.getParameters();

        if (parameters == null) {
            Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
            return;
        }

        Log.i(TAG, "Initial camera parameters: " + parameters.flatten());

        if (safeMode) {
            Log.w(TAG, "In camera config safe mode -- most settings will not be honored");
        }

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

        initializeTorch(parameters, prefs, safeMode);

        CameraConfigurationUtils.setFocus(parameters, prefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true),
                prefs.getBoolean(PreferencesActivity.KEY_DISABLE_CONTINUOUS_FOCUS, true), safeMode);

        if (!safeMode) {
            if (prefs.getBoolean(PreferencesActivity.KEY_INVERT_SCAN, false)) {
                CameraConfigurationUtils.setInvertColor(parameters);
            }

            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_BARCODE_SCENE_MODE, true)) {
                CameraConfigurationUtils.setBarcodeSceneMode(parameters);
            }

            if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_METERING, true)) {
                CameraConfigurationUtils.setVideoStabilization(parameters);
                CameraConfigurationUtils.setFocusArea(parameters);
                CameraConfigurationUtils.setMetering(parameters);
            }

        }

        parameters.setPreviewSize(bestPreviewSize.x, bestPreviewSize.y);

        theCamera.setParameters(parameters);

//      theCamera.setDisplayOrientation(cwRotationFromDisplayToCamera);
        /**
         * @author MichaelX(xiong_it) modified. {@link https://github.com/xiong-it}
         * force preview orientation to portrait.这句代码作用是旋转镜头90度,使相机预览方向正确显示  
         */
        theCamera.setDisplayOrientation(90);
        // added end.

        Camera.Parameters afterParameters = theCamera.getParameters();
        Camera.Size afterSize = afterParameters.getPreviewSize();
        if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
            Log.w(TAG, "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y
                    + ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
            bestPreviewSize.x = afterSize.width;
            bestPreviewSize.y = afterSize.height;
        }
    }
项目:weex-analyzer-android    文件:CameraManager.java   
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
  OpenCamera theCamera = camera;
  if (theCamera == null) {
    theCamera = OpenCameraInterface.open(requestedCameraId);
    if (theCamera == null) {
      throw new IOException("Camera.open() failed to return object from driver");
    }
    camera = theCamera;
  }

  if (!initialized) {
    initialized = true;
    configManager.initFromCameraParameters(theCamera);
    if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
      setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
      requestedFramingRectWidth = 0;
      requestedFramingRectHeight = 0;
    }
  }

  Camera cameraObject = theCamera.getCamera();
  Camera.Parameters parameters = cameraObject.getParameters();
  String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
  try {
    configManager.setDesiredCameraParameters(theCamera, false);
  } catch (RuntimeException re) {
    // Driver failed
    Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
    Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
    // Reset:
    if (parametersFlattened != null) {
      parameters = cameraObject.getParameters();
      parameters.unflatten(parametersFlattened);
      try {
        cameraObject.setParameters(parameters);
        configManager.setDesiredCameraParameters(theCamera, true);
      } catch (RuntimeException re2) {
        // Well, darn. Give up
        Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
      }
    }
  }
  cameraObject.setPreviewDisplay(holder);

}
项目:weex-analyzer-android    文件:CameraConfigurationManager.java   
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {

    Camera theCamera = camera.getCamera();
    Camera.Parameters parameters = theCamera.getParameters();

    if (parameters == null) {
      Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
      return;
    }

    Log.i(TAG, "Initial camera parameters: " + parameters.flatten());

    if (safeMode) {
      Log.w(TAG, "In camera config safe mode -- most settings will not be honored");
    }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    initializeTorch(parameters, prefs, safeMode);

    CameraConfigurationUtils.setFocus(
        parameters,
        prefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true),
        prefs.getBoolean(PreferencesActivity.KEY_DISABLE_CONTINUOUS_FOCUS, true),
        safeMode);

    if (!safeMode) {
      if (prefs.getBoolean(PreferencesActivity.KEY_INVERT_SCAN, false)) {
        CameraConfigurationUtils.setInvertColor(parameters);
      }

      if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_BARCODE_SCENE_MODE, true)) {
        CameraConfigurationUtils.setBarcodeSceneMode(parameters);
      }

      if (!prefs.getBoolean(PreferencesActivity.KEY_DISABLE_METERING, true)) {
        CameraConfigurationUtils.setVideoStabilization(parameters);
        CameraConfigurationUtils.setFocusArea(parameters);
        CameraConfigurationUtils.setMetering(parameters);
      }

    }

    parameters.setPreviewSize(bestPreviewSize.x, bestPreviewSize.y);

    theCamera.setDisplayOrientation(90);
    theCamera.setParameters(parameters);

    theCamera.setDisplayOrientation(cwRotationFromDisplayToCamera);

    Camera.Parameters afterParameters = theCamera.getParameters();
    Camera.Size afterSize = afterParameters.getPreviewSize();
    if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
      Log.w(TAG, "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y +
          ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
      bestPreviewSize.x = afterSize.width;
      bestPreviewSize.y = afterSize.height;
    }
  }
项目:weex-3d-map    文件:CameraManager.java   
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
  OpenCamera theCamera = camera;
  if (theCamera == null) {
    theCamera = OpenCameraInterface.open(requestedCameraId);
    if (theCamera == null) {
      throw new IOException("Camera.open() failed to return object from driver");
    }
    camera = theCamera;
  }

  if (!initialized) {
    initialized = true;
    configManager.initFromCameraParameters(theCamera);
    if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
      setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
      requestedFramingRectWidth = 0;
      requestedFramingRectHeight = 0;
    }
  }

  Camera cameraObject = theCamera.getCamera();
  Camera.Parameters parameters = cameraObject.getParameters();
  String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
  try {
    configManager.setDesiredCameraParameters(theCamera, false);
  } catch (RuntimeException re) {
    // Driver failed
    Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
    Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
    // Reset:
    if (parametersFlattened != null) {
      parameters = cameraObject.getParameters();
      parameters.unflatten(parametersFlattened);
      try {
        cameraObject.setParameters(parameters);
        configManager.setDesiredCameraParameters(theCamera, true);
      } catch (RuntimeException re2) {
        // Well, darn. Give up
        Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
      }
    }
  }
  cameraObject.setPreviewDisplay(holder);

}