GammasImpl.mesa
Copyright © 1985, Xerox Corporation. All rights reserved.
Last edited by Eric Nickell, February 7, 1985 3:11:03 pm PST
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.