* SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1 为自动调节屏幕亮度
* SCREEN_BRIGHTNESS_MODE_MANUAL=0 为手动调节兄历屏幕亮度
*/
private int getScreenMode(){
int screenMode=0
try{
screenMode = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE)
}
catch (Exception localException){
}
return screenMode
}
/**
* 获得当前屏幕亮度值 0--255
*/
private int getScreenBrightness(){
int screenBrightness=255
try{
screenBrightness = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS)
}
catch (Exception localException){
}
return screenBrightness
}
/**
* 设置当神尘衫前屏幕亮度的模式
* SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1 为自动调节屏幕亮度
* SCREEN_BRIGHTNESS_MODE_MANUAL=0 为手动调节屏幕亮度
*/
private void setScreenMode(int paramInt){
try{
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, paramInt)
}catch (Exception localException){
localException.printStackTrace()
}
}
/**
* 设置当前屏幕亮度值 0--255
*/
private void saveScreenBrightness(int paramInt){
try{
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, paramInt)
}
catch (Exception localException){
localException.printStackTrace()
}
}
/**
* 保存当前的屏幕亮度值,并使之生效
*/
private void setScreenBrightness(int paramInt){
Window localWindow = getWindow()
WindowManager.LayoutParams localLayoutParams = localWindow.getAttributes()
float f = paramInt / 255.0F
localLayoutParams.screenBrightness = f
localWindow.setAttributes(localLayoutParams)
}
我在我的应用程序中使用android camera2拍摄连续盯盯答图像,这时我使用camera2获则乎得的图像预览亮度与原始相机相比非常暗.我看到了这个,但答案中没有类似的凯慧要求.我试图设置camera2亮度的建议在这里:
请注意,此控件仅在android.control.aeMode!= OFF时有效.即使android.control.aeLock == true,此控件也会生效.
captureRequestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW)
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON)
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_LOCK, true)
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 6)
但它仍然显示预览为暗图像,如下所示.
看到这里的区别:
原装相机:
使用Camera2:
我需要传递的值是什么,作为第二个参数:
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 6)
我保持6,因为正如doc的建议:
例如,如果曝光值(EV)步长为0.333,则"6"表示+2 EV的曝光补偿-3意味着-1 EV的曝光补偿.
但亮度仍然没有影响..
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)