70#define DT_COLORCORRECTION_INSET DT_PIXEL_APPLY_DPI(5)
71#define DT_COLORCORRECTION_MAX 40.
100 return _(
"color correction");
106 _(
"corrective or creative"),
107 _(
"non-linear, Lab, display-referred"),
108 _(
"non-linear, Lab"),
109 _(
"non-linear, Lab, display-referred"));
167 const float saturation =
d->saturation;
168 const float a_scale =
d->a_scale;
169 const float a_base =
d->a_base;
170 const float b_scale =
d->b_scale;
171 const float b_base =
d->b_base;
173 for(
size_t k = 0;
k < (size_t)4 * roi_out->
width * roi_out->
height;
k += 4)
176 out[
k+1] = saturation * (in[
k+1] + in[
k+0] * a_scale + a_base);
177 out[
k+2] = saturation * (in[
k+2] + in[
k+0] * b_scale + b_base);
192 const int devid = pipe->
devid;
208 if(err != CL_SUCCESS)
goto error;
221 const int program = 2;
242 d->a_scale = (
p->hia -
p->loa) / 100.0;
244 d->b_scale = (
p->hib -
p->lob) / 100.0;
246 d->saturation =
p->saturation;
266 gtk_widget_queue_draw(self->
widget);
288 g_object_set_data(G_OBJECT(
g->area),
"iop-instance", self);
289 gtk_box_pack_start(GTK_BOX(self->
widget), GTK_WIDGET(
g->area),
TRUE,
TRUE, 0);
290 gtk_widget_set_tooltip_text(GTK_WIDGET(
g->area), _(
"drag the line for split-toning. "
291 "bright means highlights, dark means shadows. "
292 "use mouse wheel to change saturation."));
295 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
296 | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
297 gtk_widget_set_can_focus(GTK_WIDGET(
g->area),
TRUE);
309 gtk_widget_set_tooltip_text(
g->slider, _(
"set the global saturation"));
313 g->xform = cmsCreateTransform(hLab, TYPE_Lab_DBL, hsRGB, TYPE_RGB_DBL, INTENT_PERCEPTUAL, 0);
319 cmsDeleteTransform(
g->xform);
331 GtkAllocation allocation;
332 gtk_widget_get_allocation(widget, &allocation);
333 int width = allocation.width,
height = allocation.height;
335 cairo_t *cr = cairo_create(cst);
337 cairo_set_source_rgb(cr, .2, .2, .2);
340 cairo_translate(cr, inset, inset);
341 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
345 cairo_translate(cr, 0,
height);
346 cairo_scale(cr, 1., -1.);
348 for(
int j = 0; j < cells; j++)
349 for(
int i = 0;
i < cells;
i++)
351 double rgb[3] = { 0.5, 0.5, 0.5 };
359 cmsDoTransform(
g->xform, &
Lab,
rgb, 1);
361 cairo_set_source_rgb(cr,
rgb[0],
rgb[1],
rgb[2]);
362 cairo_rectangle(cr,
width *
i / (
float)cells,
height * j / (
float)cells,
367 cairo_set_antialias(cr, CAIRO_ANTIALIAS_DEFAULT);
368 float loa, hia, lob, hib;
374 cairo_set_source_rgb(cr, 0.6, 0.6, 0.6);
375 cairo_move_to(cr, loa, lob);
376 cairo_line_to(cr, hia, hib);
379 cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
386 cairo_set_source_rgb(cr, 0.9, 0.9, 0.9);
394 cairo_set_source_surface(crf, cst, 0, 0);
396 cairo_surface_destroy(cst);
407 GtkAllocation allocation;
408 gtk_widget_get_allocation(widget, &allocation);
409 int width = allocation.width - 2 * inset,
height = allocation.height - 2 * inset;
410 const float mouse_x = CLAMP(event->x - inset, 0,
width);
411 const float mouse_y = CLAMP(
height - 1 - event->y + inset, 0,
height);
414 if(event->state & GDK_BUTTON1_MASK)
422 else if(
g->selected == 2)
433 const float distlo = (
p->loa - ma) * (
p->loa - ma) + (
p->lob - mb) * (
p->lob - mb);
434 const float disthi = (
p->hia - ma) * (
p->hia - ma) + (
p->hib - mb) * (
p->hib - mb);
435 if(distlo <
thrs *
thrs && distlo < disthi)
437 else if(disthi <
thrs *
thrs && disthi <= distlo)
440 if(
g->selected > 0) gtk_widget_grab_focus(widget);
441 gtk_widget_queue_draw(self->
widget);
448 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS)
457 p->loa =
p->lob = 0.0;
461 p->hia =
p->hib = 0.0;
467 memcpy(
p,
d,
sizeof(*
p));
480 gtk_widget_queue_draw(self->
widget);
493 p->saturation = CLAMP(
p->saturation - 0.1 * delta_y, -3.0, 3.0);
495 gtk_widget_queue_draw(widget);
501#define COLORCORRECTION_DEFAULT_STEP (0.5f)
508 if(
g->selected < 1)
return FALSE;
512 float dx = 0.0f, dy = 0.0f;
513 if(
key == GDK_KEY_Up)
518 else if(
key == GDK_KEY_Down)
523 else if(
key == GDK_KEY_Right)
528 else if(
key == GDK_KEY_Left)
534 if(!handled)
return FALSE;
549 gtk_widget_queue_draw(widget);
static void error(char *msg)
void dt_bauhaus_slider_set(GtkWidget *widget, float pos)
@ DEVELOP_BLEND_CS_RGB_DISPLAY
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
void commit_params(struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
const char ** description(struct dt_iop_module_t *self)
static gboolean dt_iop_colorcorrection_motion_notify(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
static gboolean dt_iop_colorcorrection_leave_notify(GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
static gboolean dt_iop_colorcorrection_button_press(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
void init_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void gui_update(struct dt_iop_module_t *self)
static gboolean dt_iop_colorcorrection_scrolled(GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
void gui_init(struct dt_iop_module_t *self)
#define DT_COLORCORRECTION_INSET
void cleanup_global(dt_iop_module_so_t *module)
#define COLORCORRECTION_DEFAULT_STEP
int default_colorspace(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
void gui_cleanup(struct dt_iop_module_t *self)
static gboolean dt_iop_colorcorrection_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
void init_presets(dt_iop_module_so_t *self)
__DT_CLONE_TARGETS__ int process(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const i, void *const o)
void cleanup_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void init_global(dt_iop_module_so_t *module)
static gboolean dt_iop_colorcorrection_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data)
int process_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
#define DT_COLORCORRECTION_MAX
const dt_colorspaces_color_profile_t * dt_colorspaces_get_profile(dt_colorspaces_color_profile_type_t type, const char *filename, dt_colorspaces_profile_direction_t direction)
@ DT_PROFILE_DIRECTION_IN
@ DT_PROFILE_DIRECTION_ANY
static dt_aligned_pixel_t rgb
static dt_aligned_pixel_t Lab
const dt_colormatrix_t dt_aligned_pixel_t out
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
void dt_print(dt_debug_thread_t thread, const char *msg,...)
#define dt_free_align(ptr)
static void * dt_calloc_align(size_t size)
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
#define __DT_CLONE_TARGETS__
#define __OMP_PARALLEL_FOR__(...)
#define dt_dev_add_history_item(dev, module, enable, redraw)
GtkWidget * dtgtk_drawing_area_new_with_aspect_ratio(double aspect)
static guint dt_keys_mainpad_alternatives(const guint key_val)
Remap keypad keys to usual mainpad ones.
gboolean dt_gui_get_scroll_unit_deltas(const GdkEventScroll *event, int *delta_x, int *delta_y)
static cairo_surface_t * dt_cairo_image_surface_create(cairo_format_t format, int width, int height)
#define DT_GUI_BOX_SPACING
#define DT_PIXEL_APPLY_DPI(value)
void dt_gui_presets_add_generic(const char *name, dt_dev_operation_t op, const int32_t version, const void *params, const int32_t params_size, const int32_t enabled, const dt_develop_blend_colorspace_t blend_cst)
const char ** dt_iop_set_description(dt_iop_module_t *module, const char *main_text, const char *purpose, const char *input, const char *process, const char *output)
@ IOP_FLAGS_INCLUDE_IN_STYLES
@ IOP_FLAGS_SUPPORTS_BLENDING
#define IOP_GUI_ALLOC(module)
GtkWidget * dt_bauhaus_slider_from_params(dt_iop_module_t *self, const char *param)
float *const restrict const size_t k
int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
int dt_opencl_create_kernel(const int prog, const char *name)
void dt_opencl_free_kernel(const int kernel)
int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg)
struct _GtkWidget GtkWidget
struct dt_gui_gtk_t * gui
struct dt_develop_t * develop
struct dt_iop_module_t *void * data
int kernel_colorcorrection
GModule *dt_dev_operation_t op
dt_iop_global_data_t * data
dt_iop_params_t * default_params
dt_iop_gui_data_t * gui_data
dt_iop_global_data_t * global_data
Region of interest passed through the pixelpipe.