hybridGammaToLinear

Hybrid linear-gamma to linear transfer function. The function and parameters are detailed in the example below.

@safe pure nothrow @nogc
T
hybridGammaToLinear
(
double a
double b
double s
double e
T
)
(
T v
)
if (
isFloatingPoint!T
)

Examples

// sRGB parameters
enum a = 1.055;
enum b = 0.0031308;
enum s = 12.92;
enum e = 2.4;

double v = 0.5;

// the gamma function
if (v <= b*s)
    v = v/s;
else
    v = ((v + (a - 1)) / a)^^e;

assert(abs(v - hybridGammaToLinear!(a, b, s, e)(0.5)) < double.epsilon);

Meta