如何更改相机的亮度?
答案 0 :(得分:6)
使用@appleskin指出的相机参数,这些方法中的任何一种都有帮助吗? setWhiteBalance()或setExposureCompensation()
答案 1 :(得分:0)
您可以通过相机parameters。
答案 2 :(得分:0)
尝试参数.set(“iso”,400);或者您的设备支持的任何int值
答案 3 :(得分:0)
使用以下方式增加或减少亮度(它的活动因此你可以在任何地方用于相机或活动),它的工作正常。所以它对任何人都有帮助。
在您的活动中调用以下功能:
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();
}
});
}
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);
}
在 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
}
}