Mercurial > geeqie
changeset 1477:29aa897ea540
fixed histogram drawing
author | nadvornik |
---|---|
date | Thu, 26 Mar 2009 07:56:01 +0000 |
parents | ad31222ffb20 |
children | 3cc98d5c6907 |
files | src/histogram.c src/histogram.h |
diffstat | 2 files changed, 21 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/histogram.c Mon Mar 23 18:49:23 2009 +0000 +++ b/src/histogram.c Thu Mar 26 07:56:01 2009 +0000 @@ -280,11 +280,13 @@ histogram_vgrid(histogram, pixbuf, x, y, width, height); histogram_hgrid(histogram, pixbuf, x, y, width, height); - for (i = 0; i < HISTMAP_SIZE; i++) + /* exclude overexposed and underexposed */ + for (i = 1; i < HISTMAP_SIZE - 1; i++) { if (histmap->r[i] > max) max = histmap->r[i]; if (histmap->g[i] > max) max = histmap->g[i]; if (histmap->b[i] > max) max = histmap->b[i]; + if (histmap->max[i] > max) max = histmap->max[i]; } if (max > 0) @@ -301,6 +303,7 @@ gint bplus = 0; gint ii = i * HISTMAP_SIZE / width; gint xpos = x + i; + gint num_chan; for (j = 0; j < combine; j++) { @@ -314,15 +317,21 @@ for (j = 0; combine > 1 && j < 4; j++) v[j] /= combine; - for (j = 0; j < 4; j++) + num_chan = (histogram->histogram_channel == HCHAN_RGB) ? 3 : 1; + for (j = 0; j < num_chan; j++) { - gint chanmax = HCHAN_R; - - if (v[HCHAN_G] > v[HCHAN_R]) chanmax = HCHAN_G; - if (v[HCHAN_B] > v[HCHAN_G]) chanmax = HCHAN_B; - - if (histogram->histogram_channel >= HCHAN_RGB - || chanmax == histogram->histogram_channel) + gint chanmax; + if (histogram->histogram_channel == HCHAN_RGB) + { + chanmax = HCHAN_R; + if (v[HCHAN_G] > v[HCHAN_R]) chanmax = HCHAN_G; + if (v[HCHAN_B] > v[chanmax]) chanmax = HCHAN_B; + } + else + { + chanmax = histogram->histogram_channel; + } + { gulong pt; gint r = rplus;
--- a/src/histogram.h Mon Mar 23 18:49:23 2009 +0000 +++ b/src/histogram.h Thu Mar 26 07:56:01 2009 +0000 @@ -17,9 +17,9 @@ #define HCHAN_R 0 #define HCHAN_G 1 #define HCHAN_B 2 -#define HCHAN_RGB 3 -#define HCHAN_MAX 4 -#define HCHAN_COUNT (HCHAN_MAX+1) +#define HCHAN_MAX 3 +#define HCHAN_RGB 4 +#define HCHAN_COUNT 5 Histogram *histogram_new(void);