summaryrefslogtreecommitdiffstats
path: root/bin/gui/control.c
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/control.c
parent4db06730d05296b88fb2de5b07a2079627f0c8a2 (diff)
downloadlibuca-3182fa2bcae5dea54f7f3c82ead20ac006da0415.tar.gz
libuca-3182fa2bcae5dea54f7f3c82ead20ac006da0415.tar.bz2
libuca-3182fa2bcae5dea54f7f3c82ead20ac006da0415.tar.xz
libuca-3182fa2bcae5dea54f7f3c82ead20ac006da0415.zip
Add naive up-scaling
Diffstat (limited to 'bin/gui/control.c')
-rw-r--r--bin/gui/control.c61
1 files changed, 59 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 ();