summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/gui/control.c61
-rw-r--r--bin/gui/control.glade8
2 files changed, 67 insertions, 2 deletions
diff --git a/bin/gui/control.c b/bin/gui/control.c
index c177f07..5fa82df 100644
--- a/bin/gui/control.c
+++ b/bin/gui/control.c
@@ -70,14 +70,14 @@ static UcaPluginManager *plugin_manager;
static gsize mem_size = 2048;
static void
-convert_grayscale_to_rgb (ThreadData *data, gpointer buffer)
+down_scale (ThreadData *data, gpointer buffer)
{
gdouble min;
gdouble max;
gdouble factor;
guint8 *output;
- gint i = 0;
gint stride;
+ gint i = 0;
egg_histogram_get_visible_range (EGG_HISTOGRAM_VIEW (data->histogram_view), &min, &max);
factor = 255.0 / (max - min);
@@ -119,6 +119,63 @@ convert_grayscale_to_rgb (ThreadData *data, gpointer buffer)
}
static void
+up_scale (ThreadData *data, gpointer buffer)
+{
+ gdouble min;
+ gdouble max;
+ gdouble factor;
+ guint8 *output;
+ gint i = 0;
+ gint zoom;
+
+ egg_histogram_get_visible_range (EGG_HISTOGRAM_VIEW (data->histogram_view), &min, &max);
+ factor = 255.0 / (max - min);
+ output = data->pixels;
+ zoom = (gint) data->zoom_factor;
+
+ if (data->pixel_size == 1) {
+ guint8 *input = (guint8 *) buffer;
+
+ for (gint y = 0; y < data->display_height; y++) {
+ for (gint x = 0; x < data->display_width; x++) {
+ gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom));
+ gdouble dval = (input[offset] - min) * factor;
+ guchar val = (guchar) CLAMP(dval, 0.0, 255.0);
+
+ output[i++] = val;
+ output[i++] = val;
+ output[i++] = val;
+ }
+ }
+ }
+ else if (data->pixel_size == 2) {
+ guint16 *input = (guint16 *) buffer;
+
+ for (gint y = 0; y < data->display_height; y++) {
+ for (gint x = 0; x < data->display_width; x++) {
+ gint offset = ((gint) (y / zoom) * data->width) + ((gint) (x / zoom));
+ gdouble dval = (input[offset] - min) * factor;
+ guchar val = (guchar) CLAMP(dval, 0.0, 255.0);
+
+ output[i++] = val;
+ output[i++] = val;
+ output[i++] = val;
+ }
+ }
+ }
+}
+
+
+static void
+convert_grayscale_to_rgb (ThreadData *data, gpointer buffer)
+{
+ if (data->zoom_factor <= 1)
+ down_scale (data, buffer);
+ else
+ up_scale (data, buffer);
+}
+
+static void
update_pixbuf (ThreadData *data)
{
gdk_flush ();
diff --git a/bin/gui/control.glade b/bin/gui/control.glade
index eec9dde..3f64802 100644
--- a/bin/gui/control.glade
+++ b/bin/gui/control.glade
@@ -446,6 +446,14 @@
</columns>
<data>
<row>
+ <col id="0" translatable="yes">400 %</col>
+ <col id="1">4</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">200 %</col>
+ <col id="1">2</col>
+ </row>
+ <row>
<col id="0" translatable="yes">100 %</col>
<col id="1">1</col>
</row>