DitherAIS.mesa
Mik Lamming September 29, 1982 2:44 pm
DIRECTORY
Rope    USING [ROPE];
DitherAIS: DEFINITIONS = BEGIN
Pixel: TYPE = RECORD [ red, green, blue:INTEGER, rgb:CARDINAL];
PixelBuf: TYPE = REF PixelBufRec;
PixelBufRec: TYPE = RECORD [
data:SEQUENCE ix:CARDINAL OF Pixel];
UserMapProc: TYPE = PROC [r, g, b:INTEGER] RETURNS [palix:CARDINAL, re, ge, be:INTEGER];
Takes three INTEGER values of red, green and blue (which may be negative) and returns the index of the 'nearest' color in a user defined color palette together with three error values. The error values represent the difference between the r,g,b given as inputs and the r,g,b values of the 'nearest' color. N.B. r,g,b values outside the range [0..256) should be MiniMaxed to 0/255. Errors re,ge,be should be computed before MiniMaxing.
UserUnmapProc: TYPE = PROC [palix:CARDINAL] RETURNS [r, g, b:INTEGER];
Takes a palette index and returns r,g and b [0..256)
Stretch: PUBLIC PROCEDURE [redFn, greenFn, blueFn, rgbFn:Rope.ROPE, unMap:UserUnmapProc];
Takes a dithered file rgbFn and cretates three separations using the unMap procedure
Squash: PUBLIC PROCEDURE [redFn, greenFn, blueFn, rgbFn:Rope.ROPE, map:UserMapProc];
Transforms the three AIS files red,green and blue into the single AIS file: rgb using the user supplied map procedure and applying Floyd-Steinberg error distribution.
SquashScan: PUBLIC PROCEDURE [this, next:PixelBuf, left,right:CARDINAL, map:UserMapProc];
Processes the pixel buffer 'this' using the user supplied map procedure 'map' to fill in the rgb field in each pixel of 'this' and modifies the contents of the buffer 'next' using Floyd-Steinberg error distribution
END.