~
BEGIN
LookupTable: TYPE = REF LookupTableRep;
LookupTableRep:
TYPE =
RECORD [
SEQUENCE size:
NAT
OF
REAL];
Represents, by means of equally-spaced samples, a function that maps the real interval [0.0,1.0] into real values.
The value of table[0] represents the value of the function at 0.0, table[tableSize-1] represents the value of the function at 1.0, and the remaining samples are equally-spaced in between these two extremes. Intermediate values are filled in, if necessary, by linear interpolation. These functions are used to provide some rudimentary control of the generation of device-dependent color.
ColorLookupTableType:
TYPE = {redTransfer, greenTransfer, blueTransfer, grayTransfer, blackGeneration, undercolorRemoval, spare1, spare2, spare3};
This enumeration is used to distinguish which of the various 1-d lookup tables are being referenced.
redTransfer, greenTransfer, blueTransfer, grayTransfer
The RED, GREEN, BLUE, and GRAY transfer functions are applied as the final client-controlled stage of color generation (prior to any halftoning). Each of these functions transform a device-dependent component of the color independently of the other components. For a monochrome device, only the GRAY transfer function is used. For an RGB device, only the RED, GREEN, BLUE transfer functions are used, with one exception. The exception occurs whan a Gray color operator is in effect, in which case the GRAY transfer function is used prior to the conversion to RGB, and the RED, GREEN, BLUE transfer functions are not used. For a CMYK device, all four transfer functions are used; in this case, values of 0 correspond to maximum colorant, and values of 1 correspond minimum colorant; note this is the inverse of the usual sense of CMYK.
There is the possibility of a device for which this expression of a final transfer function makes very little sense, for instance if the target is a CIE L*a*b* rendition. The device may ignore the transfer functions in such a case, except that the GRAY transfer shall always apply to the results of the Gray color operator. For the transfer functions, a NIL lookupTable corresponds to the identity function. All four transfer functions should be provided; if only a gray transfer function is available, it should be used for all four.
blackGeneration
This function (BG) is used when the device needs to produce a CMYK output, and it only has three-component (CMY) color. The input to the BG is the minimum of the cyan, magenta, and yellow components, and the output is the amount of black; the range for both input and output is 0 (minimum colorant) to 1 (maximum colorant). Notice the sense of these numbers is opposite to that of the inputs and outputs of the transfer functions. A NIL BG lookupTable corresponds to the constant zero function.
undercolorRemoval
This function (UCR) is used under the same circumstances as the black generation function, and takes the same input. The output is in the range -1 to +1, and says how much colorant to remove from each of the cyan, magenta, and yellow components. A NIL UCR lookupTable corresponds to the constant zero function.
Note that this form of specification of BG and UCR functions is quite limited; some devices may benefit from functions that use more information than just MIN(C,M,Y). Such functions might be expressed as part of (device-dependent) data passed to SetColorTable. A device that recognizes this situation may end up effectively ignoring the BG and UCR lookup tables, because the color correction intrinsically generates CMYK.
DeviceColorControl: TYPE = REF DeviceColorControlRep;
DeviceColorControlRep:
TYPE =
RECORD [
table: ARRAY ColorLookupTableType OF LookupTable,
allIdentity: BOOL ¬ TRUE, -- true only if all the transfer functions are identity.
setLookupTable: SetLookupTableProc ¬,
stamp: CARD ¬ 0,
propList: Prop.PropList ¬ NIL,
private: REF PrivateRep ¬ NIL
];
GetDeviceColorControl:
PROC [device: ImagerDevice.Device]
RETURNS [DeviceColorControl];
The initial implementation places the DeviceColorControl on device.parm.propList. All uses of it should go through this routine, to simplify conversion if and when its location changes. If necessary, this routine will create a new DeviceColorControl.
SetLookupTableProc: TYPE = PROC [control: DeviceColorControl, which: ColorLookupTableType, table: LookupTable];
SetLookupTable: SetLookupTableProc
= INLINE { control.setLookupTable[control, which, table] };
SetLookupTable should be used in preference to changing the tables directly.
DefaultSetLookupTable:
PROC [control: DeviceColorControl, which: ColorLookupTableType, table: LookupTable];
The stamp is incremented by one whenever the tables are changed; this is to simplify checks for cache consistency. This also maintains control.allIdentity. This should be used in preference to changing the tables directly.
LookupReal:
PROC [table: LookupTable, real:
REAL]
RETURNS [
REAL];
Applies the table, interpolating if necessary. A NIL table acts like the identity function.
LookupFlipped:
PROC [table: LookupTable, real:
REAL]
RETURNS [
REAL];
Complements both input and output.
ColorPoint: TYPE = ImagerColorPrivate.ColorPoint;
Note: all of the following deal with inputs in the range [0.0..1.0], and outputs in the range [0.0..maxOut]
CMYKFromCMYK:
PUBLIC
PROC [control: DeviceColorControl, c, m, y, k:
REAL, maxOut:
REAL, out: ColorPoint];
Applies transfer functions.
CMYKFromCMY:
PUBLIC
PROC [control: DeviceColorControl, c, m, y:
REAL, maxOut:
REAL, out: ColorPoint];
Applies BG, UCR, and transfer functions.
CMYKFromRGB:
PUBLIC
PROC [control: DeviceColorControl, r, g, b:
REAL, maxOut:
REAL, out: ColorPoint];
Applies BG, UCR, and transfer functions.
RGBFromRGB:
PUBLIC
PROC [control: DeviceColorControl, r, g, b:
REAL, maxOut:
REAL, out: ColorPoint];
Applies transfer functions.
RGBFromCMYK:
PUBLIC
PROC [control: DeviceColorControl, c, m, y, k:
REAL, maxOut:
REAL, out: ColorPoint];
Converts to RGB, then applies transfer functions.
YFromY:
PUBLIC
PROC [control: DeviceColorControl,
Y:
REAL, maxOut:
REAL, out: ColorPoint];
Applies gray transfer function.
CMYKFromY:
PUBLIC
PROC [control: DeviceColorControl,
Y:
REAL, maxOut:
REAL, out: ColorPoint];
Applies gray transfer function, inverts sense, clears cmy.
KFromY:
PUBLIC
PROC [control: DeviceColorControl,
Y:
REAL, maxOut:
REAL, out: ColorPoint];
Applies gray transfer function, inverts sense.