How to increase brightness of camera in Android

大城市里の小女人 提交于 2019-12-21 17:51:29

问题


How do I change the brightness level of the camera?


回答1:


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




回答2:


You can pass your camera parameters.




回答3:


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




回答4:


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

    }
}


来源:https://stackoverflow.com/questions/5432503/how-to-increase-brightness-of-camera-in-android

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