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. ’GammasImpl.mesa Copyright c 1985, Xerox Corporation. All rights reserved. Last edited by Eric Nickell, February 7, 1985 3:11:03 pm PST Ê~˜code™Kšœ Ïmœ/™:K™