Author: post
Date: 2010-10-17 16:16:25 +0200 (Sun, 17 Oct 2010)
New Revision: 3570
Modified:
trunk/src/rs-histogram.c
trunk/src/rs-histogram.h
trunk/src/rs-preview-widget.c
trunk/src/rs-toolbox.c
trunk/src/rs-toolbox.h
Log:
Add current RGB values to histogram.
Modified: trunk/src/rs-histogram.c
===================================================================
--- trunk/src/rs-histogram.c 2010-10-17 12:42:56 UTC (rev 3569)
+++ trunk/src/rs-histogram.c 2010-10-17 14:16:25 UTC (rev 3570)
@@ -34,6 +34,7 @@
RSSettings *settings;
guint input_samples[4][256];
guint *output_samples[4];
+ gfloat rgb_values[3];
RSColorSpace *display_color_space;
};
@@ -74,6 +75,9 @@
hist->input = NULL;
hist->settings = NULL;
hist->blitter = NULL;
+ hist->rgb_values[0] = -1;
+ hist->rgb_values[1] = -1;
+ hist->rgb_values[2] = -1;
g_signal_connect(G_OBJECT(hist), "size-allocate",
G_CALLBACK(size_allocate), NULL);
}
@@ -127,7 +131,7 @@
* @param input An input RSFilter
*/
void
-rs_histogram_set_input(RSHistogramWidget *histogram, RSFilter* input,
RSColorSpace *display_color_space)
+rs_histogram_set_input(RSHistogramWidget* histogram, RSFilter* input,
RSColorSpace* display_color_space)
{
g_return_if_fail (RS_IS_HISTOGRAM_WIDGET(histogram));
g_return_if_fail (RS_IS_FILTER(input));
@@ -138,6 +142,25 @@
rs_histogram_redraw(histogram);
}
+void
+rs_histogram_set_highlight(RSHistogramWidget *histogram, const guchar*
rgb_values)
+{
+ g_return_if_fail (RS_IS_HISTOGRAM_WIDGET(histogram));
+ if (rgb_values)
+ {
+ histogram->rgb_values[0] = (float)rgb_values[0]/255.0f;
+ histogram->rgb_values[1] = (float)rgb_values[1]/255.0f;
+ histogram->rgb_values[2] = (float)rgb_values[2]/255.0f;
+ }
+ else
+ {
+ histogram->rgb_values[0] = -1;
+ histogram->rgb_values[1] = -1;
+ histogram->rgb_values[2] = -1;
+ }
+ rs_histogram_redraw(histogram);
+}
+
#define LUM_PRECISION 15
#define LUM_FIXED(a) ((guint)((a)*(1<<LUM_PRECISION)))
#define RLUMF LUM_FIXED(0.212671f)
@@ -204,7 +227,14 @@
GdkDrawable *window;
GtkWidget *widget;
GdkGC *gc;
+ gint current[4];
+ current[0] = (int)(histogram->rgb_values[0] * histogram->width);
+ current[1] = (int)(histogram->rgb_values[1] * histogram->width);
+ current[2] = (int)(histogram->rgb_values[2] * histogram->width);
+ gfloat lum = 0.212671f * histogram->rgb_values[0] + 0.715160f *
histogram->rgb_values[1] + 0.072169f * histogram->rgb_values[2];
+ current[3] = (int)(lum*histogram->width);
+ g_debug("0:%d 1:%d 2:%d,
3:%d",current[0],current[1],current[2],current[3]);
g_return_if_fail (RS_IS_HISTOGRAM_WIDGET(histogram));
widget = GTK_WIDGET(histogram);
@@ -308,6 +338,31 @@
cairo_line_to(cr, x, histogram->height);
cairo_fill (cr);
+ for (c = 0; c < 4; c++)
+ {
+ if (current[c] >= 0 && current[c] < histogram->width)
+ {
+ switch (c)
+ {
+ case 0:
+ cairo_set_source_rgba(cr, 1.0,
0.0, 0.0, 0.2);
+ break;
+ case 1:
+ cairo_set_source_rgba(cr, 0.0,
1.0, 0.0, 0.3);
+ break;
+ case 2:
+ cairo_set_source_rgba(cr, 0.0,
0.0, 1.0, 0.2);
+ break;
+ case 3:
+ cairo_set_source_rgba(cr, 1.0,
1.0, 1.0, 0.4);
+ break;
+ }
+ cairo_move_to (cr,
current[c],(histogram->height-1)-histogram->output_samples[c][current[c]]/factor);
+ cairo_line_to(cr, current[c],0);
+ cairo_stroke (cr);
+ }
+ }
+
/* We're done */
cairo_destroy (cr);
#else /* GTK_CHECK_VERSION(2,8,0) */
@@ -357,6 +412,7 @@
for (x = 0; x < histogram->width; x++)
points[x].y =
(histogram->height-1)-histogram->output_samples[3][x]/factor;
gdk_draw_lines(histogram->blitter, gc, points,
histogram->width);
+
#endif /* GTK_CHECK_VERSION(2,8,0) */
/* Blit to screen */
Modified: trunk/src/rs-histogram.h
===================================================================
--- trunk/src/rs-histogram.h 2010-10-17 12:42:56 UTC (rev 3569)
+++ trunk/src/rs-histogram.h 2010-10-17 14:16:25 UTC (rev 3570)
@@ -41,6 +41,7 @@
*/
extern void rs_histogram_set_input(RSHistogramWidget *histogram, RSFilter*
input, RSColorSpace *display_color_space);
+extern void rs_histogram_set_highlight(RSHistogramWidget *histogram, const
guchar* rgb_values);
/**
* Redraw a RSHistogramWidget
Modified: trunk/src/rs-preview-widget.c
===================================================================
--- trunk/src/rs-preview-widget.c 2010-10-17 12:42:56 UTC (rev 3569)
+++ trunk/src/rs-preview-widget.c 2010-10-17 14:16:25 UTC (rev 3570)
@@ -441,7 +441,6 @@
preview->toolbox = RS_TOOLBOX(toolbox);
rs_toolbox_set_histogram_input(preview->toolbox,
preview->navigator_filter_end, preview->display_color_space);
-
return widget;
}
@@ -2222,7 +2221,10 @@
{
RS_PREVIEW_CALLBACK_DATA cbdata;
if (make_cbdata(preview, view, &cbdata, scaled_x, scaled_y,
real_x, real_y))
+ {
g_signal_emit (G_OBJECT (preview),
signals[MOTION_SIGNAL], 0, &cbdata);
+ rs_toolbox_hover_value_updated(preview->toolbox,
cbdata.pixel8);
+ }
}
/* Check not to generate superfluous signals "leave"*/
@@ -2233,7 +2235,10 @@
{
RS_PREVIEW_CALLBACK_DATA cbdata;
if (make_cbdata(preview, view, &cbdata, scaled_x,
scaled_y, real_x, real_y))
+ {
g_signal_emit (G_OBJECT (preview),
signals[LEAVE_SIGNAL], 0, &cbdata);
+
rs_toolbox_hover_value_updated(preview->toolbox, NULL);
+ }
}
}
@@ -2241,6 +2246,7 @@
if (preview->loupe_enabled)
rs_loupe_set_coord(preview->loupe, real_x, real_y);
+
return TRUE;
}
Modified: trunk/src/rs-toolbox.c
===================================================================
--- trunk/src/rs-toolbox.c 2010-10-17 12:42:56 UTC (rev 3569)
+++ trunk/src/rs-toolbox.c 2010-10-17 14:16:25 UTC (rev 3570)
@@ -1162,3 +1162,10 @@
rs_core_action_group_add_radio_actions(select_snapshot,
n_select_snapshot, 0, G_CALLBACK(action_changed), toolbox);
rs_core_action_group_add_actions(actionentries, n_actionentries,
toolbox);
}
+
+extern void
+rs_toolbox_hover_value_updated(RSToolbox *toolbox, const guchar *rgb_value)
+{
+ g_assert(RS_IS_TOOLBOX(toolbox));
+ rs_histogram_set_highlight(RS_HISTOGRAM_WIDGET(toolbox->histogram),
rgb_value);
+}
Modified: trunk/src/rs-toolbox.h
===================================================================
--- trunk/src/rs-toolbox.h 2010-10-17 12:42:56 UTC (rev 3569)
+++ trunk/src/rs-toolbox.h 2010-10-17 14:16:25 UTC (rev 3570)
@@ -65,6 +65,10 @@
extern void
rs_toolbox_register_actions(RSToolbox *toolbox);
+extern void
+rs_toolbox_hover_value_updated(RSToolbox *toolbox, const guchar *rgb_value);
+
+
G_END_DECLS
#endif /* RS_TOOLBOX_H */
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit