annotate src/histogram.c @ 1306:c59358ba7ad1

French translation was updated.
author zas_
date Sat, 21 Feb 2009 18:28:53 +0000
parents edeb07e1da5d
children 2320339ca8be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
1 /*
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
2 * Geeqie
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1055
diff changeset
3 * Copyright (C) 2008 - 2009 The Geeqie Team
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
4 *
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
5 * Author: Vladimir Nadvornik
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
6 * based on a patch by Uwe Ohse
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
7 *
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
9 * Please read the included file COPYING for more information.
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
11 */
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
12
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 273
diff changeset
13 #include "main.h"
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
14 #include "histogram.h"
284
84c4618cd1cb Fix missing header files inclusions.
zas_
parents: 281
diff changeset
15
84c4618cd1cb Fix missing header files inclusions.
zas_
parents: 281
diff changeset
16 #include "pixbuf_util.h"
84c4618cd1cb Fix missing header files inclusions.
zas_
parents: 281
diff changeset
17
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
18 #include <math.h>
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
19
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
20 /*
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
21 *----------------------------------------------------------------------------
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
22 * image histogram
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
23 *----------------------------------------------------------------------------
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
24 */
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
25
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
26 #define HISTMAP_SIZE 256
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
27 typedef enum {
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
28 HISTMAP_CHANNEL_R = 0,
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
29 HISTMAP_CHANNEL_G,
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
30 HISTMAP_CHANNEL_B,
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
31 HISTMAP_CHANNEL_AVG,
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
32 HISTMAP_CHANNEL_MAX,
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
33 HISTMAP_CHANNELS
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
34 } HistMapChannels;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
35
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
36 struct _HistMap {
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
37 gulong histmap[HISTMAP_SIZE * HISTMAP_CHANNELS];
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
38 gulong area;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
39 };
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
40
290
4bbde8a38ad4 improved histogram drawing
nadvornik
parents: 287
diff changeset
41 struct _Histogram {
1304
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
42 gint channel_mode; /* drawing mode for histogram */
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
43 gint log_mode; /* logarithmical or not */
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
44 guint vgrid; /* number of vertical divisions, 0 for none */
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
45 guint hgrid; /* number of horizontal divisions, 0 for none */
1304
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
46 struct {
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
47 int R; /* red */
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
48 int G; /* green */
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
49 int B; /* blue */
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
50 int A; /* alpha */
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
51 } grid_color; /* grid color */
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
52
290
4bbde8a38ad4 improved histogram drawing
nadvornik
parents: 287
diff changeset
53 };
4bbde8a38ad4 improved histogram drawing
nadvornik
parents: 287
diff changeset
54
609
b690cecbf5b8 Use function(void) instead of function() for declaring functions which
zas_
parents: 475
diff changeset
55 Histogram *histogram_new(void)
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
56 {
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
57 Histogram *histogram;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
58
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
59 histogram = g_new0(Histogram, 1);
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
60 histogram->channel_mode = options->histogram.last_channel_mode;
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
61 histogram->log_mode = options->histogram.last_log_mode;
1304
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
62
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
63 /* grid */
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
64 histogram->vgrid = 5;
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
65 histogram->hgrid = 3;
1304
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
66 histogram->grid_color.R = 160;
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
67 histogram->grid_color.G = 160;
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
68 histogram->grid_color.B = 160;
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
69 histogram->grid_color.A = 250;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
70
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
71 return histogram;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
72 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
73
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
74 void histogram_free(Histogram *histogram)
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
75 {
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
76 g_free(histogram);
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
77 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
78
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
79
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
80 gint histogram_set_channel(Histogram *histogram, gint chan)
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
81 {
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
82 if (!histogram) return 0;
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
83 options->histogram.last_channel_mode = histogram->channel_mode = chan;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
84 return chan;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
85 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
86
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
87 gint histogram_get_channel(Histogram *histogram)
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
88 {
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
89 if (!histogram) return 0;
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
90 return histogram->channel_mode;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
91 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
92
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
93 gint histogram_set_mode(Histogram *histogram, gint mode)
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
94 {
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
95 if (!histogram) return 0;
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
96 options->histogram.last_log_mode = histogram->log_mode = mode;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
97 return mode;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
98 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
99
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
100 gint histogram_get_mode(Histogram *histogram)
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
101 {
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
102 if (!histogram) return 0;
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
103 return histogram->log_mode;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
104 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
105
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
106 const gchar *histogram_label(Histogram *histogram)
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
107 {
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
108 const gchar *t1 = "";
999
bbed8e9a5d33 Indentation fixes.
zas_
parents: 612
diff changeset
109
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
110 if (!histogram) return NULL;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
111
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
112 if (histogram->log_mode)
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
113 switch (histogram->channel_mode)
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
114 {
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
115 case HCHAN_R: t1 = _("logarithmical histogram on red"); break;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
116 case HCHAN_G: t1 = _("logarithmical histogram on green"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
117 case HCHAN_B: t1 = _("logarithmical histogram on blue"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
118 case HCHAN_VAL: t1 = _("logarithmical histogram on value"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
119 case HCHAN_RGB: t1 = _("logarithmical histogram on RGB"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
120 case HCHAN_MAX: t1 = _("logarithmical histogram on max value"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
121 }
999
bbed8e9a5d33 Indentation fixes.
zas_
parents: 612
diff changeset
122 else
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
123 switch (histogram->channel_mode)
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
124 {
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
125 case HCHAN_R: t1 = _("linear histogram on red"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
126 case HCHAN_G: t1 = _("linear histogram on green"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
127 case HCHAN_B: t1 = _("linear histogram on blue"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
128 case HCHAN_VAL: t1 = _("linear histogram on value"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
129 case HCHAN_RGB: t1 = _("linear histogram on RGB"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
130 case HCHAN_MAX: t1 = _("linear histogram on max value"); break;
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
131 }
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
132 return t1;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
133 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
134
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
135 static HistMap *histmap_read(GdkPixbuf *imgpixbuf)
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
136 {
462
6a2934cd0883 histogram_read(): speed up calculations by 20%.
zas_
parents: 461
diff changeset
137 gint w, h, i, j, srs, has_alpha, step;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
138 guchar *s_pix;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
139
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
140 HistMap *histmap;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
141
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
142 w = gdk_pixbuf_get_width(imgpixbuf);
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
143 h = gdk_pixbuf_get_height(imgpixbuf);
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
144 srs = gdk_pixbuf_get_rowstride(imgpixbuf);
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
145 s_pix = gdk_pixbuf_get_pixels(imgpixbuf);
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
146 has_alpha = gdk_pixbuf_get_has_alpha(imgpixbuf);
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
147
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
148 histmap = g_new0(HistMap, 1);
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
149
462
6a2934cd0883 histogram_read(): speed up calculations by 20%.
zas_
parents: 461
diff changeset
150 step = 3 + !!(has_alpha);
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
151 for (i = 0; i < h; i++)
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
152 {
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
153 guchar *sp = s_pix + (i * srs); /* 8bit */
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
154 for (j = 0; j < w; j++)
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
155 {
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
156 guint avg = (sp[0] + sp[1] + sp[2]) / 3;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
157 guint max = sp[0];
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
158 if (sp[1] > max) max = sp[1];
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
159 if (sp[2] > max) max = sp[2];
462
6a2934cd0883 histogram_read(): speed up calculations by 20%.
zas_
parents: 461
diff changeset
160
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
161 histmap->histmap[sp[0] * HISTMAP_CHANNELS + HISTMAP_CHANNEL_R]++;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
162 histmap->histmap[sp[1] * HISTMAP_CHANNELS + HISTMAP_CHANNEL_G]++;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
163 histmap->histmap[sp[2] * HISTMAP_CHANNELS + HISTMAP_CHANNEL_B]++;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
164 histmap->histmap[avg * HISTMAP_CHANNELS + HISTMAP_CHANNEL_AVG]++;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
165 histmap->histmap[max * HISTMAP_CHANNELS + HISTMAP_CHANNEL_MAX]++;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
166 sp += step;
462
6a2934cd0883 histogram_read(): speed up calculations by 20%.
zas_
parents: 461
diff changeset
167 }
6a2934cd0883 histogram_read(): speed up calculations by 20%.
zas_
parents: 461
diff changeset
168 }
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
169 histmap->area = w * h;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
170 return histmap;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
171 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
172
1298
c37f36b97173 added histogram pane
nadvornik
parents: 1294
diff changeset
173 const HistMap *histmap_get(FileData *fd)
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
174 {
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
175 if (fd->histmap) return fd->histmap;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
176
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
177 if (fd->pixbuf)
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
178 {
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
179 fd->histmap = histmap_read(fd->pixbuf);
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
180 return fd->histmap;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
181 }
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
182 return NULL;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
183 }
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
184
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
185 static void histogram_vgrid(Histogram *histogram, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height)
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
186 {
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
187 guint i;
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
188 float add;
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
189
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
190 if (histogram->vgrid == 0) return;
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
191
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
192 add = width / (float)histogram->vgrid;
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
193
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
194 for (i = 1; i < histogram->vgrid; i++)
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
195 {
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
196 gint xpos = x + (int)(i * add + 0.5);
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
197
1304
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
198 pixbuf_draw_line(pixbuf, x, y, width, height, xpos, y, xpos, y + height,
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
199 histogram->grid_color.R,
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
200 histogram->grid_color.G,
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
201 histogram->grid_color.B,
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
202 histogram->grid_color.A);
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
203 }
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
204 }
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
205
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
206 static void histogram_hgrid(Histogram *histogram, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height)
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
207 {
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
208 guint i;
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
209 float add;
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
210
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
211 if (histogram->hgrid == 0) return;
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
212
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
213 add = height / (float)histogram->hgrid;
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
214
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
215 for (i = 1; i < histogram->hgrid; i++)
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
216 {
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
217 gint ypos = y + (int)(i * add + 0.5);
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
218
1304
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
219 pixbuf_draw_line(pixbuf, x, y, width, height, x, ypos, x + width, ypos,
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
220 histogram->grid_color.R,
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
221 histogram->grid_color.G,
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
222 histogram->grid_color.B,
edeb07e1da5d Move grid color setting to histogram_new().
zas_
parents: 1303
diff changeset
223 histogram->grid_color.A);
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
224 }
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
225 }
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
226
1298
c37f36b97173 added histogram pane
nadvornik
parents: 1294
diff changeset
227 gint histogram_draw(Histogram *histogram, const HistMap *histmap, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height)
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
228 {
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
229 /* FIXME: use the coordinates correctly */
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
230 gint i;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
231 gulong max = 0;
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 999
diff changeset
232 gdouble logmax;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
233
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
234 if (!histogram || !histmap) return 0;
1302
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
235
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
236 /* Draw the grid */
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
237 histogram_vgrid(histogram, pixbuf, x, y, width, height);
8d1f9739c06a Add grid to bar histogram, simplify the code and draw horizontal lines too.
zas_
parents: 1298
diff changeset
238 histogram_hgrid(histogram, pixbuf, x, y, width, height);
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
239
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
240 for (i = 0; i < 1024; i++) {
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
241 #if 0
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
242 /* this is probably broken for MAX or VAL mode */
287
fd5c62403498 int -> gint
zas_
parents: 284
diff changeset
243 gint flag = 0;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
244
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
245 switch (histogram->channel_mode)
999
bbed8e9a5d33 Indentation fixes.
zas_
parents: 612
diff changeset
246 {
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
247 case HCHAN_RGB: if ((i % HISTMAP_CHANNELS) < 3) flag = 1; break;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
248 case HCHAN_R: if ((i % HISTMAP_CHANNELS) == HISTMAP_CHANNEL_R) flag = 1; break;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
249 case HCHAN_G: if ((i % HISTMAP_CHANNELS) == HISTMAP_CHANNEL_G) flag = 1; break;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
250 case HCHAN_B: if ((i % HISTMAP_CHANNELS) == HISTMAP_CHANNEL_B) flag = 1; break;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
251 case HCHAN_VAL: if ((i % HISTMAP_CHANNELS) == HISTMAP_CHANNEL_AVG) flag = 1; break;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
252 case HCHAN_MAX: if ((i % HISTMAP_CHANNELS) == HISTMAP_CHANNEL_MAX) flag = 1; break;
999
bbed8e9a5d33 Indentation fixes.
zas_
parents: 612
diff changeset
253 }
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
254 if (flag && histmap->histmap[i] > max) max = histmap->histmap[i];
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
255 #else
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
256 if (histmap->histmap[i] > max) max = histmap->histmap[i];
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
257 #endif
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
258 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
259
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
260 logmax = log(max);
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
261 for (i = 0; i < width; i++)
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
262 {
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
263 gint j;
290
4bbde8a38ad4 improved histogram drawing
nadvornik
parents: 287
diff changeset
264 glong v[4] = {0, 0, 0, 0};
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
265 gint rplus = 0;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
266 gint gplus = 0;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
267 gint bplus = 0;
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
268 gint ii = i * HISTMAP_SIZE / width;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
269 gint combine = (HISTMAP_SIZE - 1) / width + 1;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
270
290
4bbde8a38ad4 improved histogram drawing
nadvornik
parents: 287
diff changeset
271 for (j = 0; j < combine; j++)
4bbde8a38ad4 improved histogram drawing
nadvornik
parents: 287
diff changeset
272 {
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
273 v[0] += histmap->histmap[(ii + j) * HISTMAP_CHANNELS + HISTMAP_CHANNEL_R]; // r
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
274 v[1] += histmap->histmap[(ii + j) * HISTMAP_CHANNELS + HISTMAP_CHANNEL_G]; // g
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
275 v[2] += histmap->histmap[(ii + j) * HISTMAP_CHANNELS + HISTMAP_CHANNEL_B]; // b
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
276 v[3] += histmap->histmap[(ii + j) * HISTMAP_CHANNELS +
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
277 ((histogram->channel_mode == HCHAN_VAL) ? HISTMAP_CHANNEL_AVG : HISTMAP_CHANNEL_MAX)]; // value, max
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
278 }
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
279
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
280 for (j = 0; j < 4; j++)
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
281 {
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
282 v[j] /= combine;
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
283 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
284
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
285 for (j = 0; j < 4; j++)
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
286 {
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
287 gint max2 = 0;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
288 gint k;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
289
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
290 for (k = 1; k < 4; k++)
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
291 if (v[k] > v[max2]) max2 = k;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
292
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
293 if (histogram->channel_mode >= HCHAN_RGB
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
294 || max2 == histogram->channel_mode)
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
295 {
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
296 gulong pt;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
297 gint r = rplus;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
298 gint g = gplus;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
299 gint b = bplus;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
300
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
301 switch (max2)
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
302 {
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
303 case HCHAN_R: rplus = r = 255; break;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
304 case HCHAN_G: gplus = g = 255; break;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
305 case HCHAN_B: bplus = b = 255; break;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
306 }
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
307
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
308 switch (histogram->channel_mode)
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
309 {
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
310 case HCHAN_RGB:
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
311 if (r == 255 && g == 255 && b == 255)
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
312 {
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
313 r = 0; b = 0; g = 0;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
314 }
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
315 break;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
316 case HCHAN_R: b = 0; g = 0; break;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
317 case HCHAN_G: r = 0; b = 0; break;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
318 case HCHAN_B: r = 0; g = 0; break;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
319 case HCHAN_MAX:
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
320 case HCHAN_VAL: r = 0; b = 0; g = 0; break;
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
321 }
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
322
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
323 if (v[max2] == 0)
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
324 pt = 0;
1303
9669104eb58a Remove histogram_ prefix from struct _Histogram fields names and rename them more properly.
zas_
parents: 1302
diff changeset
325 else if (histogram->log_mode)
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
326 pt = ((float)log(v[max2])) / logmax * (height - 1);
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
327 else
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
328 pt = ((float)v[max2])/ max * (height - 1);
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
329
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 290
diff changeset
330 pixbuf_draw_line(pixbuf,
290
4bbde8a38ad4 improved histogram drawing
nadvornik
parents: 287
diff changeset
331 x, y, width, height,
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
332 x + i, y + height, x + i, y + height - pt,
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
333 r, g, b, 255);
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
334 }
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
335 v[max2] = -1;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
336 }
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
337 }
463
544934a1ff89 histogram_draw(): tidy up.
zas_
parents: 462
diff changeset
338
273
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
339 return TRUE;
e0e2c2b72c5a reworked the histogram patch by Uwe Ohse, most of the code is in
nadvornik
parents:
diff changeset
340 }
1294
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
341
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
342 void histogram_notify_cb(FileData *fd, NotifyType type, gpointer data)
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
343 {
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
344 if (type != NOTIFY_TYPE_INTERNAL && fd->histmap)
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
345 {
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
346 g_free(fd->histmap);
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
347 fd->histmap = NULL;
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
348 }
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
349 }
7ac9664242b2 histogram caching
nadvornik
parents: 1284
diff changeset
350
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1000
diff changeset
351 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */