aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/HVC.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib/X11/HVC.c')
-rw-r--r--nx-X11/lib/X11/HVC.c59
1 files changed, 38 insertions, 21 deletions
diff --git a/nx-X11/lib/X11/HVC.c b/nx-X11/lib/X11/HVC.c
index d46a73f6f..f790b1335 100644
--- a/nx-X11/lib/X11/HVC.c
+++ b/nx-X11/lib/X11/HVC.c
@@ -2,7 +2,7 @@
/*
* Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
* All Rights Reserved
- *
+ *
* This file is a component of an X Window System-specific implementation
* of Xcms based on the TekColor Color Management System. TekColor is a
* trademark of Tektronix, Inc. The term "TekHVC" designates a particular
@@ -10,10 +10,10 @@
* foreign patents pending). Permission is hereby granted to use, copy,
* modify, sell, and otherwise distribute this software and its
* documentation for any purpose and without fee, provided that:
- *
+ *
* 1. This copyright, permission, and disclaimer notice is reproduced in
* all copies of this software and any modification thereof and in
- * supporting documentation;
+ * supporting documentation;
* 2. Any color-handling application which displays TekHVC color
* cooordinates identifies these as TekHVC color coordinates in any
* interface that displays these coordinates and in any associated
@@ -23,10 +23,10 @@
* including those provided in this file and any equivalent pathways and
* mathematical derivations, regardless of digital (e.g., floating point
* or integer) representation.
- *
+ *
* Tektronix makes no representation about the suitability of this software
* for any purpose. It is provided "as is" and with all faults.
- *
+ *
* TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
* INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
@@ -82,7 +82,7 @@
/*************************************************************************
* Note: The DBL_EPSILON for ANSI is 1e-5 so my checks need to take
* this into account. If your DBL_EPSILON is different then
- * adjust this define.
+ * adjust this define.
*
* Also note that EPS is the error factor in the calculations
* This may need to be the same as XMY_DBL_EPSILON in
@@ -198,7 +198,24 @@ TekHVC_ParseString(
&pColor->spec.TekHVC.H,
&pColor->spec.TekHVC.V,
&pColor->spec.TekHVC.C) != 3) {
- return(XcmsFailure);
+ char *s; /* Maybe failed due to locale */
+ int f;
+ if ((s = strdup(spec))) {
+ for (f = 0; s[f]; ++f)
+ if (s[f] == '.')
+ s[f] = ',';
+ else if (s[f] == ',')
+ s[f] = '.';
+ if (sscanf(s + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.TekHVC.H,
+ &pColor->spec.TekHVC.V,
+ &pColor->spec.TekHVC.C) != 3) {
+ free(s);
+ return(XcmsFailure);
+ }
+ free(s);
+ } else
+ return(XcmsFailure);
}
pColor->format = XcmsTekHVCFormat;
pColor->pixel = 0;
@@ -299,7 +316,7 @@ XcmsTekHVC_ValidSpec(
}
while (pColor->spec.TekHVC.H >= 360.0) {
pColor->spec.TekHVC.H -= 360.0;
- }
+ }
return(XcmsSuccess);
}
@@ -310,11 +327,11 @@ XcmsTekHVC_ValidSpec(
* SYNOPSIS
*/
Status
-XcmsTekHVCToCIEuvY(ccc, pHVC_WhitePt, pColors_in_out, nColors)
- XcmsCCC ccc;
- XcmsColor *pHVC_WhitePt;
- XcmsColor *pColors_in_out;
- unsigned int nColors;
+XcmsTekHVCToCIEuvY(
+ XcmsCCC ccc,
+ XcmsColor *pHVC_WhitePt,
+ XcmsColor *pColors_in_out,
+ unsigned int nColors)
/*
* DESCRIPTION
* Transforms an array of TekHVC color specifications, given
@@ -396,9 +413,9 @@ XcmsTekHVCToCIEuvY(ccc, pHVC_WhitePt, pColors_in_out, nColors)
tempHue = radians(tempHue);
/* Calculate u'v' for the obtained hue */
- u = (XcmsFloat) ((XCMS_COS(tempHue) * pColor->spec.TekHVC.C) /
+ u = (XcmsFloat) ((XCMS_COS(tempHue) * pColor->spec.TekHVC.C) /
(pColor->spec.TekHVC.V * (double)CHROMA_SCALE_FACTOR));
- v = (XcmsFloat) ((XCMS_SIN(tempHue) * pColor->spec.TekHVC.C) /
+ v = (XcmsFloat) ((XCMS_SIN(tempHue) * pColor->spec.TekHVC.C) /
(pColor->spec.TekHVC.V * (double)CHROMA_SCALE_FACTOR));
/* Based on the white point get the offset from best red */
@@ -431,11 +448,11 @@ XcmsTekHVCToCIEuvY(ccc, pHVC_WhitePt, pColors_in_out, nColors)
* SYNOPSIS
*/
Status
-XcmsCIEuvYToTekHVC(ccc, pHVC_WhitePt, pColors_in_out, nColors)
- XcmsCCC ccc;
- XcmsColor *pHVC_WhitePt;
- XcmsColor *pColors_in_out;
- unsigned int nColors;
+XcmsCIEuvYToTekHVC(
+ XcmsCCC ccc,
+ XcmsColor *pHVC_WhitePt,
+ XcmsColor *pColors_in_out,
+ unsigned int nColors)
/*
* DESCRIPTION
* Transforms an array of CIECIEuvY.color specifications, given
@@ -603,6 +620,6 @@ _XcmsTekHVC_CheckModify(
} else if (pColor->spec.TekHVC.H >= 360.0) {
n = pColor->spec.TekHVC.H / 360.0;
pColor->spec.TekHVC.H -= n * 360.0;
- }
+ }
return(1);
}