44 /// 9 bits each for RGB and 5 bits for an exponent
55 /// </summary>
66 public partial struct ColorRGB9e5 : IColor < double >
7- {
7+ {
88 private uint bits ;
99
1010 public double R
@@ -54,19 +54,19 @@ public readonly void GetChannels(out double r, out double g, out double b, out d
5454 }
5555
5656 [ MethodImpl ( OptimizationConstants . AggressiveInliningAndOptimization ) ]
57- public void SetChannels ( double r , double g , double b , double a )
58- {
59- SetChannels ( r , g , b ) ;
60- }
61-
57+ public void SetChannels ( double r , double g , double b , double a )
58+ {
59+ SetChannels ( r , g , b ) ;
60+ }
61+
6262 [ MethodImpl ( OptimizationConstants . AggressiveInliningAndOptimization ) ]
6363 public void SetChannels ( double r , double g , double b )
6464 {
6565 int exponent = CalculateExponent ( r , g , b ) ;
66- decimal scale = ( decimal ) double . Pow ( 2 , exponent ) ;
67- uint rBits = ( uint ) ( ( decimal ) r / scale ) & ChannelBitMask ;
68- uint gBits = ( uint ) ( ( decimal ) g / scale ) & ChannelBitMask ;
69- uint bBits = ( uint ) ( ( decimal ) b / scale ) & ChannelBitMask ;
66+ double scale = double . Pow ( 2 , exponent ) ;
67+ uint rBits = ( uint ) ( r / scale ) & ChannelBitMask ;
68+ uint gBits = ( uint ) ( g / scale ) & ChannelBitMask ;
69+ uint bBits = ( uint ) ( b / scale ) & ChannelBitMask ;
7070 uint exponentBits = unchecked ( ( uint ) ( exponent + 24 ) ) ;
7171 bits = ( exponentBits << ExponentOffset ) | ( bBits << BlueOffset ) | ( gBits << GreenOffset ) | ( rBits << RedOffset ) ;
7272 }
@@ -86,12 +86,12 @@ private static int CalculateExponent(double r, double g, double b)
8686 double maxChannel = double . Max ( r , double . Max ( g , b ) ) ;
8787 double minExponent = double . Log2 ( maxChannel / ChannelBitMask ) ;
8888 return ( int ) double . Ceiling ( minExponent ) ;
89- }
90-
91- private const int ChannelBitMask = 0x1FF ;
92- private const int RedOffset = 0 ;
93- private const int GreenOffset = 9 ;
94- private const int BlueOffset = 18 ;
89+ }
90+
91+ private const int ChannelBitMask = 0x1FF ;
92+ private const int RedOffset = 0 ;
93+ private const int GreenOffset = 9 ;
94+ private const int BlueOffset = 18 ;
9595 private const int ExponentOffset = 27 ;
9696 }
9797}
0 commit comments