DIRECTORY Basics, ColorMap, Commander, ImagerOps, ImagerSample, ImagerPixelMap, Interminal, InterminalBackdoor, IO, PixelMapOps, Process, Real, Terminal; ColorMapCommandsImpl: CEDAR PROGRAM IMPORTS Basics, ColorMap, Commander, ImagerOps, ImagerSample, ImagerPixelMap, Interminal, InterminalBackdoor, IO, PixelMapOps, Process, Real, Terminal ~ { Cycle: Commander.CommandProc ~ { pos: Interminal.MousePosition; cmd.out.PutF["Use horizontal mouse to alter speed/direction of cycling.\n"]; cmd.out.PutF["Left click to stop; right click to stop and restore map.\n"]; DO Process.CheckForAbort[]; pos _ Interminal.GetMousePosition[]; ColorMap.Cycle[(pos.mouseX-500)/20]; ENDLOOP; }; PrintColorMap: Commander.CommandProc ~ { cm: ColorMap.ColorMap _ ColorMap.Get[]; FOR i: INT IN [0..256) DO cmd.out.PutF["%3g:\t%3g\t%3g\t%3g\n", IO.int[i], IO.int[cm[0][i]], IO.int[cm[1][i]], IO.int[cm[2][i]]]; ENDLOOP; }; Flash: Commander.CommandProc ~ { DO Process.CheckForAbort[]; ColorMap.Flash[]; ENDLOOP; }; GetPointer: PROC [buffer: ImagerSample.SampleBuffer, i, j, count: NAT] RETURNS [ImagerSample.UnsafeSamples] ~ INLINE { k: NAT ~ Basics.BoundsCheck[i, buffer.iSize]*buffer.jSize+Basics.BoundsCheck[j, buffer.jSize]; IF count#0 THEN [] _ Basics.BoundsCheck[j+count-1, buffer.jSize]; TRUSTED { RETURN[LOOPHOLE[@buffer[k]]] }; }; Lum: Commander.CommandProc ~ { cm: ColorMap.ColorMap _ ColorMap.Get[]; buf: ARRAY [0..256) OF INT; pm: ImagerPixelMap.PixelMap _ ImagerOps.PixelMapFromFrameBuffer [Terminal.GetColorFrameBufferA[InterminalBackdoor.terminal]]; action: PROC [sampleBuffer: ImagerSample.SampleBuffer] ~ TRUSTED { bounds: ImagerPixelMap.DeviceRectangle ~ pm.Window; sample: ImagerSample.UnsafeSamples ~ GetPointer[sampleBuffer, 0, 0, bounds.fSize]; maxVal: INT ~ CARDINAL[Basics.BITSHIFT[1, Basics.BITSHIFT[1, pm.refRep.lgBitsPerPixel]]-1]; FOR s: INT IN [bounds.sMin..bounds.sMin+bounds.sSize) DO Process.CheckForAbort[]; PixelMapOps.GetF[pm, s, bounds.fMin, sampleBuffer, 0, 0, bounds.fSize]; FOR j: NAT IN [0..bounds.fSize) DO sample[j] _ MAX[MIN[Real.Round[buf[sample[j]]], maxVal], 0]; ENDLOOP; PixelMapOps.PutF[pm, s, bounds.fMin, sampleBuffer, 0, 0, bounds.fSize, null, null]; ENDLOOP; }; FOR i: INT IN [0..255) DO buf[i] _ MIN[255, MAX[0, Real.RoundLI[.30*cm[0][i] + .59*cm[1][i] + .11*cm[2][i]]]]; ENDLOOP; ColorMap.Ramp[]; ImagerSample.DoWithScratchBuffer[1, pm.fSize, action]; }; Ramp: Commander.CommandProc ~ { ColorMap.Ramp[]; }; Commander.Register["///Commands/Cycle", Cycle, "\nCycle the colormap"]; Commander.Register["///Commands/Flash", Flash, "\nRandomly change colormap"]; Commander.Register["///Commands/Lum", Lum, "\nConvert pseudo-colors to luminance"]; Commander.Register["///Commands/Ramp", Ramp, "\nRestore grayscale colormap"]; Commander.Register["///Commands/PrintColorMap", PrintColorMap, "\nPrint colormap"]; }. άColorMapCommandsImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Bloomenthal, October 22, 1985 2:36:32 pm PDT IF pos.leftButton THEN EXIT; IF pos.middleButton THEN { ColorMap.Ramp[]; EXIT; }; Κυ˜šœ™Jšœ Οmœ1™