summaryrefslogtreecommitdiffstats
path: root/bin/gui
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-11 21:01:22 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-11 21:01:22 +0200
commit3182fa2bcae5dea54f7f3c82ead20ac006da0415 (patch)
treef04e26202e3f8096fa218a7dfbf4e0a3a4df52a4 /bin/gui
parent4db06730d05296b88fb2de5b07a2079627f0c8a2 (diff)
downloaduca-3182fa2bcae5dea54f7f3c82ead20ac006da0415.tar.gz
uca-3182fa2bcae5dea54f7f3c82ead20ac006da0415.tar.bz2
uca-3182fa2bcae5dea54f7f3c82ead20ac006da0415.tar.xz
uca-3182fa2bcae5dea54f7f3c82ead20ac006da0415.zip
Add naive up-scaling
Diffstat (limited to 'bin/gui')
-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>