add control over printed colorspaces

parent 7d30dd51
......@@ -1620,6 +1620,8 @@ coloritto_set_display_icc (const char *icc_data, int icc_length)
display_rgbf = babl_format_with_space ("R'G'B' float", display_space);
}
ColorittoDef print_spaces = 0;
char *
coloritto_collection_to_text (ColorittoCollection *cc)
{
......@@ -1647,25 +1649,34 @@ coloritto_collection_to_text (ColorittoCollection *cc)
}
mrg_string_append_printf (str, "\n");
#define colcond(col) \
((print_spaces & col) || \
((!print_spaces || (print_spaces & COLORITTO_SET))\
&& coloritto_is_set (color, col)))
if (coloritto_is_set (color, COLORITTO_LAB))
if colcond(COLORITTO_LAB)
{
coloritto_ensure (color, COLORITTO_LAB);
mrg_string_append_printf (str, " CIE Lab : %2.3f %2.3f %2.3f\n", color->lab[0], color->lab[1], color->lab[2]);
}
if (coloritto_is_set (color, COLORITTO_XYZ))
if colcond(COLORITTO_XYZ)
{
coloritto_ensure (color, COLORITTO_XYZ);
mrg_string_append_printf (str, " CIE XYZ : %2.3f %2.3f %2.3f\n", color->xyz[0], color->xyz[1], color->xyz[2]);
}
if (coloritto_is_set (color, COLORITTO_LCH))
if colcond(COLORITTO_LCH)
{
mrg_string_append_printf (str, " CIE LCH : %2.3f %2.3f %2.3f\n", color->lch[0], color->lch[1], color->lch[2]);
coloritto_ensure (color, COLORITTO_LCH);
mrg_string_append_printf (str, " CIE HLC : %2.3f %2.3f %2.3f\n", color->lch[2], color->lch[0], color->lch[1]);
}
if (coloritto_is_set (color, COLORITTO_xyY))
if colcond(COLORITTO_xyY)
{
coloritto_ensure (color, COLORITTO_xyY);
mrg_string_append_printf (str, " CIE xyY : %2.3f %2.3f %2.3f\n", color->xyY[0], color->xyY[1], color->xyY[2]);
}
if (coloritto_is_set (color, COLORITTO_SRGB))
if colcond(COLORITTO_SRGB)
{
coloritto_ensure (color, COLORITTO_SRGB);
mrg_string_append_printf (str, " sRGB : %2.0f %2.0f %2.0f\n", round(color->srgb[0]*255), round(color->srgb[1]*255), round(color->srgb[2]*255));
}
......@@ -1679,6 +1690,50 @@ int use_ui = 0;
MrgList *palettes = NULL;
static void parse_args (int argc, char **argv)
{
for (int i = 1; argv[i]; i++)
{
if (!strcmp (argv[i], "--ui")) use_ui = 1;
else if (!strcmp (argv[i], "-ui")) use_ui = 1;
else if (!strcmp (argv[i], "-c")){
if (!argv[i+1] || argv[i+1][0]=='-')
{
fprintf (stderr, "expected argument after -c\n");
exit (-1);
}
i++;
if (!strcmp (argv[i], "srgb"))
print_spaces |= COLORITTO_SRGB;
if (!strcmp (argv[i], "xyz"))
print_spaces |= COLORITTO_XYZ;
if (!strcmp (argv[i], "xyY"))
print_spaces |= COLORITTO_xyY;
if (!strcmp (argv[i], "lab"))
print_spaces |= COLORITTO_LAB;
if (!strcmp (argv[i], "lch"))
print_spaces |= COLORITTO_LCH;
if (!strcmp (argv[i], "set"))
print_spaces |= COLORITTO_SET;
}
else if (argv[i][0]=='-')
{
fprintf (stderr, "unknown option '%s'\n", argv[i]);
exit (-1);
}
else
{
ColorittoCollection *cc =
coloritto_collection_new_from_cxf_path (argv[i]);
if (cc)
mrg_list_append (&palettes, cc);
}
}
}
int
main (int argc, char **argv)
{
......@@ -1690,11 +1745,7 @@ main (int argc, char **argv)
display_rgbf = babl_format ("R'G'B' float");
for (int i = 1; argv[i]; i++)
{
if (!strcmp (argv[i], "--ui")) use_ui = 1;
if (!strcmp (argv[i], "-ui")) use_ui = 1;
}
parse_args (argc, argv);
if (use_ui)
{
......@@ -1707,29 +1758,7 @@ main (int argc, char **argv)
profile = (void*)mrg_get_profile (mrg, &length);
if (profile)
coloritto_set_display_icc (profile, length);
}
for (int i = 1; argv[i]; i++)
{
if (argv[i][0] != '-')
{
if (has_suffix (argv[i], ".txt"))
;//load_txt (luz, argv[i], i == 1);
else
{
ColorittoCollection *cc =
coloritto_collection_new_from_cxf_path (argv[1]);
if (cc)
mrg_list_append (&palettes, cc);
}
}
}
if (palette)
mrg_list_reverse (&palette);
if (use_ui)
{
mrg_set_ui (mrg, ui, NULL);
mrg_main (mrg);
}
......
......@@ -13,6 +13,9 @@ typedef enum ColorittoDef {
COLORITTO_SPECTRUM_ON_WHITE_RAMP = 1 << 8,
COLORITTO_SPECTRUM_ON_WHITE_AND_BLACK = 1 << 9,
COLORITTO_SPECTRUM_ON_WHITE_AND_BLACK_RAMP = 1 << 10,
COLORITTO_SET = 1 << 20,
} ColorittoDef;
typedef struct _Coloritto Coloritto;
......
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