3 // Copyright (C) 1998-2003 Marti Maria
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the Software
10 // is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
17 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 int Forward(register WORD In[], register WORD Out[], register LPVOID Cargo)
34 cmsLabEncoded2Float(&Lab, In);
36 if (fabs(Lab.a) < 3 && fabs(Lab.b) < 3) {
38 double L_01 = Lab.L / 100.0;
41 if (L_01 > 1) L_01 = 1;
42 K = (WORD) floor(L_01* 65535.0 + 0.5);
44 Out[0] = Out[1] = Out[2] = K;
47 Out[0] = 0xFFFF; Out[1] = 0; Out[2] = 0;
57 int main(int argc, char *argv[])
62 fprintf(stderr, "Creating interpol2.icc...");
64 unlink("interpol2.icc");
65 hProfile = cmsOpenProfileFromFile("interpol2.icc", "w8");
68 BToA0 = cmsAllocLUT();
70 cmsAlloc3DGrid(BToA0, 17, 3, 3);
72 cmsSample3DGrid(BToA0, Forward, NULL, 0);
74 cmsAddTag(hProfile, icSigBToA0Tag, BToA0);
76 cmsSetColorSpace(hProfile, icSigRgbData);
77 cmsSetPCS(hProfile, icSigLabData);
78 cmsSetDeviceClass(hProfile, icSigOutputClass);
80 cmsAddTag(hProfile, icSigProfileDescriptionTag, "Interpolation test");
81 cmsAddTag(hProfile, icSigCopyrightTag, "Copyright (c) HP 2007. All rights reserved.");
82 cmsAddTag(hProfile, icSigDeviceMfgDescTag, "Little cms");
83 cmsAddTag(hProfile, icSigDeviceModelDescTag, "Interpolation test profile");
86 cmsCloseProfile(hProfile);
90 fprintf(stderr, "Done.\n");