--- a/frameworks/base/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
+++ b/frameworks/base/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
@@ -22,6 +22,7 @@ public class BrightnessUtils {
public static final int GAMMA_SPACE_MIN = 0;
public static final int GAMMA_SPACE_MAX = 65535;
+ public static final boolean ENABLE_GAMMA = false;
// Hybrid Log Gamma constant values
private static final float R = 0.5f;
@@ -54,6 +55,7 @@ public class BrightnessUtils {
public static final int convertGammaToLinear(int val, int min, int max) {
final float normalizedVal = MathUtils.norm(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, val);
final float ret;
if (normalizedVal <= R) {
ret = MathUtils.sq(normalizedVal / R);
} else {
@@ -75,6 +77,11 @@ public class BrightnessUtils {
* @return The corresponding setting value.
*/
public static final float convertGammaToLinearFloat(int val, float min, float max) {
+ if(!ENABLE_GAMMA){
+ float ratio = (float)val / GAMMA_SPACE_MAX;
+ return min + (float)(ratio * (max - min));
+ }
final float normalizedVal = MathUtils.norm(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, val);
final float ret;
if (normalizedVal <= R) {
@@ -127,6 +134,11 @@ public class BrightnessUtils {
* @return The corresponding slider value
*/
public static final int convertLinearToGammaFloat(float val, float min, float max) {
+ if(!ENABLE_GAMMA){
+ float ratio = (float)(val - min)/ (max - min);
+ return (int)(ratio * GAMMA_SPACE_MAX);
+ }
// For some reason, HLG normalizes to the range [0, 12] rather than [0, 1]
final float normalizedVal = MathUtils.norm(min, max, val) * 12;
final float ret;
Android 12 屏幕亮度(从伽马曲线变为线性)
于 2023-01-10 11:05:25 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)