Skip to content
Browse files

module colorout: add functionality for gamut checking

  • Loading branch information...
1 parent 192f299 commit b39016e3f5efcde0845afc524e4c2a8dc2d2b465 @upegelow upegelow committed
Showing with 88 additions and 19 deletions.
  1. +78 −17 src/iop/colorout.c
  2. +10 −2 src/iop/colorout.h
View
95 src/iop/colorout.c
@@ -70,8 +70,44 @@ static gboolean key_softproof_callback(GtkAccelGroup *accel_group,
dt_iop_colorout_gui_data_t *g = (dt_iop_colorout_gui_data_t *)self->gui_data;
dt_iop_colorout_params_t *p = (dt_iop_colorout_params_t *)self->params;
- /* toggle softproofing on/off */
- g->softproof_enabled = p->softproof_enabled = !p->softproof_enabled;
+ if(p->softproof_enabled == DT_SOFTPROOF_ENABLED)
+ p->softproof_enabled = DT_SOFTPROOF_DISABLED;
+ else
+ p->softproof_enabled = DT_SOFTPROOF_ENABLED;
+
+ g->softproof_enabled = p->softproof_enabled;
+
+ if(p->softproof_enabled)
+ {
+ int pos = dt_bauhaus_combobox_get(g->cbox5);
+ gchar *filename = _get_profile_from_pos(g->profiles, pos);
+ if (filename)
+ g_strlcpy(p->softproofprofile, filename, sizeof(p->softproofprofile));
+ }
+
+ dt_dev_add_history_item(darktable.develop, self, TRUE);
+ dt_control_queue_redraw_center();
+ return TRUE;
+}
+
+
+static gboolean key_gamutcheck_callback(GtkAccelGroup *accel_group,
+ GObject *acceleratable,
+ guint keyval, GdkModifierType modifier,
+ gpointer data)
+{
+ dt_iop_module_t* self = (dt_iop_module_t*)data;
+ dt_iop_colorout_gui_data_t *g = (dt_iop_colorout_gui_data_t *)self->gui_data;
+ dt_iop_colorout_params_t *p = (dt_iop_colorout_params_t *)self->params;
+
+
+ if(p->softproof_enabled == DT_SOFTPROOF_GAMUTCHECK)
+ p->softproof_enabled = DT_SOFTPROOF_DISABLED;
+ else
+ p->softproof_enabled = DT_SOFTPROOF_GAMUTCHECK;
+
+ g->softproof_enabled = p->softproof_enabled;
+
if(p->softproof_enabled)
{
int pos = dt_bauhaus_combobox_get(g->cbox5);
@@ -85,6 +121,8 @@ static gboolean key_softproof_callback(GtkAccelGroup *accel_group,
return TRUE;
}
+
+
int
legacy_params (dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
{
@@ -101,7 +139,7 @@ legacy_params (dt_iop_module_t *self, const void *const old_params, const int ol
dt_iop_colorout_params_t *o = (dt_iop_colorout_params_t *)old_params;
dt_iop_colorout_params_t *n = (dt_iop_colorout_params_t *)new_params;
memcpy(n,o,sizeof(dt_iop_colorout_params_t));
- n->softproof_enabled = 0;
+ n->softproof_enabled = DT_SOFTPROOF_DISABLED;
n->softproofintent = 0;
g_strlcpy(n->softproofprofile,"sRGB",sizeof(n->softproofprofile));
return 0;
@@ -335,6 +373,7 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi
{
const dt_iop_colorout_data_t *const d = (dt_iop_colorout_data_t *)piece->data;
const int ch = piece->colors;
+ const int gamutcheck = (d->softproof_enabled == DT_SOFTPROOF_GAMUTCHECK);
if(!isnan(d->cmatrix[0]))
{
@@ -410,9 +449,18 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi
for (int l=0; l<roi_out->width; l++)
{
int oi=ch*l, ri=3*l;
- out[m+oi+0] = rgb[ri+0];
- out[m+oi+1] = rgb[ri+1];
- out[m+oi+2] = rgb[ri+2];
+ if(gamutcheck && (rgb[ri+0] < 0.0f || rgb[ri+1] < 0.0f || rgb[ri+2] < 0.0f))
+ {
+ out[m+oi+0] = 0.0f;
+ out[m+oi+1] = 1.0f;
+ out[m+oi+2] = 1.0f;
+ }
+ else
+ {
+ out[m+oi+0] = rgb[ri+0];
+ out[m+oi+1] = rgb[ri+1];
+ out[m+oi+2] = rgb[ri+2];
+ }
}
}
}
@@ -515,22 +563,26 @@ void commit_params (struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pi
outintent = p->displayintent;
}
+ /*
+ * Setup transform flags
+ */
+ uint32_t transformFlags = 0;
+
/* creating output profile */
d->output = _create_profile(outprofile);
/* creating softproof profile if softproof is enabled */
if (d->softproof_enabled)
+ {
d->softproof = _create_profile(p->softproofprofile);
- /*
- * Setup transform flags
- */
- uint32_t transformFlags = 0;
+ /* TODO: the use of bpc should be userconfigurable either from module or preference pane */
+ /* softproof flag and black point compensation */
+ transformFlags |= cmsFLAGS_SOFTPROOFING|cmsFLAGS_NOCACHE|cmsFLAGS_BLACKPOINTCOMPENSATION;
- /* TODO: the use of bpc should be userconfigurable either from module or preference pane */
- /* softproof flag and black point compensation */
- transformFlags |= (d->softproof_enabled ? cmsFLAGS_SOFTPROOFING|cmsFLAGS_NOCACHE|cmsFLAGS_BLACKPOINTCOMPENSATION : 0);
-
+ if(d->softproof_enabled == DT_SOFTPROOF_GAMUTCHECK)
+ transformFlags |= cmsFLAGS_GAMUTCHECK;
+ }
/* get matrix from profile, if softproofing or high quality exporting always go xform codepath */
@@ -691,14 +743,14 @@ void gui_post_expose (struct dt_iop_module_t *self, cairo_t *cr, int32_t width,
dt_iop_colorout_gui_data_t *g = (dt_iop_colorout_gui_data_t *)self->gui_data;
if(g->softproof_enabled)
{
- gchar *label=_("soft proof");
+ gchar *label= g->softproof_enabled == DT_SOFTPROOF_GAMUTCHECK ? _("gamut check") : _("soft proof");
cairo_set_source_rgba(cr,0.5,0.5,0.5,0.5);
cairo_text_extents_t te;
cairo_select_font_face (cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 20);
cairo_text_extents (cr, label, &te);
cairo_move_to (cr, te.height*2, height-(te.height*2));
- cairo_text_path (cr, _("soft proof"));
+ cairo_text_path (cr, label);
cairo_set_source_rgb(cr, 0.7, 0.7, 0.7);
cairo_fill_preserve(cr);
cairo_set_line_width(cr, 0.7);
@@ -883,14 +935,23 @@ void init_key_accels(dt_iop_module_so_t *self)
{
dt_accel_register_iop(self, FALSE, NC_("accel", "toggle softproofing"),
GDK_s, 0);
+
+ dt_accel_register_iop(self, FALSE, NC_("accel", "toggle gamutcheck"),
+ GDK_g, 0);
}
void connect_key_accels(dt_iop_module_t *self)
{
- GClosure *closure = g_cclosure_new(G_CALLBACK(key_softproof_callback),
+ GClosure *closure;
+
+ closure = g_cclosure_new(G_CALLBACK(key_softproof_callback),
(gpointer)self, NULL);
dt_accel_connect_iop(self, "toggle softproofing", closure);
+ closure = g_cclosure_new(G_CALLBACK(key_gamutcheck_callback),
+ (gpointer)self, NULL);
+ dt_accel_connect_iop(self, "toggle gamutcheck", closure);
+
}
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
View
12 src/iop/colorout.h
@@ -24,6 +24,14 @@
#include <gtk/gtk.h>
#include <inttypes.h>
+typedef enum dt_iop_colorout_softproof_t
+{
+ DT_SOFTPROOF_DISABLED = 0,
+ DT_SOFTPROOF_ENABLED = 1,
+ DT_SOFTPROOF_GAMUTCHECK = 2
+}
+dt_iop_colorout_softproof_t;
+
typedef struct dt_iop_colorout_global_data_t
{
int kernel_colorout;
@@ -46,7 +54,7 @@ dt_iop_colorout_params_t;
typedef struct dt_iop_colorout_gui_data_t
{
- gboolean softproof_enabled;
+ gint softproof_enabled;
GtkWidget *cbox1, *cbox2, *cbox3, *cbox4,*cbox5;
GList *profiles;
@@ -55,7 +63,7 @@ dt_iop_colorout_gui_data_t;
typedef struct dt_iop_colorout_data_t
{
- gboolean softproof_enabled;
+ gint softproof_enabled;
float lut[3][LUT_SAMPLES];
float cmatrix[9];
cmsHPROFILE softproof;

0 comments on commit b39016e

Please sign in to comment.
Something went wrong with that request. Please try again.