Histogram *histogram;
gint histogram_width;
gint histogram_height;
- gint histogram_channel;
- gint histogram_logmode;
GdkPixbuf *pixbuf;
FileData *fd;
};
indent++;
WRITE_CHAR(*phd, pane.title);
WRITE_BOOL(*phd, pane.expanded);
- WRITE_INT(*phd, histogram_channel);
- WRITE_INT(*phd, histogram_logmode);
+ WRITE_INT(*phd->histogram, histogram_channel);
+ WRITE_INT(*phd->histogram, histogram_mode);
indent--;
WRITE_STRING("/>\n");
}
if (channel == histogram_get_channel(phd->histogram)) return;
histogram_set_channel(phd->histogram, channel);
- phd->histogram_channel = channel;
bar_pane_histogram_update(phd);
}
if (logmode == histogram_get_mode(phd->histogram)) return;
histogram_set_mode(phd->histogram, logmode);
- phd->histogram_logmode = logmode;
bar_pane_histogram_update(phd);
}
}
-GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gint expanded, gint histogram_channel, gint histogram_logmode)
+GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gint expanded, gint histogram_channel, gint histogram_mode)
{
PaneHistogramData *phd;
phd->histogram = histogram_new();
histogram_set_channel(phd->histogram, histogram_channel);
- histogram_set_mode(phd->histogram, histogram_logmode);
+ histogram_set_mode(phd->histogram, histogram_mode);
phd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP);
gboolean expanded = TRUE;
gint height = 80;
gint histogram_channel = HCHAN_RGB;
- gint histogram_logmode = 0;
+ gint histogram_mode = 0;
while (*attribute_names)
{
if (READ_CHAR_FULL("pane.title", title)) continue;
if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
if (READ_INT_FULL("histogram_channel", histogram_channel)) continue;
- if (READ_INT_FULL("histogram_logmode", histogram_logmode)) continue;
+ if (READ_INT_FULL("histogram_mode", histogram_mode)) continue;
DEBUG_1("unknown attribute %s = %s", option, value);
}
- return bar_pane_histogram_new(title, height, expanded, histogram_channel, histogram_logmode);
+ return bar_pane_histogram_new(title, height, expanded, histogram_channel, histogram_mode);
}
gulong max[HISTMAP_SIZE];
};
-struct _Histogram {
- gint channel_mode; /* drawing mode for histogram */
- gint log_mode; /* logarithmical or not */
- guint vgrid; /* number of vertical divisions, 0 for none */
- guint hgrid; /* number of horizontal divisions, 0 for none */
- struct {
- int R; /* red */
- int G; /* green */
- int B; /* blue */
- int A; /* alpha */
- } grid_color; /* grid color */
-
-};
Histogram *histogram_new(void)
{
Histogram *histogram;
histogram = g_new0(Histogram, 1);
- histogram->channel_mode = options->histogram.last_channel_mode;
- histogram->log_mode = options->histogram.last_log_mode;
+ histogram->histogram_channel = HCHAN_RGB;
+ histogram->histogram_mode = 0;
/* grid */
histogram->vgrid = 5;
gint histogram_set_channel(Histogram *histogram, gint chan)
{
if (!histogram) return 0;
- options->histogram.last_channel_mode = histogram->channel_mode = chan;
+ histogram->histogram_channel = chan;
return chan;
}
gint histogram_get_channel(Histogram *histogram)
{
if (!histogram) return 0;
- return histogram->channel_mode;
+ return histogram->histogram_channel;
}
gint histogram_set_mode(Histogram *histogram, gint mode)
{
if (!histogram) return 0;
- options->histogram.last_log_mode = histogram->log_mode = mode;
+ histogram->histogram_mode = mode;
return mode;
}
gint histogram_get_mode(Histogram *histogram)
{
if (!histogram) return 0;
- return histogram->log_mode;
+ return histogram->histogram_mode;
}
gint histogram_toggle_channel(Histogram *histogram)
if (!histogram) return NULL;
- if (histogram->log_mode)
- switch (histogram->channel_mode)
+ if (histogram->histogram_mode)
+ switch (histogram->histogram_channel)
{
case HCHAN_R: t1 = _("logarithmical histogram on red"); break;
case HCHAN_G: t1 = _("logarithmical histogram on green"); break;
case HCHAN_MAX: t1 = _("logarithmical histogram on max value"); break;
}
else
- switch (histogram->channel_mode)
+ switch (histogram->histogram_channel)
{
case HCHAN_R: t1 = _("linear histogram on red"); break;
case HCHAN_G: t1 = _("linear histogram on green"); break;
for (j = 0; j < 4; j++)
{
- gint k;
- gint chanmax = 0;
+ gint chanmax = HCHAN_R;
- for (k = 1; k < 3; k++)
- if (v[k] > v[chanmax])
- chanmax = k;
+ if (v[HCHAN_G] > v[HCHAN_R]) chanmax = HCHAN_G;
+ if (v[HCHAN_B] > v[HCHAN_G]) chanmax = HCHAN_B;
- if (histogram->channel_mode >= HCHAN_RGB
- || chanmax == histogram->channel_mode)
+ if (histogram->histogram_channel >= HCHAN_RGB
+ || chanmax == histogram->histogram_channel)
{
gulong pt;
gint r = rplus;
switch (chanmax)
{
- case 0: rplus = r = 255; break;
- case 1: gplus = g = 255; break;
- case 2: bplus = b = 255; break;
+ case HCHAN_R: rplus = r = 255; break;
+ case HCHAN_G: gplus = g = 255; break;
+ case HCHAN_B: bplus = b = 255; break;
}
- switch (histogram->channel_mode)
+ switch (histogram->histogram_channel)
{
case HCHAN_RGB:
if (r == 255 && g == 255 && b == 255)
{
- r = 0; b = 0; g = 0;
+ r = 0; b = 0; g = 0;
}
break;
- case HCHAN_R: b = 0; g = 0; break;
- case HCHAN_G: r = 0; b = 0; break;
- case HCHAN_B: r = 0; g = 0; break;
- case HCHAN_MAX: r = 0; b = 0; g = 0; break;
+ case HCHAN_R: b = 0; g = 0; break;
+ case HCHAN_G: r = 0; b = 0; break;
+ case HCHAN_B: r = 0; g = 0; break;
+ case HCHAN_MAX: r = 0; b = 0; g = 0; break;
}
if (v[chanmax] == 0)
pt = 0;
- else if (histogram->log_mode)
+ else if (histogram->histogram_mode)
pt = ((gdouble)log(v[chanmax])) / logmax * (height - 1);
else
pt = ((gdouble)v[chanmax]) / max * (height - 1);
if (!osd || !osd->histogram) return;
histogram_toggle_channel(osd->histogram);
+ options->image_overlay.common.histogram_channel = histogram_get_channel(osd->histogram);
image_osd_update(imd);
}
if (!osd || !osd->histogram) return;
histogram_toggle_mode(osd->histogram);
+ options->image_overlay.common.histogram_mode = histogram_get_mode(osd->histogram);
image_osd_update(imd);
}
}
if (show & OSD_SHOW_HISTOGRAM)
+ {
osd->histogram = histogram_new();
+ histogram_set_channel(osd->histogram, options->image_overlay.common.histogram_channel);
+ histogram_set_mode(osd->histogram, options->image_overlay.common.histogram_mode);
+ }
else if (osd->histogram)
{
histogram_free(osd->histogram);
options->fullscreen.disable_saver = TRUE;
options->fullscreen.screen = -1;
- options->histogram.last_channel_mode = HCHAN_RGB;
- options->histogram.last_log_mode = 1;
+ options->image_overlay.common.histogram_channel = HCHAN_RGB;
+ options->image_overlay.common.histogram_mode = 1;
memset(&options->image.border_color, 0, sizeof(options->image.border_color));
options->image.dither_quality = GDK_RGB_DITHER_NORMAL;
gboolean above;
} fullscreen;
- /* histogram */
- struct {
- guint last_channel_mode;
- guint last_log_mode;
- } histogram;
-
/* image overlay */
struct {
struct {
gchar *template_string;
gint x;
gint y;
+ gint histogram_channel;
+ gint histogram_mode;
} common;
} image_overlay;
WRITE_BOOL(*options, fullscreen.above);
-// WRITE_SUBTITLE("Histogram Options");
- WRITE_UINT(*options, histogram.last_channel_mode);
- WRITE_UINT(*options, histogram.last_log_mode);
-
-
// WRITE_SUBTITLE("Image Overlay Options");
WRITE_UINT(*options, image_overlay.common.state);
WRITE_BOOL(*options, image_overlay.common.show_at_startup);
WRITE_CHAR(*options, image_overlay.common.template_string);
+ WRITE_INT(*options, image_overlay.common.histogram_channel);
+ WRITE_INT(*options, image_overlay.common.histogram_mode);
WRITE_SEPARATOR();
// g_string_append_printf(outstr, "# these are relative positions:\n");
if (READ_BOOL(*options, fullscreen.disable_saver)) continue;
if (READ_BOOL(*options, fullscreen.above)) continue;
- /* histogram */
- if (READ_UINT(*options, histogram.last_channel_mode)) continue;
- if (READ_UINT(*options, histogram.last_log_mode)) continue;
-
/* image overlay */
if (READ_UINT(*options, image_overlay.common.state)) continue;
if (READ_BOOL(*options, image_overlay.common.show_at_startup)) continue;
if (READ_CHAR(*options, image_overlay.common.template_string)) continue;
+ if (READ_INT(*options, image_overlay.common.histogram_channel)) continue;
+ if (READ_INT(*options, image_overlay.common.histogram_mode)) continue;
if (READ_INT(*options, image_overlay.common.x)) continue;
if (READ_INT(*options, image_overlay.common.y)) continue;
typedef struct _CommandLine CommandLine;
+struct _Histogram {
+ gint histogram_channel; /* drawing mode for histogram */
+ gint histogram_mode; /* logarithmical or not */
+ guint vgrid; /* number of vertical divisions, 0 for none */
+ guint hgrid; /* number of horizontal divisions, 0 for none */
+ struct {
+ int R; /* red */
+ int G; /* green */
+ int B; /* blue */
+ int A; /* alpha */
+ } grid_color; /* grid color */
+
+};
+
+
struct _EditorDescription {
gchar *key; /* desktop file name, not including path, including extension */
gchar *name; /* Name, localized name presented to user */