On 04/13/2013 09:38 AM, Jesper Pedersen wrote:
Ah, much better - thanks Daniel !
Rebased, but not squashed such that you can see the delta in 0002.
I added a keyboard shortcut 'h' as a toggle.
Actually, probably better with a global setting instead of per image.
Best regards,
Jesper
>From 6c582d5575845c2bd0f33df12c1536bc47599dc2 Mon Sep 17 00:00:00 2001
From: Jesper Pedersen <jesper.peder...@comcast.net>
Date: Sat, 13 Apr 2013 11:37:53 -0400
Subject: [PATCH 3/3] Histogram linear should be global
---
src/frontend/entangle-image-histogram.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/src/frontend/entangle-image-histogram.c b/src/frontend/entangle-image-histogram.c
index c62cab6..fceefe9 100644
--- a/src/frontend/entangle-image-histogram.c
+++ b/src/frontend/entangle-image-histogram.c
@@ -30,12 +30,13 @@
#define ENTANGLE_IMAGE_HISTOGRAM_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), ENTANGLE_TYPE_IMAGE_HISTOGRAM, EntangleImageHistogramPrivate))
+static gboolean use_linear;
+
struct _EntangleImageHistogramPrivate {
double freq_red[255];
double freq_green[255];
double freq_blue[255];
gboolean hasFreq;
- gboolean linear;
gulong imageNotifyID;
EntangleImage *image;
};
@@ -169,9 +170,9 @@ static void entangle_image_histogram_draw_grid(cairo_t *cr, const float width, c
}
-static double entangle_image_histogram_calculate_value(double d, gboolean l)
+static double entangle_image_histogram_calculate_value(double d)
{
- if (!l) {
+ if (!use_linear) {
return DOUBLE_EQUAL(d, 0.0) ? 0.0 : log(d);
}
@@ -208,9 +209,9 @@ static gboolean entangle_image_histogram_draw(GtkWidget *widget, cairo_t *cr)
if (priv->hasFreq) {
for (idx = 0 ; idx < 255 ; idx++) {
- double rv = entangle_image_histogram_calculate_value(priv->freq_red[idx], priv->linear);
- double gv = entangle_image_histogram_calculate_value(priv->freq_green[idx], priv->linear);
- double bv = entangle_image_histogram_calculate_value(priv->freq_blue[idx], priv->linear);
+ double rv = entangle_image_histogram_calculate_value(priv->freq_red[idx]);
+ double gv = entangle_image_histogram_calculate_value(priv->freq_green[idx]);
+ double bv = entangle_image_histogram_calculate_value(priv->freq_blue[idx]);
if (rv > peak)
peak = rv;
@@ -230,7 +231,7 @@ static gboolean entangle_image_histogram_draw(GtkWidget *widget, cairo_t *cr)
cairo_move_to(cr, 0, wh);
for (idx = 0 ; idx < 255 ; idx++) {
- double rv = entangle_image_histogram_calculate_value(priv->freq_red[idx], priv->linear);
+ double rv = entangle_image_histogram_calculate_value(priv->freq_red[idx]);
double x = (double)ww * (double)idx / 255.0;
double y = (double)(wh - 2) * (double)rv / peak;
@@ -247,7 +248,7 @@ static gboolean entangle_image_histogram_draw(GtkWidget *widget, cairo_t *cr)
cairo_move_to(cr, 0, wh);
for (idx = 0 ; idx < 255 ; idx++) {
- double gv = entangle_image_histogram_calculate_value(priv->freq_green[idx], priv->linear);
+ double gv = entangle_image_histogram_calculate_value(priv->freq_green[idx]);
double x = (double)ww * (double)idx / 255.0;
double y = (double)(wh - 2) * (double)gv / peak;
@@ -264,7 +265,7 @@ static gboolean entangle_image_histogram_draw(GtkWidget *widget, cairo_t *cr)
cairo_move_to(cr, 0, wh);
for (idx = 0 ; idx < 255 ; idx++) {
- double bv = entangle_image_histogram_calculate_value(priv->freq_blue[idx], priv->linear);
+ double bv = entangle_image_histogram_calculate_value(priv->freq_blue[idx]);
double x = (double)ww * (double)idx / 255.0;
double y = (double)(wh - 2) * (double)bv / peak;
@@ -404,11 +405,11 @@ void entangle_image_histogram_set_histogram_linear(EntangleImageHistogram *histo
{
g_return_if_fail(ENTANGLE_IS_IMAGE_HISTOGRAM(histogram));
- EntangleImageHistogramPrivate *priv = histogram->priv;
-
- priv->linear = linear;
+ gboolean old_use_linear = use_linear;
+ use_linear = linear;
- gtk_widget_queue_draw(GTK_WIDGET(histogram));
+ if (old_use_linear != use_linear)
+ gtk_widget_queue_draw(GTK_WIDGET(histogram));
}
@@ -416,9 +417,7 @@ gboolean entangle_image_histogram_get_histogram_linear(EntangleImageHistogram *h
{
g_return_val_if_fail(ENTANGLE_IS_IMAGE_HISTOGRAM(histogram), FALSE);
- EntangleImageHistogramPrivate *priv = histogram->priv;
-
- return priv->linear;
+ return use_linear;
}
/*
--
1.8.1.4
_______________________________________________
Entangle-devel mailing list
Entangle-devel@gna.org
https://mail.gna.org/listinfo/entangle-devel