Mercurial > geeqie
comparison src/histogram.c @ 1304:edeb07e1da5d
Move grid color setting to histogram_new().
author | zas_ |
---|---|
date | Sat, 21 Feb 2009 10:53:18 +0000 |
parents | 9669104eb58a |
children | 2320339ca8be |
comparison
equal
deleted
inserted
replaced
1303:9669104eb58a | 1304:edeb07e1da5d |
---|---|
37 gulong histmap[HISTMAP_SIZE * HISTMAP_CHANNELS]; | 37 gulong histmap[HISTMAP_SIZE * HISTMAP_CHANNELS]; |
38 gulong area; | 38 gulong area; |
39 }; | 39 }; |
40 | 40 |
41 struct _Histogram { | 41 struct _Histogram { |
42 gint channel_mode; | 42 gint channel_mode; /* drawing mode for histogram */ |
43 gint log_mode; | 43 gint log_mode; /* logarithmical or not */ |
44 guint vgrid; /* number of vertical divisions, 0 for none */ | 44 guint vgrid; /* number of vertical divisions, 0 for none */ |
45 guint hgrid; /* number of horizontal divisions, 0 for none */ | 45 guint hgrid; /* number of horizontal divisions, 0 for none */ |
46 struct { | |
47 int R; /* red */ | |
48 int G; /* green */ | |
49 int B; /* blue */ | |
50 int A; /* alpha */ | |
51 } grid_color; /* grid color */ | |
46 | 52 |
47 }; | 53 }; |
48 | 54 |
49 Histogram *histogram_new(void) | 55 Histogram *histogram_new(void) |
50 { | 56 { |
51 Histogram *histogram; | 57 Histogram *histogram; |
52 | 58 |
53 histogram = g_new0(Histogram, 1); | 59 histogram = g_new0(Histogram, 1); |
54 histogram->channel_mode = options->histogram.last_channel_mode; | 60 histogram->channel_mode = options->histogram.last_channel_mode; |
55 histogram->log_mode = options->histogram.last_log_mode; | 61 histogram->log_mode = options->histogram.last_log_mode; |
62 | |
63 /* grid */ | |
56 histogram->vgrid = 5; | 64 histogram->vgrid = 5; |
57 histogram->hgrid = 3; | 65 histogram->hgrid = 3; |
66 histogram->grid_color.R = 160; | |
67 histogram->grid_color.G = 160; | |
68 histogram->grid_color.B = 160; | |
69 histogram->grid_color.A = 250; | |
58 | 70 |
59 return histogram; | 71 return histogram; |
60 } | 72 } |
61 | 73 |
62 void histogram_free(Histogram *histogram) | 74 void histogram_free(Histogram *histogram) |
170 return NULL; | 182 return NULL; |
171 } | 183 } |
172 | 184 |
173 static void histogram_vgrid(Histogram *histogram, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height) | 185 static void histogram_vgrid(Histogram *histogram, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height) |
174 { | 186 { |
175 static gint c = 160; | |
176 static gint alpha = 250; | |
177 guint i; | 187 guint i; |
178 float add; | 188 float add; |
179 | 189 |
180 if (histogram->vgrid == 0) return; | 190 if (histogram->vgrid == 0) return; |
181 | 191 |
183 | 193 |
184 for (i = 1; i < histogram->vgrid; i++) | 194 for (i = 1; i < histogram->vgrid; i++) |
185 { | 195 { |
186 gint xpos = x + (int)(i * add + 0.5); | 196 gint xpos = x + (int)(i * add + 0.5); |
187 | 197 |
188 pixbuf_draw_line(pixbuf, x, y, width, height, xpos, y, xpos, y + height, c, c, c, alpha); | 198 pixbuf_draw_line(pixbuf, x, y, width, height, xpos, y, xpos, y + height, |
199 histogram->grid_color.R, | |
200 histogram->grid_color.G, | |
201 histogram->grid_color.B, | |
202 histogram->grid_color.A); | |
189 } | 203 } |
190 } | 204 } |
191 | 205 |
192 static void histogram_hgrid(Histogram *histogram, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height) | 206 static void histogram_hgrid(Histogram *histogram, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height) |
193 { | 207 { |
194 static gint c = 160; | |
195 static gint alpha = 250; | |
196 guint i; | 208 guint i; |
197 float add; | 209 float add; |
198 | 210 |
199 if (histogram->hgrid == 0) return; | 211 if (histogram->hgrid == 0) return; |
200 | 212 |
202 | 214 |
203 for (i = 1; i < histogram->hgrid; i++) | 215 for (i = 1; i < histogram->hgrid; i++) |
204 { | 216 { |
205 gint ypos = y + (int)(i * add + 0.5); | 217 gint ypos = y + (int)(i * add + 0.5); |
206 | 218 |
207 pixbuf_draw_line(pixbuf, x, y, width, height, x, ypos, x + width, ypos, c, c, c, alpha); | 219 pixbuf_draw_line(pixbuf, x, y, width, height, x, ypos, x + width, ypos, |
220 histogram->grid_color.R, | |
221 histogram->grid_color.G, | |
222 histogram->grid_color.B, | |
223 histogram->grid_color.A); | |
208 } | 224 } |
209 } | 225 } |
210 | 226 |
211 gint histogram_draw(Histogram *histogram, const HistMap *histmap, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height) | 227 gint histogram_draw(Histogram *histogram, const HistMap *histmap, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height) |
212 { | 228 { |