DIRECTORY ImagerPixelArray USING [PixelArray], ImagerTransformation USING [Transformation], Rope USING [ROPE]; ImagerColor: CEDAR DEFINITIONS ~ BEGIN SampleValue: TYPE ~ REAL; ROPE: TYPE ~ Rope.ROPE; Color: TYPE ~ REF ColorRep; ColorRep: TYPE ~ RECORD [ SELECT tag: * FROM constant => [ SELECT tag: * FROM op => [ colorOperator: ColorOperator, pixel: SEQUENCE size: NAT OF SampleValue ], special => [ -- XOR, stipples, named colors, and the like type: ATOM, -- identifies the kind of special color this is name: ROPE, -- hierarchical name data: REF, -- implementation-specific data substitute: ConstantColor -- use this if you don't recognize type ], ENDCASE ], sampled => [ -- the result of MakeSampledColor pa: ImagerPixelArray.PixelArray, -- the array of pixels um: ImagerTransformation.Transformation, -- transforms from color to device coordinates colorOperator: ColorOperator -- maps pixels into constant colors ], sampledBlack => [ -- the result of MakeSampledBlack pa: ImagerPixelArray.PixelArray, -- the array of pixels (must be 1 bit per pixel) um: ImagerTransformation.Transformation, -- transforms from color to device coordinates clear: BOOL -- are zero bits transparent? ], ENDCASE ]; ConstantColor: TYPE ~ REF ColorRep.constant; OpConstantColor: TYPE ~ REF ColorRep.constant.op; SpecialColor: TYPE ~ REF ColorRep.constant.special; SampledColor: TYPE ~ REF ColorRep.sampled; SampledBlack: TYPE ~ REF ColorRep.sampledBlack; Structure: TYPE ~ REF StructureRep; StructureRep: TYPE ~ RECORD [class: StructureClass, data: REF]; StructureClass: TYPE ~ REF StructureClassRep; StructureClassRep: TYPE; 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 appearanceHints: Structure -- Hints to the implementation about the desired appearance ]; ColorOperatorClassRep: TYPE; Find: PROC [name: ROPE] RETURNS [ConstantColor]; ColorFromPixel: PROC [colorOperator: ColorOperator, pixel: PROC [sampleIndex: NAT] RETURNS [REAL]] RETURNS [ConstantColor]; NarrowToOpConstantColor: PROC [color: ConstantColor] RETURNS [OpConstantColor]; MakeSampledBlack: PROC [pa: ImagerPixelArray.PixelArray, um: ImagerTransformation.Transformation, clear: BOOL ¬ FALSE] RETURNS [SampledBlack]; MakeSampledColor: PROC [pa: ImagerPixelArray.PixelArray, um: ImagerTransformation.Transformation, colorOperator: ColorOperator] RETURNS [SampledColor]; ColorFromGray: PROC [f: REAL] RETURNS [OpConstantColor]; SampleTableProc: TYPE ~ PROC [NAT] RETURNS [REAL]; NewColorOperatorGrayLinear: PROC [sWhite, sBlack: REAL, sampleTableSize: NAT ¬ 0, sampleTableProc: SampleTableProc ¬ NIL] RETURNS [ColorOperator]; NewColorOperatorGrayDensity: PROC [sWhite, sBlack, dBlack: REAL, sampleTableSize: NAT ¬ 0, sampleTableProc: SampleTableProc ¬ NIL] RETURNS [ColorOperator]; NewColorOperatorGrayVisual: PUBLIC PROC [sWhite, sBlack: REAL, sampleTableSize: NAT ¬ 0, sampleTableProc: SampleTableProc ¬ NIL] RETURNS [ColorOperator]; NewColorOperatorMap: PROC [maxSampleValue: NAT, map: PROC [NAT] RETURNS [ConstantColor]] RETURNS [ColorOperator]; NewColorOperatorBuildMap: PROC [colorOperator: ColorOperator, maxSampleValue: NAT, map: SampleTableProc] RETURNS [ColorOperator]; PixelEncoding: TYPE ~ REF PixelEncodingRep; PixelEncodingRep: TYPE ~ RECORD [SEQUENCE samplesPerPixel: NAT OF SampleEncoding]; SampleEncoding: TYPE ~ REF SampleEncodingRep; SampleEncodingRep: TYPE ~ RECORD [SEQUENCE size: NAT OF REAL]; RGB: TYPE ~ RECORD [R, G, B: REAL]; ColorFromRGB: PROC [rgb: RGB] RETURNS [OpConstantColor]; RGBFromColor: PROC [c: OpConstantColor] RETURNS [RGB]; NewColorOperatorRGB: PROC [sWhite: REAL, sBlack: REAL ¬ 0, map: PixelEncoding ¬ NIL, appearanceHints: Structure ¬ NIL] RETURNS [ColorOperator]; ColorFromHSV: PROC [H, S, V: REAL] RETURNS [OpConstantColor]; HSVFromColor: PROC [c: OpConstantColor] RETURNS [H, S, V: REAL]; YES: TYPE ~ RECORD [Y, E, S: REAL]; ColorFromYES: PROC [yes: YES] RETURNS [OpConstantColor]; YESFromColor: PROC [c: OpConstantColor] RETURNS [yes: YES]; NewColorOperatorYES: PROC [sWhite, sBlack, sneutral, srange: REAL, map: PixelEncoding ¬ NIL, appearanceHints: Structure ¬ NIL] RETURNS [ColorOperator]; CIELAB: TYPE ~ RECORD [lStar, aStar, bStar: REAL]; ColorFromCIELAB: PROC [cielab: CIELAB] RETURNS [OpConstantColor]; CIELABFromColor: PROC [c: OpConstantColor] RETURNS [CIELAB]; NewColorOperatorCIELAB: PROC [sWhite, sBlack, sneutral, srange: REAL, map: PixelEncoding ¬ NIL, appearanceHints: Structure ¬ NIL] RETURNS [ColorOperator]; Highlight: TYPE ~ RECORD [b, h: REAL]; ColorFromHighlight: PROC [highlight: Highlight] RETURNS [OpConstantColor]; HighlightFromColor: PROC [c: OpConstantColor] RETURNS [Highlight]; NewColorOperatorHighlight: PROC [sWhite, sBlack: REAL, map: PixelEncoding ¬ NIL, baseColor, highlightColor: OpConstantColor, appearanceHints: Structure ¬ NIL] RETURNS [ColorOperator]; MaxSampleProc: TYPE ~ PROC [pixelIndex: NAT] RETURNS [NAT]; SignalType: TYPE ~ MACHINE DEPENDENT { dotPercent, reflectance, transmittance, density, (CARD32.LAST) }; SignalTypeFromSignalTypeName: PROC [ROPE] RETURNS [SignalType]; SignalTypeNameFromSignalType: PROC [SignalType] RETURNS [ROPE]; NewColorOperatorProcess: PROC [su, sz: REAL, signals: NAT, map: PixelEncoding ¬ NIL, signalType: SignalType, signalNames: PROC [signal: NAT] RETURNS [ConstantColor], deviceProps: Structure ¬ NIL] RETURNS [ColorOperator]; CMYK: TYPE ~ RECORD [C, M, Y, K: REAL]; ColorFromCMYK: PROC [cmyk: CMYK] RETURNS [OpConstantColor]; NewColorOperatorCMYK: PROC [maxIn: NAT] RETURNS [ColorOperator]; END.  ImagerColor.mesa Copyright Σ 1985, 1986, 1987, 1991, 1992 by Xerox Corporation. All rights reserved. Doug Wyatt, March 6, 1986 9:59:30 pm PST Michael Plass, October 25, 1991 10:24 pm PDT Stone, October 17, 1991 5:16 pm PDT The Color type The Structure type This type provides a method of representing data that can be externalized and internalized easily; it corresponds fairly closely with an Interpress Vector. The concrete class representation and the operations are in another interface, ImagerColorPrivate, to avoid undesirable interface dependencies. The ColorOperator type A color operator specifies how to interpret pixel values as constant colors. Constant colors Finds the color with the given hierarchical name (color names, etc.). Creates a constant color by applying a color operator to a single pixel. Dereferences any chain of special colors Sampled colors Monochrome Color Operators Constant gray; f is the fraction of absorptance, from 0 (background) to 1 (black). Imager.MakeGray is identical; see MAKEGRAY in the Interpress standard, section 4.7.1. ... colorModelOperators/Xerox/GrayLinear, as specified in the Color Encoding Standard. The resulting ColorOperator maps a single sample s0 into MakeGray[f], where: s ¬ IF sampleTableSize=0 THEN s0 ELSE sampleMap[s0]; f ¬ MIN[MAX[(s-sWhite)/(sBlack-sWhite), 0.0], 1.0]; ... colorModelOperators/Xerox/GrayDensity, as specified in the Color Encoding Standard. The resulting ColorOperator maps a single sample s0 into MakeGray[f], where: s ¬ IF sampleTableSize=0 THEN s0 ELSE sampleMap[s0]; d ¬ ((s-sWhite)/(sBlack-sWhite))*dBlack; f ¬ MIN[MAX[1-10**d, 0.0], 1.0]; -- 10**d means 10 to the power d ... colorModelOperators/Xerox/GrayVisual, as specified in the Color Encoding Standard. The resulting ColorOperator maps a single sample s0 into MakeGray[f], where: s ¬ IF sampleTableSize=0 THEN s0 ELSE sampleMap[s0]; L ¬ (s-sBlack)/(sWhite-sBlack); Y ¬ IF L<=0.09 THEN L/0.09 ELSE ((L+0.16)/0.25)**3; f ¬ MIN[MAX[1-0.01*Y, 0.0], 1.0]; Map Color Operators ... colorModelOperators/Xerox/Map, as specified in the Color Encoding Standard. The resulting ColorOperator maps a single sample s0 into the ConstantColor map[s0]. ... colorModelOperators/Xerox/BuildMap, as specified in the Color Encoding Standard. The resulting ColorOperator maps a single sample s0 into the ConstantColor obtained by applying colorOperator to map[s0] PixelEncoding The PixelEncoding type corresponds with the Interpress vector of vectors of numbers that the Color Encoding Standard refers to as a pixelmap. We use a different name here because the Imager has a different meaning for the term pixelMap. RGBLinear ... Xerox/RGBLinear (Color Encoding Standard) Red, green, and blue, as for a color monitor or scanner; R, G, and B range from 0 to 1. sWhite is the sample value to be mapped to R=G=B=1 and sBlack is the sample value to be mapped to R=G=B=0, where the R, G and B are the color coordinates of the Xerox/RGBLinear color model. HSV ... convenience procedures; really produce an RGBLinear color. Hue, Saturation, Value; H, S, and V range from 0 to 1. If V=0 (black), H and S are irrelevant. If S=0 (achromatic), H is irrelevant. The HSV space is a hexcone; see Foley and van Dam, section 17.4.4. YESLinear ... Xerox/YESLinear (Color Encoding Standard) CIELAB ... Xerox/CIELAB (Color Encoding Standard) Highlight ... Xerox/HighlightLinear (Color Encoding Standard) Process, CMYK ... Xerox/Process (Color Encoding Standard) ... CMYK is a useful special case. Cyan, Magenta, Yellow, Black, for a color printer. C, M, Y, K range from 0 to 1 Cyan, Magenta, Yellow, Black, in the range 0 to 1. ... a convenience color model for cyan, magenta, yellow, black separations; expects samplesPerPixel=4. For each separation, 0 ~ no ink, maxIn ~ full ink coverage. Really turns into a process ColorOperator. Κ `•NewlineDelimiter –(cedarcode) style™codešœ™Kšœ ΟeœI™TKšœ(™(K™,K™#K™—šΟk ˜ Kšœžœ˜$Kšœžœ˜,Kšœžœžœ˜—K˜KšΟn œžœž ˜šœž˜K˜Kšœ žœžœ˜Kšžœžœžœ˜—head™Kšœžœžœ ˜šœ žœžœ˜šžœž˜šœ ˜ šžœž˜šœ˜Kšœ˜Kšœžœžœžœ ˜(Kšœ˜—šœ Οc,˜9Kšœžœ /˜;Kšœžœ ˜ Kšœžœ ˜*Kšœ '˜AKšœ˜—Kšž˜—Kšœ˜—šœ  !˜.Kšœ! ˜7Kšœ) .˜WKšœ #˜@K˜—šœ !˜3Kšœ! 0˜QKšœ) .˜WKšœžœ ˜)K˜—Kšž˜—K˜K˜—K˜Kšœžœžœ˜,Kšœžœžœ˜1šœžœžœ˜3K˜—Kšœžœžœ˜*Kšœžœžœ˜/—šœ™K™¬Kšœ žœžœ˜#Kšœžœžœžœ˜?Kšœžœžœ˜-Kšœžœ˜—™K™LKšœžœžœ˜+šœžœžœ˜!Kšœ žœ  ˜1Kšœžœ (˜@Kšœžœ w˜™Kšœžœ t˜Kšœ ;˜VK˜—Kšœžœ˜—™šŸœžœžœžœ˜0KšœE™EK™—šŸœžœ'žœžœžœžœžœ˜|KšœH™HK˜—šŸœžœžœ˜OK™(——™š ŸœžœSžœžœžœ˜ŽK˜—KšŸœžœjžœ˜——šœ™šŸ œžœžœžœ˜8K™RKšœU™UK˜—š œžœžœžœžœžœ˜2K˜—š Ÿœžœžœžœ)žœžœ˜’K™VšœL™LKšœ4™4Kšœ3™3—K˜—š Ÿœžœžœžœ)žœžœ˜›K™WšœL™LKšœ4™4Kšœ(™(KšœA™A—K™—šŸœžœžœžœžœ)žœžœ˜™K™VšœL™LKšœ4™4Kšœ™Kšœ3™3Kšœ!™!———šœ™šŸœžœžœžœžœžœžœ˜qK™OKšœS™SK˜—šŸœžœ0žœžœ˜K™TKšœx™x——šœ ™ Icode2šœ„œa™νMšœžœžœ˜+š œžœžœžœžœžœ˜RK˜—Kšœžœžœ˜-Kš œžœžœžœžœžœžœ˜>—• CharPropsaPostfix0 1 .3 textColorPostfix1 3 .div 1 .3 textColorPostfix2 3 .div 1 .3 textColoršœ ™ Kšœ.™.–ΖPostfix0 1 .3 textColorPostfix1 3 .div 1 .3 textColorPostfix2 3 .div 1 .3 textColorPostfix0 1 .3 textColorPostfix1 3 .div 1 .3 textColorPostfix2 3 .div 1 .3 textColoršžœžœžœ žœ˜#K–ePostfix0 1 .3 textColorPostfix1 3 .div 1 .3 textColorPostfix2 3 .div 1 .3 textColorCšœW™WK™—KšŸ œžœžœžœ˜8šŸ œžœžœžœ˜6K˜—šŸœžœ žœ žœžœžœžœ˜K™½——šœ™Kšœ>™>KšŸ œžœ žœžœ˜=šŸ œžœžœ žœ˜@Kšœ6™6KšœN™NKšœB™B——™ Kšœ.™.šžœžœžœ žœ˜#K˜—KšŸ œžœžœžœ˜8šŸ œžœžœžœ˜;K˜—š Ÿœžœ$žœžœžœžœ˜—K˜——šœ™Kšœ*™*šžœžœžœžœ˜2K˜—KšŸœžœ žœžœ˜AšŸœžœžœžœ˜