File indexing completed on 2025-05-04 04:07:18

0001 /* License:
0002  * 
0003  * Code for making well-behaved ICC profiles
0004  * SPDX-FileCopyrightText: 2013, 2014, 2015 Elle Stone
0005  * 
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  * 
0008  * Contact information:
0009  * ellestone@ninedegreesbelow.com
0010  * https://ninedegreesbelow.com
0011  * 
0012  * */
0013 
0014 /* About the ICC profile header "Platform" tag:
0015  * 
0016  * When creating a profile, LCMS checks to see if the platform is 
0017  * Windows ('MSFT'). If your platform isn't Windows, LCMS defaults 
0018  * to using the Apple ('APPL') platform tag for the profile header.
0019  * 
0020  * There is an unofficial Platform 
0021  * cmsPlatformSignature cmsSigUnices 0x2A6E6978 '*nix'. There is, 
0022  * however, no LCMS2 API for changing the platform when making a profile.
0023  * 
0024  * So on my own computer, to replace 'APPL' with '*nix' in the header, 
0025  * I modified the LCMS source file 'cmsio0.c' and recompiled LCMS:
0026  * #ifdef CMS_IS_WINDOWS_
0027  * Header.platform= (cmsPlatformSignature) _cmsAdjustEndianess32(cmsSigMicrosoft);
0028  * #else
0029  * Header.platform= (cmsPlatformSignature) _cmsAdjustEndianess32(cmsSigUnices);
0030  * #endif
0031  * 
0032  * */
0033 
0034 /* Sample command line to compile this code:
0035  * 
0036  * gcc -g -O0 -Wall -o make-elles-profiles make-elles-profiles.c -llcms2
0037  * 
0038  * You'll see a lot of harmless warnings about unused variables. 
0039  * That's because I included variables for profiles that the code 
0040  * doesn't actually make, in case you might want to make 
0041  * these profiles for your own use.
0042  * 
0043  * */
0044  
0045 #include <lcms2.h>
0046 int main ()
0047 {
0048 /* prints D50 XYZ values from lcms2.h, 
0049  * mostly to let you know the code did something! 
0050  * */
0051 printf("D50X, D50Y, D50Z = %1.8f %1.8f %1.8f\n", cmsD50X, cmsD50Y, cmsD50Z);
0052 
0053 
0054 /* ************************** TONE CURVES *************************** */
0055 
0056 /* sRGB, Rec709, and labl Tone Reproduction Curves ("TRCs") */
0057 /* About these TRCs: 
0058  * This code makes V2 and V4 ICC profiles.
0059  * For the V4 profiles, which are made using parametric curves, 
0060  * these TRCs can work in unbounded mode.
0061  * For the V2 profiles, the resulting TRC is a 4096-point curve and 
0062  * cannot work in unbounded mode. 
0063  * See https://ninedegreesbelow.com/photography/lcms2-unbounded-mode.html
0064  * for an explanation of unbounded mode ICC profile conversions. 
0065  * 
0066  * Also, during ICC profile conversions,
0067  * LCMS quantizes images with ICC profiles that have point TRCs. 
0068  * So use the V4 profile variants for editing images with software 
0069  * that uses LCMS2 as the Color Management System.
0070  * */
0071  
0072 /* sRGB TRC */
0073 cmsFloat64Number srgb_parameters[5] = 
0074    { 2.4, 1.0 / 1.055,  0.055 / 1.055, 1.0 / 12.92, 0.04045 }; 
0075 cmsToneCurve *srgb_parametic_curve =
0076    cmsBuildParametricToneCurve(NULL, 4, srgb_parameters);
0077 cmsToneCurve *srgb_parametric[3] = 
0078    {srgb_parametic_curve,srgb_parametic_curve,srgb_parametic_curve};
0079 
0080 /* LAB "L" (perceptually uniform) TRC */
0081 cmsFloat64Number labl_parameters[5] = 
0082    { 3.0, 0.862076,  0.137924, 0.110703, 0.080002 }; 
0083 cmsToneCurve *labl_parametic_curve =
0084    cmsBuildParametricToneCurve(NULL, 4, labl_parameters);
0085 cmsToneCurve *labl_parametric[3] = 
0086    {labl_parametic_curve,labl_parametic_curve,labl_parametic_curve};
0087 
0088 /* Rec 709 TRC */
0089 cmsFloat64Number rec709_parameters[5] = 
0090    { 1.0 / 0.45, 1.0 / 1.099,  0.099 / 1.099,  1.0 / 4.5, 0.018 }; 
0091 cmsToneCurve *rec709_parametic_curve =
0092    cmsBuildParametricToneCurve(NULL, 4, rec709_parameters);
0093 cmsToneCurve *rec709_parametric[3] = 
0094    {rec709_parametic_curve,rec709_parametic_curve,rec709_parametic_curve};
0095    
0096 /* The following true gamma TRCs work in unbounded mode
0097  * for both V2 and V4 profiles, and quantization during ICC profile
0098  * conversions is not an issue with either the V2 or V4 variants: */
0099    
0100 /* gamma=1.00, linear gamma, "linear light", etc tone response curve */
0101 cmsToneCurve* gamma100[3];
0102 gamma100[0] = gamma100[1] = gamma100[2] = cmsBuildGamma (NULL, 1.00); 
0103 
0104 cmsToneCurve* gamma200[3];
0105 gamma200[0] = gamma200[1] = gamma200[2] = cmsBuildGamma (NULL, 2.00);
0106 
0107 /* Because of hexadecimal rounding during the profile making process, 
0108  * the following two gamma values for the profile's TRC are not precisely 
0109  * preserved when a V2 profile is made. So I used the V2 value for 
0110  * both V2 and V4 versions of the profiles that use these TRCs.
0111  * Otherwise V2 and V4 versions of nominally gamma=1.80 and gamma=2.20 
0112  * profiles would have slightly different gamma curves.
0113  * */
0114 
0115 /* gamma=1.80078125 tone response curve */
0116 /* http://www.color.org/chardata/rgb/ROMMRGB.pdf indicates that 
0117  * the official tone response curve for ROMM isn't a simple gamma curve 
0118  * but rather has a linear portion in shadows, just like sRGB.
0119  * Most ProPhotoRGB profiles use a gamma curve equal to 1.80078125. 
0120  * This odd value is because of hexadecimal rounding.
0121  * */ 
0122 cmsToneCurve* gamma180[3];
0123 gamma180[0] = gamma180[1] = gamma180[2] = cmsBuildGamma (NULL, 1.80078125); 
0124 
0125 /* gamma=2.19921875 tone response curve */
0126 /* per https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf;
0127  * ClayRGB uses this value. Based on an old proprietary profile, 
0128  * it also appears to be the correct gamma for WideGamutRGB.
0129  * It also is what you get when you 
0130  * try to create a V2 profile with a gamma=2.20 gamma curve. 
0131  * So perhaps the AdobeRGB1998 specifications 
0132  * were simply bowing to the inevitable hexadecimal rounding. 
0133  * Almost all (all?) V2 ICC profiles with nominally gamma=2.20 
0134  * really have a gamma of 2.19921875, not 2.20.
0135  * */
0136  
0137 cmsToneCurve* gamma220[3];
0138 gamma220[0] = gamma220[1] = gamma220[2] = cmsBuildGamma (NULL, 2.19921875);
0139 
0140 /* ************************** WHITE POINTS ************************** */
0141 
0142 /* D50 WHITE POINTS */
0143 
0144 cmsCIExyY d50_romm_spec= {0.3457, 0.3585, 1.0};
0145 /* https://photo-lovers.org/pdf/color/romm.pdf */
0146 
0147 cmsCIExyY d50_illuminant_specs = {0.345702915, 0.358538597, 1.0};
0148 /* calculated from D50 illuminant XYZ values in ICC specs */
0149 
0150 
0151 /* D65 WHITE POINTS */
0152 
0153 cmsCIExyY  d65_srgb_adobe_specs = {0.3127, 0.3290, 1.0};
0154 /* White point from the sRGB.icm and AdobeRGB1998 profile specs:
0155  * https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf 
0156  * 4.2.1 Reference Display White Point
0157  * The chromaticity coordinates of white displayed on 
0158  * the reference color monitor shall be x=0.3127, y=0.3290. 
0159  * . . . [which] correspond to CIE Standard Illuminant D65.
0160  * 
0161  * Wikipedia gives this same white point for SMPTE-C.
0162  * This white point is also given in the sRGB color space specs.
0163  * It's probably correct for most or all of the standard D65 profiles.
0164  * 
0165  * The D65 white point values used in the LCMS virtual sRGB profile
0166  * is slightly different than the D65 white point values given in the 
0167  * sRGB color space specs, so the LCMS virtual sRGB profile
0168  * doesn't match sRGB profiles made using the values given in the 
0169  * sRGB color space specs.
0170  * 
0171  * */
0172  
0173  
0174 /* Various C and E WHITE POINTS */
0175 
0176 cmsCIExyY c_astm  = {0.310060511, 0.316149551, 1.0}; 
0177 /* see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html */
0178 cmsCIExyY e_astm  = {0.333333333, 0.333333333, 1.0};
0179 /* see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html */
0180 
0181 cmsCIExyY c_cie= {0.310, 0.316};
0182 /* https://en.wikipedia.org/wiki/NTSC#Colorimetry */
0183 cmsCIExyY e_cie= {0.333, 0.333};
0184 
0185 cmsCIExyY c_6774_robertson= {0.308548930, 0.324928102, 1.0}; 
0186 /* see https://en.wikipedia.org/wiki/Standard_illuminant#White_points_of_standard_illuminants
0187  * also see  http://www.brucelindbloom.com/index.html?Eqn_T_to_xy.html for the equations */
0188 cmsCIExyY e_5454_robertson= {0.333608970, 0.348572909, 1.0}; 
0189 /* see https://en.wikipedia.org/wiki/Standard_illuminant#White_points_of_standard_illuminants
0190  * also see http://www.brucelindbloom.com/index.html?Eqn_T_to_xy.html for the equations */
0191  
0192  
0193 /* ACES white point, taken from
0194  * Specification S-2014-004
0195  * ACEScg – A Working Space for CGI Render and Compositing
0196  */
0197 cmsCIExyY d60_aces= {0.32168, 0.33767, 1.0};
0198 
0199 /* *****************Set up profile variables and values *************** */
0200 cmsHPROFILE profile;
0201 cmsToneCurve* tone_curve[3];
0202 cmsCIExyY whitepoint;
0203 cmsCIExyYTRIPLE primaries;
0204 const char* filename;
0205 cmsMLU *copyright = cmsMLUalloc(NULL, 1);
0206 
0207 /* I put a Creative Commons Attribution-ShareAlike 3.0 Unported License
0208  * on the profiles that I distribute (see
0209  * https://creativecommons.org/licenses/by-sa/3.0/legalcode)
0210  * The CC V3 Attribution-ShareAlike unported licence is accepted by both
0211  * Debian and Fedora as a free licence.
0212  * 
0213  * Note that the CC V3 BY-SA licence that I put on the ICC profiles 
0214  * is not the same licence that's applied to my profile-making code, 
0215  * which is LGPL2.1+.
0216  * 
0217  * Of course you can modify my profile-making code to put some other 
0218  * *profile* copyright on the actual profiles that the code makes, 
0219  * for example public domain (Creative Commons CC0) 
0220  * or one of the GPL copyrights.
0221  * 
0222  * The ICC suggested wording for profile copyrights is here 
0223  * (see the last section, entitled "Licensing"): 
0224  * http://www.color.org/registry/profileregistration.xalter
0225  * 
0226  * The ICC copyright sounds like it's probably a free licence,
0227  * but as of June 2015 it hasn't been accepted by Fedora or Debian as a 
0228  * free license. 
0229  * 
0230  * Here are the Fedora and Debian lists of free licences:
0231  * 
0232  * https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Content_Licenses
0233  * https://wiki.debian.org/DFSGLicenses
0234  * 
0235  * */
0236 
0237 cmsMLUsetASCII(copyright, "en", "US", "Copyright 2015, Elle Stone (website: http://ninedegreesbelow.com/; email: ellestone@ninedegreesbelow.com). This ICC profile is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License (https://creativecommons.org/licenses/by-sa/3.0/legalcode).");
0238 
0239 cmsMLU *manufacturer = cmsMLUalloc(NULL, 1);
0240 
0241 cmsMLU *description;
0242 
0243 /* ********************** MAKE THE PROFILES ************************* */
0244 
0245 /* ACES PROFILES */
0246 
0247 /* ***** Make profile: ACEScg, D60, gamma=1.00 */
0248 /* ACEScg chromaticities taken from
0249  * Specification S-2014-004
0250  * ACEScg – A Working Space for CGI Render and Compositing
0251  */
0252 cmsCIExyYTRIPLE aces_cg_primaries = 
0253 {
0254 {0.713, 0.293,  1.0},
0255 {0.165, 0.830,  1.0},
0256 {0.128, 0.044,  1.0}
0257 };
0258 
0259 whitepoint = d60_aces;
0260 primaries = aces_cg_primaries;
0261 
0262 /* linear gamma */
0263 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
0264 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0265 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0266 /* V4 */
0267 description = cmsMLUalloc(NULL, 1);
0268 cmsMLUsetASCII(description, "en", "US", "ACEScg-elle-V4-g10.icc");
0269 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0270                              filename = "ACEScg-elle-V4-g10.icc";
0271 cmsSaveProfileToFile(profile, filename);
0272 cmsMLUfree(description);
0273 /* V2 */
0274 cmsSetProfileVersion(profile, 2.1);
0275 description = cmsMLUalloc(NULL, 1);
0276 cmsMLUsetASCII(description, "en", "US", "ACEScg-elle-V2-g10.icc");
0277 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0278                              filename = "ACEScg-elle-V2-g10.icc";
0279 cmsSaveProfileToFile(profile, filename);
0280 cmsMLUfree(description);
0281 
0282 /* gamma=2.2 */
0283 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
0284 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0285 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0286 /* V4 */
0287 description = cmsMLUalloc(NULL, 1);
0288 cmsMLUsetASCII(description, "en", "US", "ACEScg-elle-V4-g22.icc");
0289 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0290                              filename = "ACEScg-elle-V4-g22.icc";
0291 cmsSaveProfileToFile(profile, filename);
0292 cmsMLUfree(description);
0293 /* V2 */
0294 cmsSetProfileVersion(profile, 2.1);
0295 description = cmsMLUalloc(NULL, 1);
0296 cmsMLUsetASCII(description, "en", "US", "ACEScg-elle-V2-g22.icc");
0297 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0298                              filename = "ACEScg-elle-V2-g22.icc";
0299 cmsSaveProfileToFile(profile, filename);
0300 cmsMLUfree(description);
0301 
0302 /* sRGB TRC */
0303 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
0304 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0305 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0306 /* V4 */
0307 description = cmsMLUalloc(NULL, 1);
0308 cmsMLUsetASCII(description, "en", "US", "ACEScg-elle-V4-srgbtrc.icc");
0309 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0310                              filename = "ACEScg-elle-V4-srgbtrc.icc";
0311 cmsSaveProfileToFile(profile, filename);
0312 cmsMLUfree(description);
0313 /* V2 */
0314 cmsSetProfileVersion(profile, 2.1);
0315 description = cmsMLUalloc(NULL, 1);
0316 cmsMLUsetASCII(description, "en", "US", "ACEScg-elle-V2-srgbtrc.icc");
0317 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0318                              filename = "ACEScg-elle-V2-srgbtrc.icc";
0319 cmsSaveProfileToFile(profile, filename);
0320 cmsMLUfree(description);
0321 
0322 /* labl TRC */
0323 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
0324 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0325 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0326 /* V4 */
0327 description = cmsMLUalloc(NULL, 1);
0328 cmsMLUsetASCII(description, "en", "US", "ACEScg-elle-V4-labl.icc");
0329 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0330                              filename = "ACEScg-elle-V4-labl.icc";
0331 cmsSaveProfileToFile(profile, filename);
0332 cmsMLUfree(description);
0333 /* V2 */
0334 cmsSetProfileVersion(profile, 2.1);
0335 description = cmsMLUalloc(NULL, 1);
0336 cmsMLUsetASCII(description, "en", "US", "ACEScg-elle-V2-labl.icc");
0337 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0338                              filename = "ACEScg-elle-V2-labl.icc";
0339 cmsSaveProfileToFile(profile, filename);
0340 cmsMLUfree(description);
0341 
0342 
0343 
0344 /* ***** Make profile: ACES, D60, gamma=1.00 */
0345 /* ACES chromaticities taken from
0346  * Specification
0347  * */
0348 cmsCIExyYTRIPLE aces_primaries = 
0349 {
0350 {0.73470,  0.26530,  1.0},
0351 {0.00000,  1.00000,  1.0},
0352 {0.00010, -0.07700,  1.0}
0353 };
0354 cmsCIExyYTRIPLE aces_primaries_prequantized = 
0355 {
0356 {0.734704192222, 0.265298276252,  1.0},
0357 {-0.000004945077, 0.999992850272,  1.0},
0358 {0.000099889199, -0.077007518685,  1.0}
0359 };
0360 
0361 whitepoint = d60_aces;
0362 primaries = aces_primaries_prequantized;
0363 
0364 /* linear gamma */
0365 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
0366 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0367 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0368 /* V4 */
0369 description = cmsMLUalloc(NULL, 1);
0370 cmsMLUsetASCII(description, "en", "US", "ACES-elle-V4-g10.icc");
0371 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0372                              filename = "ACES-elle-V4-g10.icc";
0373 cmsSaveProfileToFile(profile, filename);
0374 cmsMLUfree(description);
0375 /* V2 */
0376 cmsSetProfileVersion(profile, 2.1);
0377 description = cmsMLUalloc(NULL, 1);
0378 cmsMLUsetASCII(description, "en", "US", "ACES-elle-V2-g10.icc");
0379 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0380                              filename = "ACES-elle-V2-g10.icc";
0381 cmsSaveProfileToFile(profile, filename);
0382 cmsMLUfree(description);
0383 
0384 /* gamma=2.2 */
0385 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
0386 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0387 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0388 /* V4 */
0389 description = cmsMLUalloc(NULL, 1);
0390 cmsMLUsetASCII(description, "en", "US", "ACES-elle-V4-g122.icc");
0391 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0392                              filename = "ACES-elle-V4-g22.icc";
0393 cmsSaveProfileToFile(profile, filename);
0394 cmsMLUfree(description);
0395 /* V2 */
0396 cmsSetProfileVersion(profile, 2.1);
0397 description = cmsMLUalloc(NULL, 1);
0398 cmsMLUsetASCII(description, "en", "US", "ACES-elle-V2-g22.icc");
0399 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0400                              filename = "ACES-elle-V2-g22.icc";
0401 cmsSaveProfileToFile(profile, filename);
0402 cmsMLUfree(description);
0403 
0404 /* sRGB TRC */
0405 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
0406 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0407 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0408 /* V4 */
0409 description = cmsMLUalloc(NULL, 1);
0410 cmsMLUsetASCII(description, "en", "US", "ACES-elle-V4-srgbtrc.icc");
0411 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0412                              filename = "ACES-elle-V4-srgbtrc.icc";
0413 cmsSaveProfileToFile(profile, filename);
0414 cmsMLUfree(description);
0415 /* V2 */
0416 cmsSetProfileVersion(profile, 2.1);
0417 description = cmsMLUalloc(NULL, 1);
0418 cmsMLUsetASCII(description, "en", "US", "ACES-elle-V2-srgbtrc.icc");
0419 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0420                              filename = "ACES-elle-V2-srgbtrc.icc";
0421 cmsSaveProfileToFile(profile, filename);
0422 cmsMLUfree(description);
0423 
0424 /* labl TRC */
0425 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
0426 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0427 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0428 /* V4 */
0429 description = cmsMLUalloc(NULL, 1);
0430 cmsMLUsetASCII(description, "en", "US", "ACES-elle-V4-labl.icc");
0431 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0432                              filename = "ACES-elle-V4-labl.icc";
0433 cmsSaveProfileToFile(profile, filename);
0434 cmsMLUfree(description);
0435 /* V2 */
0436 cmsSetProfileVersion(profile, 2.1);
0437 description = cmsMLUalloc(NULL, 1);
0438 cmsMLUsetASCII(description, "en", "US", "ACES-elle-V2-labl.icc");
0439 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0440                              filename = "ACES-elle-V2-labl.icc";
0441 cmsSaveProfileToFile(profile, filename);
0442 cmsMLUfree(description);
0443 
0444 
0445 
0446 
0447 /* D50 PROFILES */
0448 
0449 /* ***** Make profile: AllColorsRGB, D50, gamma=1.00 */
0450 /* AllColors.icc has a slightly larger color gamut than the ACES color space.
0451  * It has a D50 white point and a linear gamma TRC. 
0452  * It holds all visible colors.
0453  * Just like the ACES color space, 
0454  * AllColors also holds a high percentage of imaginary colors.
0455  * See https://ninedegreesbelow.com/photography/xyz-rgb.html#xyY 
0456  * for more information about imaginary colors.
0457  * AllColors primaries for red and blue from 
0458  * https://www.ledtuning.nl/en/cie-convertor
0459  * blue 375nm red 780nm, plus Y intercepts:
0460  * Color Wavelength (): 375 nm.
0461  * Spectral Locus coordinates: X:0.17451 Y:0.005182
0462  * Color Wavelength (): 780 nm.
0463  * Spectral Locus coordinates: X:0.734690265 Y:0.265309735
0464  * X1:0.17451 Y1:0.005182
0465  * X2:0.734690265 Y2:0.265309735
0466  * X3:0.00Y3:? Solve for Y3:
0467  * (0.265309735-0.005182)/(0.734690265-0.17451)=0.46436433279205221554=m
0468  * y=mx+b let x=0; y=b
0469  * Y1=0.005182=(0.46436433279205221554*0.17451)+b
0470  * b=0.005182-(0.46436433279205221554*0.17451)=-.07585421971554103213
0471  *  */
0472 cmsCIExyYTRIPLE allcolors_primaries = 
0473 {
0474 {0.734690265,  0.265309735,  1.0},
0475 {0.000000000,  1.000000000,  1.0},
0476 {0.000000000, -.0758542197,  1.0}
0477 }; 
0478 whitepoint = d50_illuminant_specs;
0479 primaries = allcolors_primaries;
0480 
0481 /* linear gamma */
0482 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
0483 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0484 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0485 /* V4 */
0486 description = cmsMLUalloc(NULL, 1);
0487 cmsMLUsetASCII(description, "en", "US", "AllColorsRGB-elle-V4-g10.icc");
0488 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0489                              filename = "AllColorsRGB-elle-V4-g10.icc";
0490 cmsSaveProfileToFile(profile, filename);
0491 cmsMLUfree(description);
0492 /* V2 */
0493 cmsSetProfileVersion(profile, 2.1);
0494 description = cmsMLUalloc(NULL, 1);
0495 cmsMLUsetASCII(description, "en", "US", "AllColorsRGB-elle-V2-g10.icc");
0496 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0497                              filename = "AllColorsRGB-elle-V2-g10.icc";
0498 cmsSaveProfileToFile(profile, filename);
0499 cmsMLUfree(description);
0500 
0501 /* gamma=2.2 */
0502 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
0503 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0504 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0505 /* V4 */
0506 description = cmsMLUalloc(NULL, 1);
0507 cmsMLUsetASCII(description, "en", "US", "AllColorsRGB-elle-V4-g22.icc");
0508 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0509                              filename = "AllColorsRGB-elle-V4-g22.icc";
0510 cmsSaveProfileToFile(profile, filename);
0511 cmsMLUfree(description);
0512 /* V2 */
0513 cmsSetProfileVersion(profile, 2.1);
0514 description = cmsMLUalloc(NULL, 1);
0515 cmsMLUsetASCII(description, "en", "US", "AllColorsRGB-elle-V2-g22.icc");
0516 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0517                              filename = "AllColorsRGB-elle-V2-g22.icc";
0518 cmsSaveProfileToFile(profile, filename);
0519 cmsMLUfree(description);
0520 
0521 /* sRGB TRC */
0522 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
0523 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0524 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0525 /* V4 */
0526 description = cmsMLUalloc(NULL, 1);
0527 cmsMLUsetASCII(description, "en", "US", "AllColorsRGB-elle-V4-srgbtrc.icc");
0528 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0529                              filename = "AllColorsRGB-elle-V4-srgbtrc.icc";
0530 cmsSaveProfileToFile(profile, filename);
0531 cmsMLUfree(description);
0532 /* V2 */
0533 cmsSetProfileVersion(profile, 2.1);
0534 description = cmsMLUalloc(NULL, 1);
0535 cmsMLUsetASCII(description, "en", "US", "AllColorsRGB-elle-V2-srgbtrc.icc");
0536 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0537                              filename = "AllColorsRGB-elle-V2-srgbtrc.icc";
0538 cmsSaveProfileToFile(profile, filename);
0539 cmsMLUfree(description);
0540 
0541 /* labl TRC */
0542 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
0543 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0544 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0545 /* V4 */
0546 description = cmsMLUalloc(NULL, 1);
0547 cmsMLUsetASCII(description, "en", "US", "AllColorsRGB-elle-V4-labl.icc");
0548 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0549                              filename = "AllColorsRGB-elle-V4-labl.icc";
0550 cmsSaveProfileToFile(profile, filename);
0551 cmsMLUfree(description);
0552 /* V2 */
0553 cmsSetProfileVersion(profile, 2.1);
0554 description = cmsMLUalloc(NULL, 1);
0555 cmsMLUsetASCII(description, "en", "US", "AllColorsRGB-elle-V2-labl.icc");
0556 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0557                              filename = "AllColorsRGB-elle-V2-labl.icc";
0558 cmsSaveProfileToFile(profile, filename);
0559 cmsMLUfree(description);
0560 
0561 
0562 /* ***** Make profile: Identity, D50, gamma=1.00. */
0563 /* These primaries also hold all possible visible colors, 
0564  * but less efficiently than the AllColors profile.*/
0565 cmsCIExyYTRIPLE identity_primaries = {/*  */
0566 {1.0, 0.0, 1.0},
0567 {0.0, 1.0, 1.0},
0568 {0.0, 0.0, 1.0}
0569 };
0570 whitepoint = d50_illuminant_specs;
0571 primaries = identity_primaries;
0572 
0573 /* linear gamma */
0574 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
0575 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0576 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0577 /* V4 */
0578 description = cmsMLUalloc(NULL, 1);
0579 cmsMLUsetASCII(description, "en", "US", "IdentityRGB-elle-V4-g10.icc");
0580 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0581                              filename = "IdentityRGB-elle-V4-g10.icc";
0582 cmsSaveProfileToFile(profile, filename);
0583 cmsMLUfree(description);
0584 /* V2 */
0585 cmsSetProfileVersion(profile, 2.1);
0586 description = cmsMLUalloc(NULL, 1);
0587 cmsMLUsetASCII(description, "en", "US", "IdentityRGB-elle-V2-g10.icc");
0588 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0589                              filename = "IdentityRGB-elle-V2-g10.icc";
0590 cmsSaveProfileToFile(profile, filename);
0591 cmsMLUfree(description);
0592 
0593 /* gamma=2.2 */
0594 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
0595 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0596 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0597 /* V4 */
0598 description = cmsMLUalloc(NULL, 1);
0599 cmsMLUsetASCII(description, "en", "US", "IdentityRGB-elle-V4-g22.icc");
0600 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0601                              filename = "IdentityRGB-elle-V4-g22.icc";
0602 cmsSaveProfileToFile(profile, filename);
0603 cmsMLUfree(description);
0604 /* V2 */
0605 cmsSetProfileVersion(profile, 2.1);
0606 description = cmsMLUalloc(NULL, 1);
0607 cmsMLUsetASCII(description, "en", "US", "IdentityRGB-elle-V2-g22.icc");
0608 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0609                              filename = "IdentityRGB-elle-V2-g22.icc";
0610 cmsSaveProfileToFile(profile, filename);
0611 cmsMLUfree(description);
0612 
0613 /* sRGB TRC */
0614 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
0615 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0616 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0617 /* V4 */
0618 description = cmsMLUalloc(NULL, 1);
0619 cmsMLUsetASCII(description, "en", "US", "IdentityRGB-elle-V4-srgbtrc.icc");
0620 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0621                              filename = "IdentityRGB-elle-V4-srgbtrc.icc";
0622 cmsSaveProfileToFile(profile, filename);
0623 cmsMLUfree(description);
0624 /* V2 */
0625 cmsSetProfileVersion(profile, 2.1);
0626 description = cmsMLUalloc(NULL, 1);
0627 cmsMLUsetASCII(description, "en", "US", "IdentityRGB-elle-V2-srgbtrc.icc");
0628 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0629                              filename = "IdentityRGB-elle-V2-srgbtrc.icc";
0630 cmsSaveProfileToFile(profile, filename);
0631 cmsMLUfree(description);
0632 
0633 /* labl TRC */
0634 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
0635 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0636 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0637 /* V4 */
0638 description = cmsMLUalloc(NULL, 1);
0639 cmsMLUsetASCII(description, "en", "US", "IdentityRGB-elle-V4-labl.icc");
0640 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0641                              filename = "IdentityRGB-elle-V4-labl.icc";
0642 cmsSaveProfileToFile(profile, filename);
0643 cmsMLUfree(description);
0644 /* V2 */
0645 cmsSetProfileVersion(profile, 2.1);
0646 description = cmsMLUalloc(NULL, 1);
0647 cmsMLUsetASCII(description, "en", "US", "IdentityRGB-elle-V2-labl.icc");
0648 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0649                              filename = "IdentityRGB-elle-V2-labl.icc";
0650 cmsSaveProfileToFile(profile, filename);
0651 cmsMLUfree(description);
0652 
0653 
0654 /* ***** Make profile: Romm/Prophoto, D50, gamma=1.80 */
0655 /* Reference Input/Output Medium Metric RGB Color Encodings (RIMM/ROMM RGB)
0656  * Kevin E. Spaulding, Geoffrey J. Woolfe and Edward J. Giorgianni
0657  * Eastman Kodak Company, Rochester, New York, U.S.A.
0658  * Above document is available at https://photo-lovers.org/pdf/color/romm.pdf
0659  * Kodak designed the Romm (ProPhoto) color gamut to include all printable 
0660  * and most real world colors. It includes some imaginary colors and excludes 
0661  * some of the real world blues and violet blues that can be captured by 
0662  * digital cameras. For high bit depth image editing only.
0663  */
0664 cmsCIExyYTRIPLE romm_primaries = {
0665 {0.7347, 0.2653, 1.0},
0666 {0.1596, 0.8404, 1.0},
0667 {0.0366, 0.0001, 1.0}
0668 };
0669 primaries = romm_primaries;
0670 whitepoint = d50_romm_spec;
0671 /* gamma 1.80 */
0672 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma180[0];
0673 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0674 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0675 /* V4 */
0676 description = cmsMLUalloc(NULL, 1);
0677 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V4-g18.icc");
0678 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0679                              filename = "LargeRGB-elle-V4-g18.icc";
0680 cmsSaveProfileToFile(profile, filename);
0681 cmsMLUfree(description);
0682 /* V2 */
0683 cmsSetProfileVersion(profile, 2.1);
0684 description = cmsMLUalloc(NULL, 1);
0685 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V2-g18.icc");
0686 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0687                              filename = "LargeRGB-elle-V2-g18.icc";
0688 cmsSaveProfileToFile(profile, filename);
0689 cmsMLUfree(description);
0690 
0691 /* linear gamma */
0692 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
0693 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0694 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0695 /* V4 */
0696 description = cmsMLUalloc(NULL, 1);
0697 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V4-g10.icc");
0698 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0699                              filename = "LargeRGB-elle-V4-g10.icc";
0700 cmsSaveProfileToFile(profile, filename);
0701 cmsMLUfree(description);
0702 /* V2 */
0703 cmsSetProfileVersion(profile, 2.1);
0704 description = cmsMLUalloc(NULL, 1);
0705 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V2-g10.icc");
0706 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0707                              filename = "LargeRGB-elle-V2-g10.icc";
0708 cmsSaveProfileToFile(profile, filename);
0709 cmsMLUfree(description);
0710 
0711 /* gamma=2.2 */
0712 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
0713 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0714 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0715 /* V4 */
0716 description = cmsMLUalloc(NULL, 1);
0717 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V4-g22.icc");
0718 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0719                              filename = "LargeRGB-elle-V4-g22.icc";
0720 cmsSaveProfileToFile(profile, filename);
0721 cmsMLUfree(description);
0722 /* V2 */
0723 cmsSetProfileVersion(profile, 2.1);
0724 description = cmsMLUalloc(NULL, 1);
0725 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V2-g22.icc");
0726 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0727                              filename = "LargeRGB-elle-V2-g22.icc";
0728 cmsSaveProfileToFile(profile, filename);
0729 cmsMLUfree(description);
0730 
0731 /* sRGB TRC */
0732 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
0733 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0734 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0735 /* V4 */
0736 description = cmsMLUalloc(NULL, 1);
0737 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V4-srgbtrc.icc");
0738 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0739                              filename = "LargeRGB-elle-V4-srgbtrc.icc";
0740 cmsSaveProfileToFile(profile, filename);
0741 cmsMLUfree(description);
0742 /* V2 */
0743 cmsSetProfileVersion(profile, 2.1);
0744 description = cmsMLUalloc(NULL, 1);
0745 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V2-srgbtrc.icc");
0746 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0747                              filename = "LargeRGB-elle-V2-srgbtrc.icc";
0748 cmsSaveProfileToFile(profile, filename);
0749 cmsMLUfree(description);
0750 
0751 /* labl TRC */
0752 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
0753 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0754 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0755 /* V4 */
0756 description = cmsMLUalloc(NULL, 1);
0757 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V4-labl.icc");
0758 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0759                              filename = "LargeRGB-elle-V4-labl.icc";
0760 cmsSaveProfileToFile(profile, filename);
0761 cmsMLUfree(description);
0762 /* V2 */
0763 cmsSetProfileVersion(profile, 2.1);
0764 description = cmsMLUalloc(NULL, 1);
0765 cmsMLUsetASCII(description, "en", "US", "LargeRGB-elle-V2-labl.icc");
0766 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0767                              filename = "LargeRGB-elle-V2-labl.icc";
0768 cmsSaveProfileToFile(profile, filename);
0769 cmsMLUfree(description);
0770 
0771 
0772 
0773 /* ***** Make profile: WidegamutRGB, D50, gamma=2.19921875 */
0774 /* Pascale's primary values produce a profile that matches 
0775  * old V2 Widegamut profiles from Adobe and Canon.
0776  * Danny Pascale: A review of RGB color spaces
0777  * http://www.babelcolor.com/download/A%20review%20of%20RGB%20color%20spaces.pdf  
0778  * WideGamutRGB was designed by Adobe to be a wide gamut color space that uses
0779  * spectral colors as its primaries. For high bit depth image editing only. */
0780 cmsCIExyYTRIPLE widegamut_pascale_primaries = {
0781 {0.7347, 0.2653, 1.0},
0782 {0.1152, 0.8264, 1.0},
0783 {0.1566, 0.0177, 1.0}
0784 };
0785 primaries = widegamut_pascale_primaries;
0786 whitepoint = d50_romm_spec;
0787 /* gamma 2.20 */
0788 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
0789 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0790 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0791 /* V4 */
0792 description = cmsMLUalloc(NULL, 1);
0793 cmsMLUsetASCII(description, "en", "US", "WideRGB-elle-V4-g22.icc");
0794 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0795                              filename = "WideRGB-elle-V4-g22.icc";
0796 cmsSaveProfileToFile(profile, filename);
0797 cmsMLUfree(description);
0798 /* V2 */
0799 cmsSetProfileVersion(profile, 2.1);
0800 description = cmsMLUalloc(NULL, 1);
0801 cmsMLUsetASCII(description, "en", "US", "WideRGB-elle-V2-g22.icc");
0802 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0803                              filename = "WideRGB-elle-V2-g22.icc";
0804 cmsSaveProfileToFile(profile, filename);
0805 cmsMLUfree(description);
0806 
0807 /* linear gamma */
0808 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
0809 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0810 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0811 /* V4 */
0812 description = cmsMLUalloc(NULL, 1);
0813 cmsMLUsetASCII(description, "en", "US", "WideRGB-elle-V4-g10.icc");
0814 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0815                              filename = "WideRGB-elle-V4-g10.icc";
0816 cmsSaveProfileToFile(profile, filename);
0817 cmsMLUfree(description);
0818 /* V2 */
0819 cmsSetProfileVersion(profile, 2.1);
0820 description = cmsMLUalloc(NULL, 1);
0821 cmsMLUsetASCII(description, "en", "US", "WideRGB-elle-V2-g10.icc");
0822 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0823                              filename = "WideRGB-elle-V2-g10.icc";
0824 cmsSaveProfileToFile(profile, filename);
0825 cmsMLUfree(description);
0826 
0827 /* sRGB TRC */
0828 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
0829 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0830 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0831 /* V4 */
0832 description = cmsMLUalloc(NULL, 1);
0833 cmsMLUsetASCII(description, "en", "US", "WideRGB-elle-V4-srgbtrc.icc");
0834 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0835                              filename = "WideRGB-elle-V4-srgbtrc.icc";
0836 cmsSaveProfileToFile(profile, filename);
0837 cmsMLUfree(description);
0838 /* V2 */
0839 cmsSetProfileVersion(profile, 2.1);
0840 description = cmsMLUalloc(NULL, 1);
0841 cmsMLUsetASCII(description, "en", "US", "WideRGB-elle-V2-srgbtrc.icc");
0842 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0843                              filename = "WideRGB-elle-V2-srgbtrc.icc";
0844 cmsSaveProfileToFile(profile, filename);
0845 cmsMLUfree(description);
0846 
0847 /* labl TRC */
0848 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
0849 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0850 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0851 /* V4 */
0852 description = cmsMLUalloc(NULL, 1);
0853 cmsMLUsetASCII(description, "en", "US", "WideRGB-elle-V4-labl.icc");
0854 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0855                              filename = "WideRGB-elle-V4-labl.icc";
0856 cmsSaveProfileToFile(profile, filename);
0857 cmsMLUfree(description);
0858 /* V2 */
0859 cmsSetProfileVersion(profile, 2.1);
0860 description = cmsMLUalloc(NULL, 1);
0861 cmsMLUsetASCII(description, "en", "US", "WideRGB-elle-V2-labl.icc");
0862 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0863                              filename = "WideRGB-elle-V2-labl.icc";
0864 cmsSaveProfileToFile(profile, filename);
0865 cmsMLUfree(description);
0866 
0867 
0868 /* D65 PROFILES */
0869 
0870 /* ***** Make profile: ClayRGB (AdobeRGB), D65, gamma=2.19921875 */
0871 /* The Adobe RGB 1998 color gamut covers a higher percentage of 
0872  * real-world greens than sRGB, but still doesn't include all printable 
0873  * greens, yellows, and cyans. 
0874  * When made using the gamma=2.19921875 tone response curve, 
0875  * this profile can be used for 8-bit image editing 
0876  * if used with appropriate caution to avoid posterization. 
0877  * When made with the gamma=2.19921875 tone response curve
0878  * this profile can be applied to DCF R98 camera-generated jpegs.
0879  * */
0880 cmsCIExyYTRIPLE adobe_primaries = {
0881 {0.6400, 0.3300, 1.0},
0882 {0.2100, 0.7100, 1.0},
0883 {0.1500, 0.0600, 1.0}
0884 };
0885 cmsCIExyYTRIPLE adobe_primaries_prequantized = {
0886 {0.639996511, 0.329996864, 1.0},
0887 {0.210005295, 0.710004866, 1.0},
0888 {0.149997606, 0.060003644, 1.0}
0889 };
0890 primaries = adobe_primaries_prequantized;
0891 whitepoint = d65_srgb_adobe_specs;
0892 /* gamma 2.20 */
0893 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
0894 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0895 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0896 /* V4 */
0897 description = cmsMLUalloc(NULL, 1);
0898 cmsMLUsetASCII(description, "en", "US", "ClayRGB-elle-V4-g22.icc");
0899 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0900                              filename = "ClayRGB-elle-V4-g22.icc";
0901 cmsSaveProfileToFile(profile, filename); 
0902 cmsMLUfree(description);
0903 /* V2 */
0904 cmsSetProfileVersion(profile, 2.1);
0905 description = cmsMLUalloc(NULL, 1);
0906 cmsMLUsetASCII(description, "en", "US", "ClayRGB-elle-V2-g22.icc");
0907 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0908                              filename = "ClayRGB-elle-V2-g22.icc";
0909 cmsSaveProfileToFile(profile, filename); 
0910 cmsMLUfree(description);
0911 
0912 /* linear gamma */
0913 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
0914 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0915 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0916 /* V4 */
0917 description = cmsMLUalloc(NULL, 1);
0918 cmsMLUsetASCII(description, "en", "US", "ClayRGB-elle-V4-g10.icc");
0919 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0920                              filename = "ClayRGB-elle-V4-g10.icc";
0921 cmsSaveProfileToFile(profile, filename); 
0922 cmsMLUfree(description);
0923 /* V2 */
0924 cmsSetProfileVersion(profile, 2.1);
0925 description = cmsMLUalloc(NULL, 1);
0926 cmsMLUsetASCII(description, "en", "US", "ClayRGB-elle-V2-g10.icc");
0927 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0928                              filename = "ClayRGB-elle-V2-g10.icc";
0929 cmsSaveProfileToFile(profile, filename); 
0930 cmsMLUfree(description);
0931 
0932 /* sRGB TRC */
0933 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
0934 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0935 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0936 /* V4 */
0937 description = cmsMLUalloc(NULL, 1);
0938 cmsMLUsetASCII(description, "en", "US", "ClayRGB-elle-V4-srgbtrc.icc");
0939 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0940                              filename = "ClayRGB-elle-V4-srgbtrc.icc";
0941 cmsSaveProfileToFile(profile, filename); 
0942 cmsMLUfree(description);
0943 /* V2 */
0944 cmsSetProfileVersion(profile, 2.1);
0945 description = cmsMLUalloc(NULL, 1);
0946 cmsMLUsetASCII(description, "en", "US", "ClayRGB-elle-V2-srgbtrc.icc");
0947 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0948                              filename = "ClayRGB-elle-V2-srgbtrc.icc";
0949 cmsSaveProfileToFile(profile, filename); 
0950 cmsMLUfree(description);
0951 
0952 /* labl TRC */
0953 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
0954 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0955 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0956 /* V4 */
0957 description = cmsMLUalloc(NULL, 1);
0958 cmsMLUsetASCII(description, "en", "US", "ClayRGB-elle-V4-labl.icc");
0959 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0960                              filename = "ClayRGB-elle-V4-labl.icc";
0961 cmsSaveProfileToFile(profile, filename);
0962 cmsMLUfree(description);
0963 /* V2 */
0964 cmsSetProfileVersion(profile, 2.1);
0965 description = cmsMLUalloc(NULL, 1);
0966 cmsMLUsetASCII(description, "en", "US", "ClayRGB-elle-V2-labl.icc");
0967 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0968                              filename = "ClayRGB-elle-V2-labl.icc";
0969 cmsSaveProfileToFile(profile, filename);
0970 cmsMLUfree(description);
0971 
0972 
0973 
0974 /* ***** Make profile: Rec.2020, D65, Rec709 TRC */
0975 /* 
0976  * */
0977 cmsCIExyYTRIPLE rec2020_primaries = {
0978 {0.7079, 0.2920, 1.0},
0979 {0.1702, 0.7965, 1.0},
0980 {0.1314, 0.0459, 1.0}
0981 };
0982 
0983 cmsCIExyYTRIPLE rec2020_primaries_prequantized = {
0984 {0.708012540607, 0.291993664388, 1.0},
0985 {0.169991652439, 0.797007778423, 1.0},
0986 {0.130997824007, 0.045996550894, 1.0}
0987 };
0988 
0989 primaries = rec2020_primaries_prequantized;
0990 whitepoint = d65_srgb_adobe_specs;
0991 /* rec.709 */
0992 tone_curve[0] = tone_curve[1] = tone_curve[2] = rec709_parametric[0];
0993 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
0994 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
0995 /* V4 */
0996 description = cmsMLUalloc(NULL, 1);
0997 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V4-rec709.icc");
0998 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
0999                              filename = "Rec2020-elle-V4-rec709.icc";
1000 cmsSaveProfileToFile(profile, filename); 
1001 cmsMLUfree(description);
1002 /* V2 */
1003 cmsSetProfileVersion(profile, 2.1);
1004 description = cmsMLUalloc(NULL, 1);
1005 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V2-rec709.icc");
1006 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1007                              filename = "Rec2020-elle-V2-rec709.icc";
1008 cmsSaveProfileToFile(profile, filename); 
1009 cmsMLUfree(description);
1010 
1011 /* linear gamma */
1012 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
1013 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1014 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1015 /* V4 */
1016 description = cmsMLUalloc(NULL, 1);
1017 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V4-g10.icc");
1018 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1019                              filename = "Rec2020-elle-V4-g10.icc";
1020 cmsSaveProfileToFile(profile, filename); 
1021 cmsMLUfree(description);
1022 /* V2 */
1023 cmsSetProfileVersion(profile, 2.1);
1024 description = cmsMLUalloc(NULL, 1);
1025 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V2-g10.icc");
1026 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1027                              filename = "Rec2020-elle-V2-g10.icc";
1028 cmsSaveProfileToFile(profile, filename); 
1029 cmsMLUfree(description);
1030 
1031 /* gamma=2.2 */
1032 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
1033 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1034 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1035 /* V4 */
1036 description = cmsMLUalloc(NULL, 1);
1037 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V4-g22.icc");
1038 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1039                              filename = "Rec2020-elle-V4-g22.icc";
1040 cmsSaveProfileToFile(profile, filename); 
1041 cmsMLUfree(description);
1042 /* V2 */
1043 cmsSetProfileVersion(profile, 2.1);
1044 description = cmsMLUalloc(NULL, 1);
1045 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V2-g22.icc");
1046 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1047                              filename = "Rec2020-elle-V2-g22.icc";
1048 cmsSaveProfileToFile(profile, filename); 
1049 cmsMLUfree(description);
1050 
1051 
1052 /* sRGB TRC */
1053 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
1054 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1055 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1056 /* V4 */
1057 description = cmsMLUalloc(NULL, 1);
1058 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V4-srgbtrc.icc");
1059 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1060                              filename = "Rec2020-elle-V4-srgbtrc.icc";
1061 cmsSaveProfileToFile(profile, filename); 
1062 cmsMLUfree(description);
1063 /* V2 */
1064 cmsSetProfileVersion(profile, 2.1);
1065 description = cmsMLUalloc(NULL, 1);
1066 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V2-srgbtrc.icc");
1067 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1068                              filename = "Rec2020-elle-V2-srgbtrc.icc";
1069 cmsSaveProfileToFile(profile, filename); 
1070 cmsMLUfree(description);
1071 
1072 /* labl TRC */
1073 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
1074 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1075 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1076 /* V4 */
1077 description = cmsMLUalloc(NULL, 1);
1078 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V4-labl.icc");
1079 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1080                              filename = "Rec2020-elle-V4-labl.icc";
1081 cmsSaveProfileToFile(profile, filename);
1082 cmsMLUfree(description);
1083 /* V2 */
1084 cmsSetProfileVersion(profile, 2.1);
1085 description = cmsMLUalloc(NULL, 1);
1086 cmsMLUsetASCII(description, "en", "US", "Rec2020-elle-V2-labl.icc");
1087 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1088                              filename = "Rec2020-elle-V2-labl.icc";
1089 cmsSaveProfileToFile(profile, filename);
1090 cmsMLUfree(description);
1091 
1092 
1093 /* ***** Make profile: sRGB, D65, sRGB TRC */
1094 /* https://en.wikipedia.org/wiki/Srgb */
1095 /* Hewlett-Packard and Microsoft designed sRGB to match 
1096  * the color gamut of consumer-grade CRTs from the 1990s
1097  * and to be the standard color space for the world wide web.
1098  * When made using the standard sRGB TRC, this sRGB profile 
1099  * can be applied to DCF R03 camera-generated jpegs and 
1100  * is an excellent color space for editing 8-bit images.
1101  * When made using the linear gamma TRC, the resulting profile
1102  * should only be used for high bit depth image editing.
1103  * */
1104 cmsCIExyYTRIPLE srgb_primaries = {
1105 {0.6400, 0.3300, 1.0},
1106 {0.3000, 0.6000, 1.0},
1107 {0.1500, 0.0600, 1.0}
1108 };
1109 cmsCIExyYTRIPLE srgb_primaries_pre_quantized = {
1110 {0.639998686, 0.330010138, 1.0},
1111 {0.300003784, 0.600003357, 1.0},
1112 {0.150002046, 0.059997204, 1.0}
1113 };
1114 primaries = srgb_primaries_pre_quantized;
1115 whitepoint = d65_srgb_adobe_specs;
1116 /* sRGB TRC */
1117 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
1118 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1119 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1120 /* V4 */
1121 description = cmsMLUalloc(NULL, 1);
1122 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V4-srgbtrc.icc");
1123 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1124                              filename = "sRGB-elle-V4-srgbtrc.icc";
1125 cmsSaveProfileToFile(profile, filename);
1126 cmsMLUfree(description);
1127 /* V2 */
1128 cmsSetProfileVersion(profile, 2.1);
1129 description = cmsMLUalloc(NULL, 1);
1130 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V2-srgbtrc.icc");
1131 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1132                              filename = "sRGB-elle-V2-srgbtrc.icc";
1133 cmsSaveProfileToFile(profile, filename);
1134 cmsMLUfree(description);
1135 
1136 /* linear gamma */
1137 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
1138 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1139 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1140 /* V4 */
1141 description = cmsMLUalloc(NULL, 1);
1142 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V4-g10.icc");
1143 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1144                              filename = "sRGB-elle-V4-g10.icc";
1145 cmsSaveProfileToFile(profile, filename);
1146 cmsMLUfree(description);
1147 /* V2 */
1148 cmsSetProfileVersion(profile, 2.1);
1149 description = cmsMLUalloc(NULL, 1);
1150 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V2-g10.icc");
1151 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1152                              filename = "sRGB-elle-V2-g10.icc";
1153 cmsSaveProfileToFile(profile, filename);
1154 cmsMLUfree(description);
1155 
1156 /* gamma=2.2 */
1157 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
1158 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1159 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1160 /* V4 */
1161 description = cmsMLUalloc(NULL, 1);
1162 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V4-g22.icc");
1163 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1164                              filename = "sRGB-elle-V4-g22.icc";
1165 cmsSaveProfileToFile(profile, filename);
1166 cmsMLUfree(description);
1167 /* V2 */
1168 cmsSetProfileVersion(profile, 2.1);
1169 description = cmsMLUalloc(NULL, 1);
1170 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V2-g22.icc");
1171 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1172                              filename = "sRGB-elle-V2-g22.icc";
1173 cmsSaveProfileToFile(profile, filename);
1174 cmsMLUfree(description);
1175 
1176 /* labl TRC */
1177 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
1178 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1179 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1180 /* V4 */
1181 description = cmsMLUalloc(NULL, 1);
1182 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V4-labl.icc");
1183 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1184                              filename = "sRGB-elle-V4-labl.icc";
1185 cmsSaveProfileToFile(profile, filename);
1186 cmsMLUfree(description);
1187 /* V2 */
1188 cmsSetProfileVersion(profile, 2.1);
1189 description = cmsMLUalloc(NULL, 1);
1190 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V2-labl.icc");
1191 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1192                              filename = "sRGB-elle-V2-labl.icc";
1193 cmsSaveProfileToFile(profile, filename);
1194 cmsMLUfree(description);
1195 
1196 /* Rec.709 TRC */
1197 tone_curve[0] = tone_curve[1] = tone_curve[2] = rec709_parametric[0];
1198 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1199 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1200 /* V4 */
1201 description = cmsMLUalloc(NULL, 1);
1202 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V4-rec709.icc");
1203 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1204                              filename = "sRGB-elle-V4-rec709.icc";
1205 cmsSaveProfileToFile(profile, filename);
1206 cmsMLUfree(description);
1207 /* V2 */
1208 cmsSetProfileVersion(profile, 2.1);
1209 description = cmsMLUalloc(NULL, 1);
1210 cmsMLUsetASCII(description, "en", "US", "sRGB-elle-V2-rec709.icc");
1211 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1212                              filename = "sRGB-elle-V2-rec709.icc";
1213 cmsSaveProfileToFile(profile, filename);
1214 cmsMLUfree(description);
1215 
1216 
1217 /* ***** Make profile: CIE-RGB profile, E white point*/
1218 /* The ASTM E white point is probably the right white point 
1219  * to use when making the CIE-RGB color space profile.
1220  * It's not clear to me what the correct CIE-RGB primaries really are.
1221  * Lindbloom gives one set. The LCMS version 1 tutorial gives a different set.
1222  * I asked a friend to ask an expert, who said the real primaries should
1223  * be calculated from the spectral wavelengths. 
1224  * Two sets of primaries are given below:
1225  * */
1226 /* This page explains what the CIE color space is:
1227  * https://en.wikipedia.org/wiki/CIE_1931
1228  * These pages give the wavelengths:
1229  * http://hackipedia.org/Color%20space/pdf/CIE%20Color%20Space.pdf 
1230  * http://infocom.ing.uniroma1.it/~gaetano/texware/Full-How%20the%20CIE%201931%20Color-Matching%20Functions%20Were%20Derived%20from%20Wright-Guild%20Data.pdf
1231  * This page has resources for calculating xy values given a spectral color wavelength:
1232  * http://www.cvrl.org/cmfs.htm
1233  * This page does the calculations for you:
1234  * https://www.ledtuning.nl/en/cie-convertor
1235  * Plugging the wavelengths into the ledtuning website 
1236  * gives the following CIE RGB xy primaries:
1237 700.0 nm has Spectral Locus coordinates: x:0.734690023  y:0.265309977
1238 546.1 nm has Spectral Locus coordinates: x:0.2736747378 y:0.7174284409
1239 435.8 nm has Spectral Locus coordinates: x:0.1665361196 y:0.0088826412
1240 * */
1241 cmsCIExyYTRIPLE cie_primaries_ledtuning = {
1242 {0.7346900230, 0.2653099770, 1.0},
1243 {0.2736747378, 0.7174284409, 1.0},
1244 {0.1665361196, 0.0088826412, 1.0}
1245 };
1246 /* Assuming you want to use the ASTM values for the E white point, 
1247  * here are the prequantized ledtuning primaries */
1248 cmsCIExyYTRIPLE cie_primaries_ledtuning_prequantized = {
1249 {0.734689082, 0.265296653, 1.0},
1250 {0.273673341, 0.717437354, 1.0},
1251 {0.166531028, 0.008882428, 1.0}
1252 };
1253 primaries = cie_primaries_ledtuning_prequantized;
1254 whitepoint = e_astm;
1255 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
1256 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1257 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1258 /* V4 */
1259 description = cmsMLUalloc(NULL, 1);
1260 cmsMLUsetASCII(description, "en", "US", "CIERGB-elle-V4-g22.icc");
1261 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1262                              filename = "CIERGB-elle-V4-g22.icc";
1263 cmsSaveProfileToFile(profile, filename);
1264 cmsMLUfree(description);
1265 /* V2 */
1266 cmsSetProfileVersion(profile, 2.1);
1267 description = cmsMLUalloc(NULL, 1);
1268 cmsMLUsetASCII(description, "en", "US", "CIERGB-elle-V2-g22.icc");
1269 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1270                              filename = "CIERGB-elle-V2-g22.icc";
1271 cmsSaveProfileToFile(profile, filename);
1272 cmsMLUfree(description);
1273 
1274 /* A linear gamma version of this profile makes more sense 
1275  * than a gamma=2.2 version */
1276 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma100[0];
1277 whitepoint = e_astm;
1278 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1279 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1280 /* V4 */
1281 description = cmsMLUalloc(NULL, 1);
1282 cmsMLUsetASCII(description, "en", "US", "CIERGB-elle-V4-g10.icc");
1283 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1284                              filename = "CIERGB-elle-V4-g10.icc";
1285 cmsSaveProfileToFile(profile, filename);
1286 cmsMLUfree(description);
1287 /* V2 */
1288 cmsSetProfileVersion(profile, 2.1);
1289 description = cmsMLUalloc(NULL, 1);
1290 cmsMLUsetASCII(description, "en", "US", "CIERGB-elle-V2-g10.icc");
1291 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1292                              filename = "CIERGB-elle-V2-g10.icc";
1293 cmsSaveProfileToFile(profile, filename);
1294 cmsMLUfree(description);
1295 
1296 /* sRGB TRC*/
1297 tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric[0];
1298 whitepoint = e_astm;
1299 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1300 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1301 /* V4 */
1302 description = cmsMLUalloc(NULL, 1);
1303 cmsMLUsetASCII(description, "en", "US", "CIERGB-elle-V4-srgbtrc.icc");
1304 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1305                              filename = "CIERGB-elle-V4-srgbtrc.icc";
1306 cmsSaveProfileToFile(profile, filename);
1307 cmsMLUfree(description);
1308 /* V2 */
1309 cmsSetProfileVersion(profile, 2.1);
1310 description = cmsMLUalloc(NULL, 1);
1311 cmsMLUsetASCII(description, "en", "US", "CIERGB-elle-V2-srgbtrc.icc");
1312 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1313                              filename = "CIERGB-elle-V2-srgbtrc.icc";
1314 cmsSaveProfileToFile(profile, filename);
1315 cmsMLUfree(description);
1316 
1317 /* labl TRC */
1318 tone_curve[0] = tone_curve[1] = tone_curve[2] = labl_parametric[0];
1319 profile = cmsCreateRGBProfile ( &whitepoint, &primaries, tone_curve );
1320 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1321 /* V4 */
1322 description = cmsMLUalloc(NULL, 1);
1323 cmsMLUsetASCII(description, "en", "US", "CIERGB-elle-V4-labl.icc");
1324 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1325                              filename = "CIERGB-elle-V4-labl.icc";
1326 cmsSaveProfileToFile(profile, filename);
1327 cmsMLUfree(description);
1328 /* V2 */
1329 cmsSetProfileVersion(profile, 2.1);
1330 description = cmsMLUalloc(NULL, 1);
1331 cmsMLUsetASCII(description, "en", "US", "CIERGB-elle-V2-labl.icc");
1332 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1333                              filename = "CIERGB-elle-V2-labl.icc";
1334 cmsSaveProfileToFile(profile, filename);
1335 cmsMLUfree(description);
1336 
1337 
1338 /* 
1339  * Here's the second set of primaries
1340  * http://www.cis.rit.edu/research/mcsl2/research/broadbent/CIE1931_RGB.pdf
1341  * https://groups.google.com/forum/#!topic/sci.engr.color/fBI3k1llm-g 
1342  * Lindbloom gives these values on his Working Space Information page: */
1343 cmsCIExyYTRIPLE cie_primaries_lindbloom = {
1344 {0.7350, 0.2650, 1.0},
1345 {0.2740, 0.7170, 1.0},
1346 {0.1670, 0.0090, 1.0}
1347 }; 
1348 /* Assuming you want to use the ASTM values for the E white point, 
1349  * here are the prequantized Lindbloom primaries */
1350 cmsCIExyYTRIPLE cie_primaries_lindbloom_prequantized = {
1351 {0.714504840, 0.297234644, 1.0},
1352 {0.520085568, 0.452364535, 1.0},
1353 {0.090957433, 0.051485032, 1.0}
1354 }; 
1355 
1356 
1357 /* ***** Make profile: Gray ICC profiles - D50 white point  ********* */
1358 whitepoint = d50_illuminant_specs;
1359 const cmsToneCurve* grayTRC;
1360 
1361 /* Gray profile with gamma=1.00, linear gamma, "linear light", etc */
1362 grayTRC = cmsBuildGamma (NULL, 1.00); 
1363 profile = cmsCreateGrayProfile ( &whitepoint, grayTRC );
1364 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1365 /* V4 */
1366 description = cmsMLUalloc(NULL, 1);
1367 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V4-g10.icc");
1368 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1369                              filename = "Gray-D50-elle-V4-g10.icc";
1370 cmsSaveProfileToFile(profile, filename);
1371 cmsMLUfree(description);
1372 /* V2 */
1373 cmsSetProfileVersion(profile, 2.1);
1374 description = cmsMLUalloc(NULL, 1);
1375 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V2-g10.icc");
1376 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1377                              filename = "Gray-D50-elle-V2-g10.icc";
1378 cmsSaveProfileToFile(profile, filename);
1379 cmsMLUfree(description);
1380 
1381 /* Gray profile with gamma=1.80, 
1382  * actually 1.80078125,
1383  * in order to create the same gamma curve in V2 and V4 profiles */
1384 grayTRC = cmsBuildGamma (NULL, 1.80078125); 
1385 profile = cmsCreateGrayProfile ( &whitepoint, grayTRC );
1386 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1387 /* V4 */
1388 description = cmsMLUalloc(NULL, 1);
1389 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V4-g18.icc");
1390 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1391                              filename = "Gray-D50-elle-V4-g18.icc";
1392 cmsSaveProfileToFile(profile, filename);
1393 cmsMLUfree(description);
1394 /* V2 */
1395 cmsSetProfileVersion(profile, 2.1);
1396 description = cmsMLUalloc(NULL, 1);
1397 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V2-g18.icc");
1398 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1399                              filename = "Gray-D50-elle-V2-g18.icc";
1400 cmsSaveProfileToFile(profile, filename);
1401 cmsMLUfree(description);
1402 
1403 /* Gray profile with gamma=2.20 
1404  * actually gamma=2.19921875,
1405  * in order to create the same gamma curve in V2 and V4 profiles  */
1406 grayTRC = cmsBuildGamma (NULL, 2.19921875); 
1407 profile = cmsCreateGrayProfile ( &whitepoint, grayTRC );
1408 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1409 /* V4 */
1410 description = cmsMLUalloc(NULL, 1);
1411 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V4-g22.icc");
1412 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1413                              filename = "Gray-D50-elle-V4-g22.icc";
1414 cmsSaveProfileToFile(profile, filename);
1415 cmsMLUfree(description);
1416 /* V2 */
1417 cmsSetProfileVersion(profile, 2.1);
1418 description = cmsMLUalloc(NULL, 1);
1419 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V2-g22.icc");
1420 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1421                              filename = "Gray-D50-elle-V2-g22.icc";
1422 cmsSaveProfileToFile(profile, filename);
1423 cmsMLUfree(description);
1424 
1425 /* Gray profile with srgb-trc */
1426 grayTRC = cmsBuildParametricToneCurve(NULL, 4, srgb_parameters);
1427 profile = cmsCreateGrayProfile ( &whitepoint, grayTRC );
1428 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1429 /* V4 */
1430 description = cmsMLUalloc(NULL, 1);
1431 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V4-srgbtrc.icc");
1432 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1433                              filename = "Gray-D50-elle-V4-srgbtrc.icc";
1434 cmsSaveProfileToFile(profile, filename);
1435 cmsMLUfree(description);
1436 /* V2 */
1437 cmsSetProfileVersion(profile, 2.1);
1438 description = cmsMLUalloc(NULL, 1);
1439 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V2-srgbtrc.icc");
1440 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1441                              filename = "Gray-D50-elle-V2-srgbtrc.icc";
1442 cmsSaveProfileToFile(profile, filename);
1443 cmsMLUfree(description);
1444 
1445 /* Gray profile with labl TRC */
1446 grayTRC = cmsBuildParametricToneCurve(NULL, 4, labl_parameters);
1447 profile = cmsCreateGrayProfile ( &whitepoint, grayTRC );
1448 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1449 /* V4 */
1450 description = cmsMLUalloc(NULL, 1);
1451 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V4-labl.icc");
1452 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1453                              filename = "Gray-D50-elle-V4-labl.icc";
1454 cmsSaveProfileToFile(profile, filename);
1455 cmsMLUfree(description);
1456 /* V2 */
1457 cmsSetProfileVersion(profile, 2.1);
1458 description = cmsMLUalloc(NULL, 1);
1459 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V2-labl.icc");
1460 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1461                              filename = "Gray-D50-elle-V2-labl.icc";
1462 cmsSaveProfileToFile(profile, filename);
1463 cmsMLUfree(description);
1464 
1465 /* Gray profile with Rec709 TRC */
1466 grayTRC = cmsBuildParametricToneCurve(NULL, 4, rec709_parameters);
1467 profile = cmsCreateGrayProfile ( &whitepoint, grayTRC );
1468 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1469 /* V4 */
1470 description = cmsMLUalloc(NULL, 1);
1471 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V4-rec709.icc");
1472 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1473                              filename = "Gray-D50-elle-V4-rec709.icc";
1474 cmsSaveProfileToFile(profile, filename);
1475 cmsMLUfree(description);
1476 /* V2 */
1477 cmsSetProfileVersion(profile, 2.1);
1478 description = cmsMLUalloc(NULL, 1);
1479 cmsMLUsetASCII(description, "en", "US", "Gray-D50-elle-V2-rec709.icc");
1480 cmsWriteTag(profile, cmsSigProfileDescriptionTag, description);
1481                              filename = "Gray-D50-elle-V2-rec709.icc";
1482 cmsSaveProfileToFile(profile, filename);
1483 cmsMLUfree(description);
1484 
1485 
1486 /* ***** Make profile: LCMS built-in LAB and XYZ profiles *********** */
1487 /* Based on transicc output, the V4 profiles 
1488  * can be used in unbounded mode, but the V2 versions cannot. */
1489 profile  = cmsCreateLab2Profile(&d50_illuminant_specs);
1490 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1491 description = cmsMLUalloc(NULL, 1);
1492 cmsMLUsetASCII(description, "en", "US", "Lab-D50-Identity-elle-V2.icc");
1493                              filename = "Lab-D50-Identity-elle-V2.icc";
1494 cmsSaveProfileToFile(profile, filename);
1495 cmsMLUfree(description);
1496 
1497 profile  = cmsCreateLab4Profile(&d50_illuminant_specs);
1498 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1499 description = cmsMLUalloc(NULL, 1);
1500 cmsMLUsetASCII(description, "en", "US", "Lab-D50-Identity-elle-V4.icc");
1501                              filename = "Lab-D50-Identity-elle-V4.icc";
1502 cmsSaveProfileToFile(profile, filename);
1503 cmsMLUfree(description);
1504 
1505 profile = cmsCreateXYZProfile();
1506 cmsWriteTag(profile, cmsSigCopyrightTag, copyright);
1507 description = cmsMLUalloc(NULL, 1);
1508 cmsMLUsetASCII(description, "en", "US", "XYZ-D50-Identity-elle-V4.icc");
1509                              filename = "XYZ-D50-Identity-elle-V4.icc";
1510 cmsSaveProfileToFile(profile, filename);
1511 cmsMLUfree(description);
1512 
1513 
1514 /* For the following profiles, information is provided, but not the actual
1515  * profile making code.
1516  * */
1517 
1518 /* old monitor-based editing profiles */
1519 
1520 /* ColorMatchRGB, D50, gamma=1.80 */
1521 /* https://www.dpreview.com/forums/post/3902882 
1522  * https://lists.apple.com/archives/colorsync-users/2001/Apr/msg00073.html
1523  * ColorMatch was designed to fit Radius PressView CRT monitors,
1524  * similar to sRGB fitting consumer-grade CRT monitors, 
1525  * "fit" meaning "could be calibrated to match".
1526  * Adobe does still distribute a ColorMatchRGB profile.
1527  * Making this profile using the D50_romm_doc white point that is used 
1528  * in other old V2 profiles (ProPhoto, WideGamut)
1529  * doesn't make a well behaved profile,
1530  * but the resulting profile is very close to the Adobe-supplied version. 
1531  * Using the prequantized primaries makes a profile that's just as close
1532  * to the Adobe-supplied version and in addition is well behaved.
1533  * Unless you have untagged images created on a PressView CRT, 
1534  * there is no reason to make or use this profile. 
1535  * */
1536 cmsCIExyYTRIPLE colormatch_primaries = {
1537 {0.6300, 0.3400, 1.0},
1538 {0.2950, 0.6050, 1.0},
1539 {0.1500, 0.0750, 1.0}
1540 };
1541 cmsCIExyYTRIPLE colormatch_primaries_prequantized = {
1542 {0.629992636, 0.339999723, 1.0},
1543 {0.295006332, 0.604997745, 1.0},
1544 {0.149992036, 0.075005244, 1.0}
1545 };
1546 primaries = colormatch_primaries_prequantized;
1547 whitepoint = d50_romm_spec;
1548 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma180[0];
1549 
1550 /* AppleRGB, D65, gamma=1.80 */
1551 /* AppleRGB was created to fit the old Apple CRT displays
1552  * just as sRGB fit consumer-grade CRT monitors
1553  * and ColorMatch fit PressView CRT monitors.
1554  * */
1555 cmsCIExyYTRIPLE apple_primaries = {
1556 {0.6250, 0.3400, 1.0},
1557 {0.2800, 0.5950, 1.0},
1558 {0.1550, 0.0700, 1.0}
1559 };
1560 cmsCIExyYTRIPLE apple_primaries_prequantized = {
1561 {0.625012368, 0.340000081, 1.0},
1562 {0.279996113, 0.595006943, 1.0},
1563 {0.155001212, 0.070001183, 1.0}
1564 };
1565 primaries = apple_primaries_prequantized;
1566 whitepoint = d65_srgb_adobe_specs;
1567 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma180[0];
1568 
1569 /* video profiles */
1570 
1571 /* PAL-SECAM, D65 gamma=2.20 */
1572 /* https://en.wikipedia.org/wiki/PAL */
1573 cmsCIExyYTRIPLE pal_primaries = {
1574 {0.6400, 0.3300, 1.0},
1575 {0.2900, 0.6000, 1.0},
1576 {0.1500, 0.0600, 1.0}
1577 }; 
1578 /* PAL is one of many video and television-related color spaces. 
1579  * If you need the original profile with all its tags, 
1580  * I recommend that you use the Argyllcms version of this profile 
1581  * (EBU3213_PAL.icm, located in the "ref" folder), 
1582  * rather than making your own. 
1583  * But if you do want to make your own PAL profile using LCMS2, 
1584  * these prequantized primaries and white point make a profile with 
1585  * the same primaries and white point as the Argyllcms profile. 
1586  * The Argyllcms profile has a point curve TRC.
1587  * */
1588 cmsCIExyYTRIPLE pal_primaries_prequantized = {
1589 {0.640007798, 0.330006592, 1.0},
1590 {0.290000327, 0.600000840, 1.0},
1591 {0.149998025, 0.059996098, 1.0}
1592 };
1593 primaries = pal_primaries_prequantized;
1594 whitepoint = d65_srgb_adobe_specs;
1595 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
1596 
1597 /* SMPTE-C, D65, gamma=2.20 */
1598 /* https://en.wikipedia.org/wiki/NTSC#SMPTE_C 
1599  * SMPTE-C is one of many video and television-related color spaces 
1600  * and is an update of the original NTSC. */
1601 cmsCIExyYTRIPLE smpte_c_primaries = {
1602 {0.6300, 0.3400, 1.0},
1603 {0.3100, 0.5950, 1.0},
1604 {0.1550, 0.0700, 1.0}
1605 };
1606 cmsCIExyYTRIPLE smpte_c_primaries_prequantized = {
1607 {0.629996495, 0.339990597, 1.0},
1608 {0.309997880, 0.594995808, 1.0},
1609 {0.149999952, 0.069999431, 1.0}
1610 };
1611 primaries = smpte_c_primaries_prequantized;
1612 whitepoint = d65_srgb_adobe_specs;
1613 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
1614 
1615 /* NTSC, C, gamma=2.20 */
1616 /* https://en.wikipedia.org/wiki/NTSC#Colorimetry*/
1617 /* According to Wikipedia, these "original 1953 color NTSC specifications"
1618  * were used by early television receivers. */
1619 cmsCIExyYTRIPLE ntcs_primaries = {
1620 {0.6700, 0.3300, 1.0},
1621 {0.2100, 0.7100, 1.0},
1622 {0.1400, 0.0800, 1.0}
1623 }; 
1624 cmsCIExyYTRIPLE ntcs_primaries_prequantized = {
1625 {0.670010373, 0.330001186, 1.0},
1626 {0.209999261, 0.710001124, 1.0},
1627 {0.139996061, 0.080002934, 1.0}
1628 };
1629 primaries = ntcs_primaries_prequantized;
1630 whitepoint = c_astm;
1631 tone_curve[0] = tone_curve[1] = tone_curve[2] = gamma220[0];
1632 
1633 
1634 /* ***********************  wrap up and close out  ****************** */
1635 
1636 /* free copyright */
1637 cmsMLUfree(copyright);
1638 
1639 /* make gcc happy by returning an integer from main() */
1640 return 0;
1641 }