1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
//
// Little cms
// Copyright (C) 1998-2015 Marti Maria
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
// Copyright (c) 1998-2014 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//---------------------------------------------------------------------------------
#include "utils.h"
// The toggles stuff
static cmsBool lShowXYZ = TRUE;
static cmsBool lShowLab = FALSE;
static cmsBool lShowLCh = FALSE;
static
void HandleSwitches(int argc, char *argv[])
{
int s;
while ((s = xgetopt(argc, argv, "lcx")) != EOF) {
switch (s){
case 'l':
lShowLab = TRUE;
break;
case 'c':
lShowLCh = TRUE;
break;
case 'x':
lShowXYZ = FALSE;
break;
default:
FatalError("Unknown option - run without args to see valid ones.\n");
}
}
}
static
void Help(void)
{
fprintf(stderr, "little CMS ICC white point utility - v3 [LittleCMS %2.2f]\n", LCMS_VERSION / 1000.0);
fprintf(stderr, "usage: wtpt [flags] [<ICC profile>]\n\n");
fprintf(stderr, "flags:\n\n");
fprintf(stderr, "%cl - CIE Lab\n", SW);
fprintf(stderr, "%cc - CIE LCh\n", SW);
fprintf(stderr, "%cx - Don't show XYZ\n", SW);
fprintf(stderr, "\nIf no parameters are given, then this program will\n");
fprintf(stderr, "ask for XYZ value of media white. If parameter given, it must be\n");
fprintf(stderr, "the profile to inspect.\n\n");
fprintf(stderr, "This program is intended to be a demo of the little cms\n"
"engine. Both lcms and this program are freeware. You can\n"
"obtain both in source code at http://www.littlecms.com\n"
"For suggestions, comments, bug reports etc. send mail to\n"
"info@littlecms.com\n\n");
exit(0);
}
static
void ShowWhitePoint(cmsCIEXYZ* WtPt)
{
cmsCIELab Lab;
cmsCIELCh LCh;
cmsCIExyY xyY;
cmsXYZ2Lab(NULL, &Lab, WtPt);
cmsLab2LCh(&LCh, &Lab);
cmsXYZ2xyY(&xyY, WtPt);
if (lShowXYZ) printf("XYZ=(%3.1f, %3.1f, %3.1f)\n", WtPt->X, WtPt->Y, WtPt->Z);
if (lShowLab) printf("Lab=(%3.3f, %3.3f, %3.3f)\n", Lab.L, Lab.a, Lab.b);
if (lShowLCh) printf("LCh=(%3.3f, %3.3f, %3.3f)\n", LCh.L, LCh.C, LCh.h);
{
double Ssens = (LCh.C * 100.0 )/ sqrt(LCh.C*LCh.C + LCh.L * LCh.L) ;
printf("Sens = %f\n", Ssens);
}
}
int main(int argc, char *argv[])
{
int nargs;
InitUtils("wtpt");
HandleSwitches(argc, argv);
nargs = (argc - xoptind);
if (nargs != 1)
Help();
else {
cmsCIEXYZ* WtPt;
cmsHPROFILE hProfile = cmsOpenProfileFromFile(argv[xoptind], "r");
if (hProfile == NULL) return 1;
WtPt = cmsReadTag(hProfile, cmsSigMediaWhitePointTag);
ShowWhitePoint(WtPt);
cmsCloseProfile(hProfile);
}
return 0;
}
|