Tizen 2.0 Release
[external/lcms.git] / utils / samples / wtpt.c
1 //
2 //  Little cms
3 //  Copyright (C) 1998-2000 Marti Maria
4 //
5 // THIS SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
6 // EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
7 // WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
8 //
9 // IN NO EVENT SHALL MARTI MARIA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
10 // INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
11 // OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
12 // WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
13 // LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
14 // OF THIS SOFTWARE.
15 //
16 //
17 // This library is free software; you can redistribute it and/or
18 // modify it under the terms of the GNU Lesser General Public
19 // License as published by the Free Software Foundation; either
20 // version 2 of the License, or (at your option) any later version.
21 //
22 // This library is distributed in the hope that it will be useful,
23 // but WITHOUT ANY WARRANTY; without even the implied warranty of
24 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25 // Lesser General Public License for more details.
26 //
27 // You should have received a copy of the GNU Lesser General Public
28 // License along with this library; if not, write to the Free Software
29 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
30
31 // Example: how to show white points of profiles
32
33
34 #include "lcms.h"
35
36
37
38 static
39 void ShowWhitePoint(LPcmsCIEXYZ WtPt)
40 {       
41            cmsCIELab Lab;
42            cmsCIELCh LCh;
43            cmsCIExyY xyY;
44        char Buffer[1024];
45
46                 
47            _cmsIdentifyWhitePoint(Buffer, WtPt);
48        printf("%s\n", Buffer);
49        
50        cmsXYZ2Lab(NULL, &Lab, WtPt);
51            cmsLab2LCh(&LCh, &Lab);
52            cmsXYZ2xyY(&xyY, WtPt);
53
54            printf("XYZ=(%3.1f, %3.1f, %3.1f)\n", WtPt->X, WtPt->Y, WtPt->Z);
55        printf("Lab=(%3.3f, %3.3f, %3.3f)\n", Lab.L, Lab.a, Lab.b);
56            printf("(x,y)=(%3.3f, %3.3f)\n", xyY.x, xyY.y);
57            printf("Hue=%3.2f, Chroma=%3.2f\n", LCh.h, LCh.C);
58        printf("\n");
59        
60 }
61
62
63 int main (int argc, char *argv[])
64 {
65        printf("Show media white of profiles, identifying black body locus. v2\n\n");
66
67
68        if (argc == 2) {
69                                   cmsCIEXYZ WtPt;
70                           cmsHPROFILE hProfile = cmsOpenProfileFromFile(argv[1], "r");
71
72                                   printf("%s\n", cmsTakeProductName(hProfile));
73                                   cmsTakeMediaWhitePoint(&WtPt, hProfile);
74                                   ShowWhitePoint(&WtPt);
75                                   cmsCloseProfile(hProfile);
76               }
77        else
78               {
79               cmsCIEXYZ xyz;
80               
81               printf("usage:\n\nIf no parameters are given, then this program will\n");
82               printf("ask for XYZ value of media white. If parameter given, it must be\n");
83               printf("the profile to inspect.\n\n");
84
85               printf("X? "); scanf("%lf", &xyz.X);
86               printf("Y? "); scanf("%lf", &xyz.Y);
87               printf("Z? "); scanf("%lf", &xyz.Z);
88
89                           ShowWhitePoint(&xyz);
90               }
91
92            return 0;
93 }
94