ScanConvert.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Frank Crow, March 4, 1986 3:48:58 pm PST
Fancy operations on two-dimensional arrays of pixels.
DIRECTORY
Atom USING [PropList],
Vector2 USING [VEC],
ImagerColor USING [RGB],
Pixels USING [PixelBuffer, SampleSet, SampleSetSequence];
ScanConvert:
CEDAR
DEFINITIONS
~ BEGIN
Type Definitions
PixelBuffer: TYPE ~ Pixels.PixelBuffer;
RGB: TYPE ~ ImagerColor.RGB; -- RECORD[ r, g, b: REAL];
IntRGB: TYPE ~ RECORD[ r, g, b: CARDINAL];
IntRGBT: TYPE ~ RECORD[ r, g, b, t: CARDINAL];
Vec2: TYPE ~ Vector2.VEC; -- RECORD[x, y: REAL];
IntVec2: TYPE ~ RECORD[x, y: INTEGER];
RealSequence: TYPE ~ RECORD [ length: NAT, reals: SEQUENCE maxLength: NAT OF REAL ];
SampleSet: TYPE ~ Pixels.SampleSet;
IntVec2Sequence: TYPE ~ RECORD [length: NAT, pairs: SEQUENCE maxLength: NAT OF IntVec2];
SampleSetSequence: TYPE ~ Pixels.SampleSetSequence;
ScanConvertError: SIGNAL [reason: ATOM];
Constants
justNoticeable: REAL ~ 0.02; -- percentage intensity change for a just noticeable difference
Spot - (Point/PIxel/Spot) Definitions
A spot is the information necessary to compute one or more pixels over a given position in an image
GetColorProc: TYPE ~ PROC[spot: Spot] RETURNS[IntRGBT];
Spot:
TYPE ~
RECORD[
x, y: NAT, -- screen coordinates
coverage: REAL ← 1.0, -- percentage of pixel area covered by surface
mask: CARDINAL ← LAST[CARDINAL], -- coding for position of covered area
val: REF RealSequence ← NIL, -- interpolated values for shading
yIncr: REF RealSequence ← NIL, -- vertical increments for interpolated values
xIncr: REF RealSequence ← NIL, -- horizontal increments for interpolated values
props: Atom.PropList ← NIL, -- catchall
proc: GetColorProc ← NIL -- extracts color for painting display
];
SpotSequence: TYPE ~ RECORD [ length: NAT, spots: SEQUENCE maxLength: NAT OF Spot ];
Utility Procedures
Extend: PROC[ seq: REF RealSequence, newLength: NAT] RETURNS[REF RealSequence];
Power: PROC[ value: INTEGER, power: NAT] RETURNS[ result: INTEGER ];
DitheredRGB: PROC[renderMode: ATOM, x, y, red, grn, blu: INTEGER] RETURNS[INTEGER];
MappedRGB: PROC[renderMode: ATOM, clr: IntRGB] RETURNS[NAT];
RGBFromMap: PROC[renderMode: ATOM, value: NAT] RETURNS[IntRGB];
Point/Spot Operations
PutSpot: PROC [ buf: PixelBuffer, spot: Spot, op, renderMode: ATOM ];
GetSpot:
PROC [ buf: PixelBuffer, spot: Spot, renderMode:
ATOM ]
RETURNS[ Spot ];
Currently r, g, b are returned as spot.lerp[0] - spot.lerp[2]
Scan Conversion for Lines
PutLine:
PROC [buf: PixelBuffer, p1, p2: IntVec2, color: SampleSet ];
Device dependent, numbers must fit PixelBuffer dimensions, bytes used as is
Scan Conversion for Convex Areas
ConstantPoly: PROC [buf: PixelBuffer, color: SampleSet, plygn: REF IntVec2Sequence];
SmoothPoly: PROC [buf: PixelBuffer, plygn: REF SpotSequence, renderMode: ATOM];
ShinyPoly: PROC [buf: PixelBuffer, plygn: REF SpotSequence, shininess: NAT,
renderMode: ATOM];
END.