1*3ff48bf5SDavid du ColombierThis directory contains a subset of the icclib 2.0 distribution for 2*3ff48bf5SDavid du Colombieruse with Ghostscript. The full version of icclib is available from 3*3ff48bf5SDavid du ColombierGraeme Gill's website: http://web.access.net.au/argyll/color.html 4*3ff48bf5SDavid du Colombier 5*3ff48bf5SDavid du ColombierIn the near future, we expect to treat icclib much the same way we 6*3ff48bf5SDavid du Colombierdo libjpeg and friends. At that point, it will be available from 7*3ff48bf5SDavid du Colombierthe Ghostscript download locations, but won't actually be included 8*3ff48bf5SDavid du Colombierin the Ghostscript distribution proper, or in the source tree. 9*3ff48bf5SDavid du Colombier 10*3ff48bf5SDavid du ColombierRaph Levien 11*3ff48bf5SDavid du Colombier18 October 2001 12*3ff48bf5SDavid du Colombier 13*3ff48bf5SDavid du ColombierRelease notes by Jan Stoeckenius follow (lightly edited by Raph Levien 14*3ff48bf5SDavid du Colombierto reflect the icclib 2.0 integration): 15*3ff48bf5SDavid du Colombier 16*3ff48bf5SDavid du ColombierThis patch integrates Graeme W. Gill's icclib code into ghostscript, 17*3ff48bf5SDavid du Colombierto support ICCBased color spaces for both PostScript and PDF. 18*3ff48bf5SDavid du Colombier 19*3ff48bf5SDavid du ColombierThe PDF support is as documented in version 1.3 of PDF; see the "PDR 20*3ff48bf5SDavid du ColombierReference", 2nd. ed., Sec. 4.5.4 (pp. 165 - 180). 21*3ff48bf5SDavid du Colombier 22*3ff48bf5SDavid du ColombierSupport for PostScript is essentially identical. An ICCBased color space is 23*3ff48bf5SDavid du Colombierarray of the form: 24*3ff48bf5SDavid du Colombier 25*3ff48bf5SDavid du Colombier [ /ICCBased <dictionary> ] 26*3ff48bf5SDavid du Colombier 27*3ff48bf5SDavid du ColombierThe recognized entries in the dictionary are: 28*3ff48bf5SDavid du Colombier 29*3ff48bf5SDavid du Colombier N integer (Required) The number of color space components, 30*3ff48bf5SDavid du Colombier as in the PDF dictionary. This may be 1, 3, or 4. 31*3ff48bf5SDavid du Colombier 32*3ff48bf5SDavid du Colombier Alternate array or (Optional) The alternative color space to use if 33*3ff48bf5SDavid du Colombier name the ICC profile is not useable (for any reason). 34*3ff48bf5SDavid du Colombier If this entry is not provided, its default value 35*3ff48bf5SDavid du Colombier is determined by N, using the rule 1 ==> DeviceGray, 36*3ff48bf5SDavid du Colombier 3 ==> DeviceRGB, 4 ==> DeviceCMYK. All this is 37*3ff48bf5SDavid du Colombier the same as in the PDF dictionary. 38*3ff48bf5SDavid du Colombier 39*3ff48bf5SDavid du Colombier Range array (Optional) An array of 2 * N numbers, which obey 40*3ff48bf5SDavid du Colombier the relationship Range[2 * i] <= Range[2 * i + 1]. 41*3ff48bf5SDavid du Colombier The i'th component of a color, c[i], is 42*3ff48bf5SDavid du Colombier constrained such that: 43*3ff48bf5SDavid du Colombier 44*3ff48bf5SDavid du Colombier Range[2 * i] <= c[i] <= Range[2 * i + 1] 45*3ff48bf5SDavid du Colombier 46*3ff48bf5SDavid du Colombier If this entry is not provided, its default value 47*3ff48bf5SDavid du Colombier is an array of length 2 * N with the form 48*3ff48bf5SDavid du Colombier [ 0 1 0 1 ... ]. All of this is the same as for 49*3ff48bf5SDavid du Colombier the PDF dictionary. 50*3ff48bf5SDavid du Colombier 51*3ff48bf5SDavid du Colombier DataSource file or (Required)The ICC profile data. If this is a 52*3ff48bf5SDavid du Colombier string file it must be positionable. 53*3ff48bf5SDavid du Colombier 54*3ff48bf5SDavid du ColombierWith the exception of running out of memory, most errors discovered while 55*3ff48bf5SDavid du Colombierreading the profile will result in the alternative space being used. 56*3ff48bf5SDavid du Colombier 57*3ff48bf5SDavid du Colombier 58*3ff48bf5SDavid du ColombierNew Files: 59*3ff48bf5SDavid du Colombier 60*3ff48bf5SDavid du Colombier src/gsicc.c 61*3ff48bf5SDavid du Colombier Implementation of the methods associated with the ICCBased color space 62*3ff48bf5SDavid du Colombier structure (a gs_color_space_s structure of type gs_color_space_index_CIEICC). 63*3ff48bf5SDavid du Colombier The gs_cspace_build_CIEICC procedure is also implemented in this file. 64*3ff48bf5SDavid du Colombier 65*3ff48bf5SDavid du Colombier src/gsicc.h 66*3ff48bf5SDavid du Colombier Definition of the gs_cie_icc_s structure, which is the essential 67*3ff48bf5SDavid du Colombier parameter structure for ICCBased color spaces. The files in this 68*3ff48bf5SDavid du Colombier structure are all straightforward, except for the file_id field. This 69*3ff48bf5SDavid du Colombier latter field is compared with the read_id and write_id of a stream, 70*3ff48bf5SDavid du Colombier to verify that the stream is still valid. This is the same mechanism 71*3ff48bf5SDavid du Colombier as is used by the ref structure, and for the same reason. 72*3ff48bf5SDavid du Colombier 73*3ff48bf5SDavid du Colombier src/zicc.c 74*3ff48bf5SDavid du Colombier Implementation of the .seticcspace operator, which is used to set the 75*3ff48bf5SDavid du Colombier current color space to be an ICCBased color space. 76*3ff48bf5SDavid du Colombier 77*3ff48bf5SDavid du Colombier src/icclib.mak 78*3ff48bf5SDavid du Colombier Makefile for building the icclib code (which is in a separate directory). 79*3ff48bf5SDavid du Colombier The mechanism used is identical to that used by zlib.mak. 80*3ff48bf5SDavid du Colombier 81*3ff48bf5SDavid du Colombier lib/gs_icc.ps 82*3ff48bf5SDavid du Colombier Implementation of the ICCBased color space specific routine in 83*3ff48bf5SDavid du Colombier colorspacedict. This routine is much more extensive that those used 84*3ff48bf5SDavid du Colombier for the other color spaces, both due to the greater complexity of the 85*3ff48bf5SDavid du Colombier color space and because we have chosen to implement much of the error 86*3ff48bf5SDavid du Colombier checking in this routine. 87*3ff48bf5SDavid du Colombier 88*3ff48bf5SDavid du Colombier NB: To disable support for ICCBased color spaces, replace "NOCIE" in 89*3ff48bf5SDavid du Colombier this file with "true". Though ICCBased will still be a recognized 90*3ff48bf5SDavid du Colombier color space family, the alternative space will always be used. 91*3ff48bf5SDavid du Colombier 92*3ff48bf5SDavid du Colombier gs_icclib/icc.c 93*3ff48bf5SDavid du Colombier gs_icclib/icc.h 94*3ff48bf5SDavid du Colombier gs_icclib/icc9809.h 95*3ff48bf5SDavid du Colombier The gs_icclib directory is the default location of the icclib code. 96*3ff48bf5SDavid du Colombier The files in this directory are identical to those of the usual 97*3ff48bf5SDavid du Colombier distribution of this library. 98*3ff48bf5SDavid du Colombier 99*3ff48bf5SDavid du Colombier 100*3ff48bf5SDavid du ColombierModified Files: 101*3ff48bf5SDavid du Colombier 102*3ff48bf5SDavid du Colombier src/gdevpdfc.c 103*3ff48bf5SDavid du Colombier Added support for ICCBased color spaces to the pdf_color_space procedure. 104*3ff48bf5SDavid du Colombier These are effectively translated into themselves, with the DataSource 105*3ff48bf5SDavid du Colombier component replaced by a (PDF) stream. 106*3ff48bf5SDavid du Colombier 107*3ff48bf5SDavid du Colombier src/gdevpx.c 108*3ff48bf5SDavid du Colombier Added ICCBased to the set of color spaces that 109*3ff48bf5SDavid du Colombier pclxl_can_handle_color_space reports as one that cannot be handled. 110*3ff48bf5SDavid du Colombier 111*3ff48bf5SDavid du Colombier src/gscie.c 112*3ff48bf5SDavid du Colombier Added support for ICCBased color spaces in the cie_cs_common_abc 113*3ff48bf5SDavid du Colombier procedure. Also exported gx_cie_common_complete (previously 114*3ff48bf5SDavid du Colombier cie_common_complete) and gx_cie_load_common_cache (previously 115*3ff48bf5SDavid du Colombier cie_load_common_cache) for use in gsicc.c. 116*3ff48bf5SDavid du Colombier 117*3ff48bf5SDavid du Colombier src/gscie.h 118*3ff48bf5SDavid du Colombier Modified the definitions of st_cie_common and st_cie_common_elements 119*3ff48bf5SDavid du Colombier to be public. 120*3ff48bf5SDavid du Colombier 121*3ff48bf5SDavid du Colombier src/gsciemap.c 122*3ff48bf5SDavid du Colombier Removed the definition of the macro CIE_CHECK_RENDERING (it is now in 123*3ff48bf5SDavid du Colombier gxcie.h). Exported gx_cie_remap_finish (previously cie_remap_finish) 124*3ff48bf5SDavid du Colombier for use in gsicc.c. 125*3ff48bf5SDavid du Colombier 126*3ff48bf5SDavid du Colombier src/gscolor.c 127*3ff48bf5SDavid du Colombier Added support for ICCBased color spaces in gs_currentrgbcolor. 128*3ff48bf5SDavid du Colombier 129*3ff48bf5SDavid du Colombier src/gscolor1.c 130*3ff48bf5SDavid du Colombier Added support for ICCBased color spaces in gs_currentcmykcolor. 131*3ff48bf5SDavid du Colombier 132*3ff48bf5SDavid du Colombier src/gscscie.c 133*3ff48bf5SDavid du Colombier Exported st_cie_common, st_cie_common_elements, gx_concrete_space_CIE, 134*3ff48bf5SDavid du Colombier gx_install_CIE, gx_set_common_cie_defaults (previously 135*3ff48bf5SDavid du Colombier set_common_cie_defaults), and gx_build_cie_space (previously 136*3ff48bf5SDavid du Colombier build_cie_space) for use in gsicc.c. 137*3ff48bf5SDavid du Colombier 138*3ff48bf5SDavid du Colombier src/gscspace.h 139*3ff48bf5SDavid du Colombier Added the gs_icc_params data structure (for ICCBased color spaces), 140*3ff48bf5SDavid du Colombier and the associated type indicator (gs_color_space_index_CIEICC). Also 141*3ff48bf5SDavid du Colombier broke what had been the gs_base_color_space structure into two, with 142*3ff48bf5SDavid du Colombier gs_small_base_color_space covering all the prior base color spaces, 143*3ff48bf5SDavid du Colombier and gs_base_color_space covering these and the ICCBased color space. 144*3ff48bf5SDavid du Colombier See the comments in the file for an explanation as to why this was 145*3ff48bf5SDavid du Colombier necessary. 146*3ff48bf5SDavid du Colombier 147*3ff48bf5SDavid du Colombier src/gscssub.c 148*3ff48bf5SDavid du Colombier Added code to allow ICCBased color spaces to be substituted for the 149*3ff48bf5SDavid du Colombier device specific color spaces. This is necessary to support the 150*3ff48bf5SDavid du Colombier DefaultDevice* color spaces in PDF. 151*3ff48bf5SDavid du Colombier 152*3ff48bf5SDavid du Colombier src/gxcie.h 153*3ff48bf5SDavid du Colombier Moved the definition of the CIE_CHECK_RENDERING macro to this file 154*3ff48bf5SDavid du Colombier (it was in gsciemap.c). Added prototypes for st_cie_common, 155*3ff48bf5SDavid du Colombier st_cie_common_elemets_t, gx_set_common_cie_defaults, 156*3ff48bf5SDavid du Colombier gx_cie_load_common_cache, gx_cie_common_complete, gx_install_CIE, 157*3ff48bf5SDavid du Colombier gx__build_cie_space, and gs_concrete_cspace_CIE. 158*3ff48bf5SDavid du Colombier 159*3ff48bf5SDavid du Colombier src/gxshade.c 160*3ff48bf5SDavid du Colombier Added support for ICCBased color spaces in shade_init_fill_state. 161*3ff48bf5SDavid du Colombier 162*3ff48bf5SDavid du Colombier src/icie.h 163*3ff48bf5SDavid du Colombier Added a prototype for cie_set_finish. 164*3ff48bf5SDavid du Colombier 165*3ff48bf5SDavid du Colombier src/zcie.c 166*3ff48bf5SDavid du Colombier Exported cie_set_finish (previously set_cie_finish) for use in zicc.c 167*3ff48bf5SDavid du Colombier (the name change maintains consistency with other exported CIE-specific 168*3ff48bf5SDavid du Colombier interpreter routines). 169*3ff48bf5SDavid du Colombier 170*3ff48bf5SDavid du Colombier src/lib.mak 171*3ff48bf5SDavid du Colombier Added the sicclib.dev feature device, and the associated compilation 172*3ff48bf5SDavid du Colombier directives and dependency lists. Also updated the dependency lists 173*3ff48bf5SDavid du Colombier for gscie.c and gxshade.c (both now require gsicc.h). 174*3ff48bf5SDavid du Colombier 175*3ff48bf5SDavid du Colombier src/int.mak 176*3ff48bf5SDavid du Colombier Added the icc.dev feature device, and the associated compilation 177*3ff48bf5SDavid du Colombier directives and dependency lists. This pdf.dev feature device now 178*3ff48bf5SDavid du Colombier lists icc.dev as a prerequisite. 179*3ff48bf5SDavid du Colombier 180*3ff48bf5SDavid du Colombier src/devs.mak 181*3ff48bf5SDavid du Colombier Updated the dependency list for gdevpdfc.c. 182*3ff48bf5SDavid du Colombier 183*3ff48bf5SDavid du Colombier src/bcwin32.mak 184*3ff48bf5SDavid du Colombier src/dvx-gcc.mak 185*3ff48bf5SDavid du Colombier src/msvc32.mak 186*3ff48bf5SDavid du Colombier src/msvclib.mak 187*3ff48bf5SDavid du Colombier src/openvms.mak 188*3ff48bf5SDavid du Colombier src/os2.mak 189*3ff48bf5SDavid du Colombier src/ugcclib.mak 190*3ff48bf5SDavid du Colombier src/unix-gcc.mak 191*3ff48bf5SDavid du Colombier src/unixansi.mak 192*3ff48bf5SDavid du Colombier src/unixtrad.mak 193*3ff48bf5SDavid du Colombier src/watc.mak 194*3ff48bf5SDavid du Colombier src/watclib.mak 195*3ff48bf5SDavid du Colombier src/watcw32.mak 196*3ff48bf5SDavid du Colombier Added a default definition for ICCSRCDIR, the source directory for 197*3ff48bf5SDavid du Colombier the icclib code. 198*3ff48bf5SDavid du Colombier 199*3ff48bf5SDavid du Colombier src/gs.mak 200*3ff48bf5SDavid du Colombier Added default definitions for ICCGENDIR, ICCOBJDIR, ICCI_ (ICC specific 201*3ff48bf5SDavid du Colombier include directories), and ICCF_ (currently empty). 202*3ff48bf5SDavid du Colombier 203*3ff48bf5SDavid du Colombier 204*3ff48bf5SDavid du Colombier lib/pdf_draw.ps 205*3ff48bf5SDavid du Colombier Added ICCBased color space specific procedures for csncompdict and 206*3ff48bf5SDavid du Colombier defaultdecodedict. Modified the ICCBased color space procedure in 207*3ff48bf5SDavid du Colombier csrdict to map a PDF-form color space to the PostScript form. 208*3ff48bf5SDavid du Colombier 209*3ff48bf5SDavid du Colombier lib/pdf__ops.ps 210*3ff48bf5SDavid du Colombier Added ICCBased color space specific procedure to CSdict and Cdict. 211*3ff48bf5SDavid du Colombier 212*3ff48bf5SDavid du ColombierAdditional notes by Jan Stoeckenius: 213*3ff48bf5SDavid du Colombier 214*3ff48bf5SDavid du Colombier1. The color produced when ICCBased color spaces are employed is 215*3ff48bf5SDavid du Colombier dependent on the installed color rendering dictionary. For the 216*3ff48bf5SDavid du Colombier default X11 device, this dictionary does not provide correction 217*3ff48bf5SDavid du Colombier for the relative white point (at least, not as far as we can tell). 218*3ff48bf5SDavid du Colombier ICC profiles use the D50 white point. In the absence of white point 219*3ff48bf5SDavid du Colombier adjustment, "white" in the associated color space appears to be 220*3ff48bf5SDavid du Colombier a moderate yellow on the output device (other colors are similarly 221*3ff48bf5SDavid du Colombier "red-shifted"). 222*3ff48bf5SDavid du Colombier 223*3ff48bf5SDavid du Colombier This arrangement has the advantage of making it obvious when ICCBased 224*3ff48bf5SDavid du Colombier color spaces are supported (useful for testing). On the other hand, 225*3ff48bf5SDavid du Colombier the output is probably not what the user intended. 226*3ff48bf5SDavid du Colombier 227*3ff48bf5SDavid du Colombier If you have any devices with known "good" color rendering dictionaries, 228*3ff48bf5SDavid du Colombier it would be useful to test ICCBased color space support on those 229*3ff48bf5SDavid du Colombier devices as soon as possible. 230*3ff48bf5SDavid du Colombier 231*3ff48bf5SDavid du Colombier2. The tests we have run do not exercise the memory handling facilities 232*3ff48bf5SDavid du Colombier in ghostscript to any extent. The support for ICCBased color spaces 233*3ff48bf5SDavid du Colombier involves two new structures, for which we have provided structure 234*3ff48bf5SDavid du Colombier descriptors. We believe these have been correctly constructed, and 235*3ff48bf5SDavid du Colombier that the one reference-counted structure is being handled properly, 236*3ff48bf5SDavid du Colombier but we have no simple way of testing for this. 237*3ff48bf5SDavid du Colombier 238*3ff48bf5SDavid du Colombier3. Changes were required in an unexpectedly large number of files 239*3ff48bf5SDavid du Colombier (9 new files, 34 existing files [these figures refer to the 240*3ff48bf5SDavid du Colombier integration into 7.00 - RLL]), though in many cases only a few 241*3ff48bf5SDavid du Colombier lines needed to be modified. 242*3ff48bf5SDavid du Colombier 243*3ff48bf5SDavid du Colombier The primary reason for this is that the graphic library color space 244*3ff48bf5SDavid du Colombier code severely violates the principles of object-oriented programming. 245*3ff48bf5SDavid du Colombier Color space objects have a visible type indicator, and this type is 246*3ff48bf5SDavid du Colombier directly used in many places. When adding a new color space type, it 247*3ff48bf5SDavid du Colombier was not sufficient to create the associated methods. We also had to 248*3ff48bf5SDavid du Colombier search the code for all places in which a color space type indicator 249*3ff48bf5SDavid du Colombier was explicitly accessed. 250*3ff48bf5SDavid du Colombier 251*3ff48bf5SDavid du Colombier We believe we have found all the places where this occurs, and have 252*3ff48bf5SDavid du Colombier modified them appropriately (see the ReleaseNotes file for details). 253*3ff48bf5SDavid du Colombier On the other hand, we have not come remotely close to testing all of 254*3ff48bf5SDavid du Colombier these changes, nor is there any easy test to see if there are places 255*3ff48bf5SDavid du Colombier we missed. 256*3ff48bf5SDavid du Colombier 257*3ff48bf5SDavid du Colombier When Peter was the only person working on the graphic library, 258*3ff48bf5SDavid du Colombier this situation was bothersome but probably not critical. In the 259*3ff48bf5SDavid du Colombier new environment in which ghostscript is being developed, we believe 260*3ff48bf5SDavid du Colombier this situation will lead to serious problems. We recommend that a 261*3ff48bf5SDavid du Colombier project be started to make the color space code much more object- 262*3ff48bf5SDavid du Colombier oriented, by creating color space methods for all of the required 263*3ff48bf5SDavid du Colombier color space properties. 264*3ff48bf5SDavid du Colombier 265*3ff48bf5SDavid du Colombier4. The current method of "inline" storage of alternative/base color spaces 266*3ff48bf5SDavid du Colombier is becoming hard to maintain. Strictly speaking, ICCBased color spaces 267*3ff48bf5SDavid du Colombier cannot be implemented within this mechanism: the color spaces may be 268*3ff48bf5SDavid du Colombier (and are) used as alternative color spaces for Separation and DeviceN 269*3ff48bf5SDavid du Colombier color spaces, and may in turn access such color spaces as their own 270*3ff48bf5SDavid du Colombier alternative color space. We hacked around this problem by disallowing 271*3ff48bf5SDavid du Colombier the latter possibility, and introducing yet another layer in the 272*3ff48bf5SDavid du Colombier color space hierarchy. The class gs_base_color_space is now split 273*3ff48bf5SDavid du Colombier into gs_small_base_color_space (all of the previous base color spaces) 274*3ff48bf5SDavid du Colombier and gs_base_color_space (gs_small_base_color_space and ICCBased color 275*3ff48bf5SDavid du Colombier spaces). This is an unholy mess, but at least it seems to be functional. 276*3ff48bf5SDavid du Colombier 277*3ff48bf5SDavid du Colombier As the number of layers in the color space hierarchy grows, so does the 278*3ff48bf5SDavid du Colombier potential for serious and well-hidden problems. The reason is that 279*3ff48bf5SDavid du Colombier pointers to alternative/base color spaces may point into the middle of 280*3ff48bf5SDavid du Colombier an object. If such a pointer is accessible via the heap, and is subject 281*3ff48bf5SDavid du Colombier to relocation, the location of the structure descriptor will be read 282*3ff48bf5SDavid du Colombier incorrectly. By the time this error is apparent, much of the affected 283*3ff48bf5SDavid du Colombier memory may be overwritten. Tracing such problems is typically quite 284*3ff48bf5SDavid du Colombier time-consuming. 285*3ff48bf5SDavid du Colombier 286*3ff48bf5SDavid du Colombier The original guard against this problem was to perform all color space 287*3ff48bf5SDavid du Colombier assignments by value. This worked when Peter was the only person regularly 288*3ff48bf5SDavid du Colombier changing the code, and may continue to work under the current arrangement. 289*3ff48bf5SDavid du Colombier We believe, however, that this situation will cause trouble in the 290*3ff48bf5SDavid du Colombier future. 291*3ff48bf5SDavid du Colombier 292*3ff48bf5SDavid du Colombier We recommend that the current color space mechanism be discarded. A new 293*3ff48bf5SDavid du Colombier mechanism should allow alternative/base color spaces to be included by 294*3ff48bf5SDavid du Colombier reference rather than by value. Such a mechanism should also move the 295*3ff48bf5SDavid du Colombier generic color space parameters (number of components, additive/subtractive 296*3ff48bf5SDavid du Colombier indicator, etc.) into the base structure, even if these parameters are 297*3ff48bf5SDavid du Colombier fixed for certain color spaces. 298*3ff48bf5SDavid du Colombier 299*3ff48bf5SDavid du Colombier5. The PDF device code currently attempts to translate PostScript's 300*3ff48bf5SDavid du Colombier CIEBased color spaces into the more restrictive set of CIE color spaces 301*3ff48bf5SDavid du Colombier in PDF. Many color spaces cannot be translated directly, and the code 302*3ff48bf5SDavid du Colombier will fail if such a color space is encountered. 303*3ff48bf5SDavid du Colombier 304*3ff48bf5SDavid du Colombier We have generalized this code to handle ICCBased color spaces, which 305*3ff48bf5SDavid du Colombier effectively are translated to themselves. A much more complete solution 306*3ff48bf5SDavid du Colombier could be provided by mapping PostScript's CIEBased color spaces into 307*3ff48bf5SDavid du Colombier ICCBased color spaces in PDF. Essentially all CIEBased color spaces 308*3ff48bf5SDavid du Colombier could be handled in this manner (via sample and generation of a lookup 309*3ff48bf5SDavid du Colombier table). 310*3ff48bf5SDavid du Colombier 311