@@ -95,13 +95,26 @@ public static boolean useLotteLaunchSplashScreen(boolean original) {
95
95
return original ;
96
96
}
97
97
98
+ private static int colorChannelTo3Bits (int channel8Bits ) {
99
+ final float channel3Bits = channel8Bits * 7 / 255f ;
100
+
101
+ // If a color channel is near zero, then allow rounding up so values between
102
+ // 0x12 and 0x23 will show as 0x24. This ensures color channels that are
103
+ // close to zero (but not zero) still show some color.
104
+ //
105
+ // But always round down when the channel is near full saturation, otherwise rounding
106
+ // to nearest will cause all values between 0xEC and 0xFE to always show as 0xFF.
107
+ return channel3Bits < 1
108
+ ? Math .round (channel3Bits )
109
+ : (int ) channel3Bits ;
110
+ }
111
+
98
112
private static String get9BitStyleIdentifier (int color24Bit ) {
99
- // Convert to nearest 9-bit color (3 bits per color channel).
100
- final int r3 = Color .red (color24Bit ) * 7 / 255 ;
101
- final int g3 = Color .green (color24Bit ) * 7 / 255 ;
102
- final int b3 = Color .blue (color24Bit ) * 7 / 255 ;
113
+ final int rInt = colorChannelTo3Bits (Color .red (color24Bit ));
114
+ final int gInt = colorChannelTo3Bits (Color .green (color24Bit ));
115
+ final int bInt = colorChannelTo3Bits (Color .blue (color24Bit ));
103
116
104
- return String .format (Locale .US , "splash_seekbar_color_style_%d_%d_%d" , r3 , g3 , b3 );
117
+ return String .format (Locale .US , "splash_seekbar_color_style_%d_%d_%d" , rInt , gInt , bInt );
105
118
}
106
119
107
120
/**
0 commit comments