<> <> <> <> <<>> DIRECTORY Atom USING [PropList], IIPixel USING [PixelProc], IIPixelArray USING [PixelArray], IISample USING [Function, Sample], IITransformation USING [Transformation]; IIColor: CEDAR DEFINITIONS ~ BEGIN Sample: TYPE ~ IISample.Sample; <> Color: TYPE ~ REF ColorRep; ColorRep: TYPE ~ RECORD [ SELECT tag: * FROM constant => [ colorOperator: ColorOperator, pixel: SEQUENCE size: NAT OF Sample ], sampled => [ -- the result of MakeSampledColor pa: IIPixelArray.PixelArray, -- the array of pixels um: IITransformation.Transformation, -- transforms from color to device coordinates colorOperator: ColorOperator -- maps pixels into constant colors ], sampledBlack => [ -- the result of MakeSampledBlack pa: IIPixelArray.PixelArray, -- the array of pixels (must be 1 bit per pixel) um: IITransformation.Transformation, -- transforms from color to device coordinates clear: BOOL -- are zero bits transparent? ], special => [ -- XOR, stipples, named colors, and the like type: ATOM, data: REF, substitute: Color -- use this if you don't recognize type ], ENDCASE ]; ConstantColor: TYPE ~ REF ColorRep.constant; SampledColor: TYPE ~ REF ColorRep.sampled; SampledBlack: TYPE ~ REF ColorRep.sampledBlack; SpecialColor: TYPE ~ REF ColorRep.special; <> <> <<>> ColorOperator: TYPE ~ REF ColorOperatorRep; ColorOperatorRep: TYPE ~ RECORD [ chromatic: BOOL, -- If FALSE, everything is gray. samplesPerPixelIn: NAT, -- Number of samples per pixel expected. class: REF ColorOperatorClassRep, -- Contains the name of the Interpress color model operator and the operations that the ColorOperator needs to perform. data: REF -- Contains the data specific to the ColorOperator; corresponds to the parameters needed by the color model operator ]; ColorOperatorClassRep: TYPE; <> XYZ: TYPE ~ RECORD [X, Y, Z: REAL]; <> <> Chromaticity: TYPE ~ RECORD [x, y: REAL]; <> <<>> <> <> illuminantC: Chromaticity ~ [x: 0.310, y: 0.317]; <> ChromaticityFromXYZ: PROC [XYZ] RETURNS [Chromaticity]; <> XYZFromChromaticity: PROC [c: Chromaticity, Y: REAL] RETURNS [XYZ]; <> <<>> Row3: TYPE ~ ARRAY [0..3) OF REAL; Matrix3: TYPE ~ ARRAY [0..3) OF ARRAY [0..3) OF REAL; RGBCalibration: TYPE ~ REF RGBCalibrationRep; RGBCalibrationRep: TYPE ~ RECORD [ type: ATOM, -- identifying name red: Chromaticity, -- CIE chromaticity of red phosphor green: Chromaticity, -- CIE chromaticity of green phosphor blue: Chromaticity, -- CIE chromaticity of blue phosphor white: Chromaticity, -- CIE chromaticity of white (RGB[1, 1, 1]) maxY: REAL, -- maximum luminance, typically 1 matrixRGBtoXYZ: Matrix3, -- A row vector with [red, green, blue] components, multiplied on the right by the matrix, yields a row vector with [X, Y, Z] components. matrixXYZtoRGB: Matrix3 -- The inverse. ]; <> <<>> GetDefaultCalibration: PROC RETURNS [RGBCalibration]; <> <<>> CreateCalibration: PROC [type: ATOM, red, green, blue: Chromaticity, white: Chromaticity, maxY: REAL _ 1] RETURNS [RGBCalibration]; <> <<>> RGB: TYPE ~ RECORD [R, G, B: REAL]; <> <<>> XYZFromRGB: PROC [rgb: RGB, calibration: RGBCalibration _ NIL] RETURNS [XYZ]; <> <<>> RGBFromXYZ: PROC [xyz: XYZ, calibration: RGBCalibration _ NIL] RETURNS [RGB]; <> <> RGBMaxY: PROC [c: Chromaticity, calibration: RGBCalibration _ NIL] RETURNS [Y: REAL]; <> <<[x, y, Y] is inside the device's gamut iff Y<=RGBMaxY[[x, y], calibration].>> <<>> YIQ: TYPE ~ RECORD [Y, I, Q: REAL]; <> <> <> <<>> YIQFromRGB: PROC [RGB] RETURNS [YIQ]; RGBFromYIQ: PROC [YIQ] RETURNS [RGB]; <> HSV: TYPE ~ RECORD [H, S, V: REAL]; <> <> <> HSVFromRGB: PROC [RGB] RETURNS [HSV]; RGBFromHSV: PROC [HSV] RETURNS [RGB]; <> HSL: TYPE ~ RECORD [H, S, L: REAL]; <> <> <> HSLFromRGB: PROC [RGB] RETURNS [HSL]; RGBFromHSL: PROC [HSL] RETURNS [RGB]; <> <<>> <> ColorFromPixel: PROC [colorOperator: ColorOperator, pixel: IIPixel.PixelProc] RETURNS [ConstantColor]; <> ColorFromGray: PROC [f: REAL] RETURNS [ConstantColor]; <> <> ColorFromXYZ: PROC [xyz: XYZ] RETURNS [ConstantColor]; <> <<>> ColorFromRGB: PROC [rgb: RGB] RETURNS [ConstantColor]; <> <<>> <> SampleTableProc: TYPE ~ PROC [Sample] RETURNS [REAL]; NewColorOperatorGrayLinear: PROC [sWhite, sBlack: REAL, sampleTableSize: Sample _ 0, sampleTableProc: SampleTableProc _ NIL] RETURNS [ColorOperator]; <<... colorModelOperators/Xerox/GrayLinear, as specified in the Raster Encoding Standard.>> <> <> <> NewColorOperatorGrayDensity: PROC [sWhite, sBlack, dBlack: REAL, sampleTableSize: Sample _ 0, sampleTableProc: SampleTableProc _ NIL] RETURNS [ColorOperator]; <<... colorModelOperators/Xerox/GrayDensity, as specified in the Raster Encoding Standard.>> <> <> <> <> <<>> NewColorOperatorGrayVisual: PUBLIC PROC [sWhite, sBlack: REAL, sampleTableSize: Sample _ 0, sampleTableProc: SampleTableProc _ NIL] RETURNS [ColorOperator]; <<... colorModelOperators/Xerox/GrayVisual, as specified in the Raster Encoding Standard.>> <> <> <> <> <> NewColorOperatorMap: PROC [maxSampleValue: Sample, map: PROC [Sample] RETURNS [ConstantColor]] RETURNS [ColorOperator]; <<... colorModelOperators/Xerox/Map, as specified in the Raster Encoding Standard.>> <> NewColorOperatorBuildMap: PROC [colorOperator: ColorOperator, maxSampleValue: Sample, map: PROC [Sample] RETURNS [Sample]] RETURNS [ColorOperator]; <<... colorModelOperators/Xerox/BuildMap, as specified in the Raster Encoding Standard.>> <> SampleEncoding: TYPE ~ REF SampleEncodingRep _ NIL; SampleEncodingRep: TYPE ~ RECORD [SEQUENCE size: NAT OF REAL]; Pixel3Encoding: TYPE ~ ARRAY [0..3) OF SampleEncoding; identityPixel3Encoding: Pixel3Encoding ~ ALL[NIL]; MakeSampleEncoding: PROC [size: NAT _ 0, sampleTableProc: SampleTableProc _ NIL] RETURNS [SampleEncoding]; NewColorOperatorCalibrated: PROC [encoding: Pixel3Encoding _ identityPixel3Encoding, matrix: Matrix3, hints: Atom.PropList] RETURNS [ColorOperator]; <<... a color model for calibrated color. The parameters specify a mapping from a 3-sample pixel to a set CIE tristimulus values as follows: first, each sample is looked up in its SampleEncoding table to yield a real number (if the table is NIL, the sample is simply converted to a real number without scaling). Then the resulting row vector is postmultiplied by the matrix to yield a row vector containing the [X, Y, Z] tristimulus values, normalized so that the maximum attainable Y component is 1.>> <> NewColorOperatorRGB: PROC [maxIn: Sample] RETURNS [ColorOperator]; <<... a color model for uncalibrated red, green, blue separations; expects samplesPerPixel=3. For each separation, 0 ~ minimum intensity, maxIn ~ maximum intensity.>> NewColorOperatorCMY: PROC [maxIn: Sample] RETURNS [ColorOperator]; <<... a color model for uncalibrated cyan, magenta, yellow separations; expects samplesPerPixel=3. For each separation, 0 ~ no ink, maxIn ~ full ink coverage.>> NewColorOperatorCMYK: PROC [maxIn: Sample] RETURNS [ColorOperator]; <<... a simple color model for cyan, magenta, yellow, black separations; expects samplesPerPixel=4. For each separation, 0 ~ no ink, maxIn ~ full ink coverage.>> ColorValue: TYPE ~ [0..256); ColorValueTriple: TYPE ~ PACKED ARRAY [0..3) OF ColorValue; -- red, green, blue ColorMapProc: TYPE ~ PROC [Sample] RETURNS [ColorValueTriple]; NewColorOperatorColorMap: PROC [maxIn: Sample, map: ColorMapProc] RETURNS [ColorOperator]; <<... a color operator corresponding to the color map in certain display devices (although still device independent). Each ColorValueTriple is interpreted according to the color operator obtained from NewColorOperatorRGB[ColorValue.LAST].>> <<>> NewColorOperatorAlpha: PROC [colorOperator: ColorOperator, maxAlphaIn: Sample] RETURNS [ColorOperator]; <> <> MakeSampledBlack: PROC [pa: IIPixelArray.PixelArray, um: IITransformation.Transformation, clear: BOOL _ FALSE] RETURNS [SampledBlack]; MakeSampledColor: PROC [pa: IIPixelArray.PixelArray, um: IITransformation.Transformation, colorOperator: ColorOperator] RETURNS [SampledColor]; <> ColorFromStipple: PROC [word: WORD, function: IISample.Function] RETURNS [SpecialColor]; <> END.