<> <> <> <<>> DIRECTORY Real USING [RoundC], RealFns USING [Power], Gammas ; <<>> <<>> GammasImpl: CEDAR MONITOR IMPORTS Real, RealFns EXPORTS Gammas = BEGIN OPEN Gammas; gamma: PUBLIC REF READONLY Gamma; defaultGamma: REF Gamma; BuildGammaTable: PUBLIC PROC [gammaValue: REAL _ 2.2] RETURNS [ref: REF Gamma _ NEW[Gamma]] ~ { invGamma: REAL; invGamma _ 1.0/gammaValue; FOR x: Color IN Color DO ref[x] _ Real.RoundC[255.0 * RealFns.Power[base: (x/255.0), exponent: invGamma]]; ENDLOOP; }; InstallGammaTable: PUBLIC ENTRY PROC [ref: REF Gamma] ~ { ENABLE UNWIND => NULL; gamma _ IF ref#NIL THEN ref ELSE defaultGamma; }; Init: PROC ~ { InstallGammaTable[defaultGamma _ BuildGammaTable[]]; }; Init[]; END.