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