catch some more cxf colors

parent 9c23ef92
......@@ -650,6 +650,9 @@ int load_cxf (Luz *luz, char *path)
float wavelength, prev_wavelength;
float start_wl = 380.0;
float increment = 10.0;
int got_rgb = 0, got_lab = 0, got_xyz = 0;
XmlState state = IN_NONE;
LuzString *colorsetname = luz_string_new ("");
......@@ -677,16 +680,24 @@ int load_cxf (Luz *luz, char *path)
case t_word:
switch (state)
{
case IN_XYZ_X_TAG: xyz[0] = strtod (data, NULL); break;
case IN_XYZ_Y_TAG: xyz[1] = strtod (data, NULL); break;
case IN_XYZ_Z_TAG: xyz[2] = strtod (data, NULL); break;
case IN_XYZ_X_TAG: xyz[0] = strtod (data, NULL);
break;
case IN_XYZ_Y_TAG: xyz[1] = strtod (data, NULL);
break;
case IN_XYZ_Z_TAG: xyz[2] = strtod (data, NULL);
got_xyz = 1;
break;
case IN_LAB_L_TAG: lab[0] = strtod (data, NULL); break;
case IN_LAB_A_TAG: lab[1] = strtod (data, NULL); break;
case IN_LAB_B_TAG: lab[2] = strtod (data, NULL); break;
case IN_LAB_B_TAG: lab[2] = strtod (data, NULL); got_lab=1;break;
case IN_SRGB_RED_TAG: srgb[0] = strtod (data, NULL); break;
case IN_SRGB_GREEN_TAG: srgb[1] = strtod (data, NULL); break;
case IN_SRGB_BLUE_TAG: srgb[2] = strtod (data, NULL); break;
case IN_SRGB_BLUE_TAG: srgb[2] = strtod (data, NULL); got_rgb=1;break;
case IN_REFLECTANCE_POINT_TAG: /* XXX: tune */
spectrum[0] = strtod (data, NULL); break;
case IN_REFLECTANCE_SPECTRUM_TAG: /* XXX: tune */
......@@ -711,7 +722,10 @@ int load_cxf (Luz *luz, char *path)
fprintf (stderr, "tag: %s ", data);
if (has_suffix (data, ":Color")) state = IN_NONE;
if (has_suffix (data, ":Color")) {
state = IN_NONE;
got_lab = got_rgb = got_xyz = 0;
}
else if (has_suffix (data, ":ColorSpaceCIEXYZ")) state = IN_XYZ_TAG;
else if (has_suffix (data, ":X")) state = IN_XYZ_X_TAG;
else if (has_suffix (data, ":Y")) state = IN_XYZ_Y_TAG;
......@@ -733,22 +747,35 @@ int load_cxf (Luz *luz, char *path)
break;
case t_closetag:
if (!strcmp (data, "CxF:Color"))
if (has_suffix (data, ":ColorSpaceSpectral"))
{
fprintf (stderr, "YEYPYEP! %s %f %f %f %f %f %f\n", colorname->str,
lab[0],
lab[1],
lab[2],
srgb[0],
srgb[1],
srgb[2]);
coloritto_set_name (
add_item (luz, COLORITTO_LAB, &lab[0], 0.005),
colorname->str);
fprintf (stderr, "fnord! [%s]\n", reflectance_spectrum->str);
}
if (has_suffix (data, ":ReflectanceSpectrum"))
{
fprintf (stderr, "fnord2! [%s]\n", reflectance_spectrum->str);
}
if (has_suffix (data, ":Color"))
{
if (got_lab)
coloritto_set_name (
add_item (luz, COLORITTO_LAB, &lab[0], 0.005),
colorname->str);
else if (got_rgb)
coloritto_set_name (
add_item (luz, COLORITTO_SRGB, &srgb[0], 0.005),
colorname->str);
else if (got_xyz)
coloritto_set_name (
add_item (luz, COLORITTO_XYZ, &xyz[0], 0.005),
colorname->str);
else
{
fprintf (stderr, "unhandled foo\n");
}
}
state = IN_NONE;
break;
......@@ -760,7 +787,14 @@ int load_cxf (Luz *luz, char *path)
break;
case t_val:
{
if (!strcmp ("ColorName", attname->str))
if (!strcmp ("Name", attname->str))
{
luz_string_set (colorname, data);
luz_string_set (attname, "");
luz_string_set (reflectance_spectrum, "");
}
else if (!strcmp ("ColorName", attname->str))
{
luz_string_set (colorname, data);
luz_string_set (attname, "");
......
......@@ -265,6 +265,7 @@ spectrum_to_rgb (Luz *luz,
{
float xyz[3];
spectrum_to_xyz (luz, observed, &xyz[0], &xyz[1], &xyz[2]);
/* use babl instead */
rgb[0] = xyz[0] * 3.134274799724 +
xyz[1] * -1.617275708956 +
xyz[2] * -0.490724283042;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment