How to increase brightness of camera in Android

我们两清 提交于 2019-12-04 10:51:37
Steve

Using the camera parameters as pointed out by @appleskin, would either of these methods help? setWhiteBalance() or setExposureCompensation()

You can pass your camera parameters.

Try parameters.set("iso", 400); or whatever int value is supported on your device

used following way to increase or decrease brightness ( its for activity so you can used anywhere for camera or activity also), its working fine.so it helping to anyone.

call following function in your activity :

    private void setSeekbar() {

    seekBar.setMax(255);
    float curBrightnessValue = 0;
    try {
        curBrightnessValue = android.provider.Settings.System.getInt(
                getContentResolver(),
                android.provider.Settings.System.SCREEN_BRIGHTNESS);
    } catch (SettingNotFoundException e) {
        e.printStackTrace();
    }

    int screen_brightness = (int) curBrightnessValue;
    seekBar.setProgress(screen_brightness);

    seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        public void onStopTrackingTouch(SeekBar seekBar) {
            // Nothing handled here
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
            // Nothing handled here
        }

        public void onProgressChanged(SeekBar seekBar, int progress,
                boolean fromUser) {
            // Set the minimal brightness level
            // if seek bar is 20 or any value below
            screenBrightness(progress);
            editor.putInt("brightness",progress);
            editor.commit();
        }
    });
  }

method of screenBrightness :

 private void screenBrightness(double newBrightnessValue) {
    /*
     * WindowManager.LayoutParams settings = getWindow().getAttributes();
     * settings.screenBrightness = newBrightnessValue;
     * getWindow().setAttributes(settings);
     */
          WindowManager.LayoutParams lp = getWindow().getAttributes();
          float newBrightness = (float) newBrightnessValue;
          lp.screenBrightness = newBrightness / (float) 255;
          getWindow().setAttributes(lp);
 }

following method call before SeekBarChangeListener :

  void changeBrightnessMode() {

    try {
        int brightnessMode = Settings.System.getInt(getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS_MODE);
        if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
            Settings.System.putInt(getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS_MODE,
                    Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
        }

    } catch (Exception e) {
        // do something useful

    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!