Example #1
0
 /// <summary>
 /// Converts a single color component from SRGB (gamma) to linear space.
 /// </summary>
 /// <param name="x">Component in SRGB space.</param>
 /// <returns>Component in linear space.</returns>
 private static float SRGBToLinear(float x)
 {
     if (x <= 0.0f)
     {
         return(0.0f);
     }
     else if (x >= 1.0f)
     {
         return(1.0f);
     }
     else if (x < 0.04045f)
     {
         return(x / 12.92f);
     }
     else
     {
         return(MathEx.Pow((x + 0.055f) / 1.055f, 2.4f));
     }
 }
Example #2
0
 /// <summary>
 /// Converts a single color component from linear to SRGB (gamma) space.
 /// </summary>
 /// <param name="x">Component in linear space.</param>
 /// <returns>Component in SRGB space.</returns>
 private static float LinearToSRGB(float x)
 {
     if (x <= 0.0f)
     {
         return(0.0f);
     }
     else if (x >= 1.0f)
     {
         return(1.0f);
     }
     else if (x < 0.0031308f)
     {
         return(x * 12.92f);
     }
     else
     {
         return(MathEx.Pow(x, 1.0f / 2.4f) * 1.055f - 0.055f);
     }
 }