|
|
clipka <ano### [at] anonymousorg> wrote:
Excellent information, as always.
Al ways, always, always learning something new and useful here. :)
> (It should be noted that `srgb <184/255, 115/255, 48/255> * Tone`
> doesn't give you exactly what you are asking for. Theoretically it
> should be `(srgb <184/255, 115/255, 48/255>) * Tone`, but that's
> currently not allowed by the parser.)
So something along the lines of this would be necessary:
(untested, needs handling of optional transmit and filter values)
#macro RGB2SRGB (C_linear)
// https://en.wikipedia.org/wiki/SRGB
// C_linear is a standard rgb color vector
#local RGB = array[3] {C_linear.red, C_linear.green, C_linear.blue};
#local SRGB = array[3];
#local _a = 0.055;
#local _Threshold = 0.0031308;
#local _Gamma = 2.4;
#for (Component, 0, 2)
#if (RGB[Component] <= _Threshold)
#local SRGB[Component] = 12.92 * RGB[Component];
#else
#local SRGB[Component] = ((1 + _a) * pow (RGB[Component], 1/_Gamma)) - _a;
#end // end if
#end // end for Component
#local C_srgb = <SRGB[0], SRGB[1], SRGB[2]>
C_srgb
#end // end macro RGB2SRGB
Post a reply to this message
|
|