mesa: simplify dependencies in mmakefiles
[AROS.git] / workbench / libs / lcms2 / utils / samples / mkcmy.c
blob1b0755f17b06fecd71365d4c19904d6643e1a61a
1 //
2 // Little cms
3 // Copyright (C) 1998-2003 Marti Maria
4 //
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 // THIS SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17 // WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19 // IN NO EVENT SHALL MARTI MARIA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20 // INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21 // OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22 // WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 // LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 // OF THIS SOFTWARE.
26 // Version 1.12
29 #include "lcms.h"
32 typedef struct {
33 cmsHPROFILE hLab;
34 cmsHPROFILE hRGB;
35 cmsHTRANSFORM Lab2RGB;
36 cmsHTRANSFORM RGB2Lab;
38 } CARGO, FAR* LPCARGO;
44 // Our space will be CIE primaries plus a gamma of 4.5
46 static
47 int Forward(register WORD In[], register WORD Out[], register LPVOID Cargo)
49 LPCARGO C = (LPCARGO) Cargo;
50 WORD RGB[3];
51 cmsCIELab Lab;
53 cmsLabEncoded2Float(&Lab, In);
55 printf("%g %g %g\n", Lab.L, Lab.a, Lab.b);
57 cmsDoTransform(C ->Lab2RGB, In, &RGB, 1);
60 Out[0] = 0xFFFF - RGB[0]; // Our CMY is negative of RGB
61 Out[1] = 0xFFFF - RGB[1];
62 Out[2] = 0xFFFF - RGB[2];
65 return TRUE;
70 static
71 int Reverse(register WORD In[], register WORD Out[], register LPVOID Cargo)
74 LPCARGO C = (LPCARGO) Cargo;
75 WORD RGB[3];
77 RGB[0] = 0xFFFF - In[0];
78 RGB[1] = 0xFFFF - In[1];
79 RGB[2] = 0xFFFF - In[2];
81 cmsDoTransform(C ->RGB2Lab, &RGB, Out, 1);
83 return TRUE;
89 static
90 void InitCargo(LPCARGO Cargo)
94 Cargo -> hLab = cmsCreateLabProfile(NULL);
95 Cargo -> hRGB = cmsCreate_sRGBProfile();
97 Cargo->Lab2RGB = cmsCreateTransform(Cargo->hLab, TYPE_Lab_16,
98 Cargo ->hRGB, TYPE_RGB_16,
99 INTENT_RELATIVE_COLORIMETRIC,
100 cmsFLAGS_NOTPRECALC);
102 Cargo->RGB2Lab = cmsCreateTransform(Cargo ->hRGB, TYPE_RGB_16,
103 Cargo ->hLab, TYPE_Lab_16,
104 INTENT_RELATIVE_COLORIMETRIC,
105 cmsFLAGS_NOTPRECALC);
111 static
112 void FreeCargo(LPCARGO Cargo)
114 cmsDeleteTransform(Cargo ->Lab2RGB);
115 cmsDeleteTransform(Cargo ->RGB2Lab);
116 cmsCloseProfile(Cargo ->hLab);
117 cmsCloseProfile(Cargo ->hRGB);
123 int main(void)
125 LPLUT AToB0, BToA0;
126 CARGO Cargo;
127 cmsHPROFILE hProfile;
129 fprintf(stderr, "Creating lcmscmy.icm...");
131 InitCargo(&Cargo);
133 hProfile = cmsCreateLabProfile(NULL);
136 AToB0 = cmsAllocLUT();
137 BToA0 = cmsAllocLUT();
139 cmsAlloc3DGrid(AToB0, 25, 3, 3);
140 cmsAlloc3DGrid(BToA0, 25, 3, 3);
143 cmsSample3DGrid(AToB0, Reverse, &Cargo, 0);
144 cmsSample3DGrid(BToA0, Forward, &Cargo, 0);
147 cmsAddTag(hProfile, icSigAToB0Tag, AToB0);
148 cmsAddTag(hProfile, icSigBToA0Tag, BToA0);
150 cmsSetColorSpace(hProfile, icSigCmyData);
151 cmsSetDeviceClass(hProfile, icSigOutputClass);
153 cmsAddTag(hProfile, icSigProfileDescriptionTag, "CMY ");
154 cmsAddTag(hProfile, icSigCopyrightTag, "Copyright (c) HP, 2007. All rights reserved.");
155 cmsAddTag(hProfile, icSigDeviceMfgDescTag, "Little cms");
156 cmsAddTag(hProfile, icSigDeviceModelDescTag, "CMY space");
158 _cmsSaveProfile(hProfile, "lcmscmy.icm");
161 cmsFreeLUT(AToB0);
162 cmsFreeLUT(BToA0);
163 cmsCloseProfile(hProfile);
164 FreeCargo(&Cargo);
165 fprintf(stderr, "Done.\n");
169 return 0;