From c25120f4b71da8b82476c8a14b1617c8f7b72d57 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 2 Dec 2010 22:56:28 +0100 Subject: Fix Cairo conditionals --- src/render.c | 163 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 85 insertions(+), 78 deletions(-) (limited to 'src/render.c') diff --git a/src/render.c b/src/render.c index 2cc6a63b..98fb693d 100644 --- a/src/render.c +++ b/src/render.c @@ -13,8 +13,12 @@ #include #endif -#include + +#ifdef HAVE_GTK #include +#endif + +#include #include #include #include @@ -27,81 +31,6 @@ #include "utils.h" -static void *render_bin(float *in, int inw, int inh, int binning, float *maxp) -{ - float *data; - int x, y; - int w, h; - float max; - - w = inw / binning; - h = inh / binning; /* Some pixels might get discarded */ - - data = malloc(w*h*sizeof(float)); - max = 0.0; - - for ( x=0; x max ) max = data[x+w*y]; - - } - } - - *maxp = max; - return data; -} - - -float *render_get_image_binned(DisplayWindow *dw, int binning, float *max) -{ - struct image *image; - float *data; - - if ( (dw->image == NULL) || (dw->image_dirty) ) { - - image = malloc(sizeof(struct image)); - if ( image == NULL ) return NULL; - image->features = NULL; - image->data = NULL; - - /* We don't care about the photon energy here */ - hdf5_read(dw->hdfile, image, 1, 0.0); - dw->image_dirty = 0; - if ( dw->cmfilter ) filter_cm(image); - if ( dw->noisefilter ) filter_noise(image, NULL); - - /* Deal with the old image, if existing */ - if ( dw->image != NULL ) { - image->features = dw->image->features; - if ( dw->image->data != NULL ) free(dw->image->data); - free(dw->image); - } - - dw->image = image; - - } - - data = render_bin(dw->image->data, hdfile_get_width(dw->hdfile), - hdfile_get_height(dw->hdfile), binning, max); - - return data; -} - - static void render_rgb(float val, float max, float *rp, float *gp, float *bp) { int s; @@ -201,6 +130,84 @@ void render_scale(float val, float max, int scale, } +#ifdef HAVE_GTK + + +static void *render_bin(float *in, int inw, int inh, int binning, float *maxp) +{ + float *data; + int x, y; + int w, h; + float max; + + w = inw / binning; + h = inh / binning; /* Some pixels might get discarded */ + + data = malloc(w*h*sizeof(float)); + max = 0.0; + + for ( x=0; x max ) max = data[x+w*y]; + + } + } + + *maxp = max; + return data; +} + + +float *render_get_image_binned(DisplayWindow *dw, int binning, float *max) +{ + struct image *image; + float *data; + + if ( (dw->image == NULL) || (dw->image_dirty) ) { + + image = malloc(sizeof(struct image)); + if ( image == NULL ) return NULL; + image->features = NULL; + image->data = NULL; + + /* We don't care about the photon energy here */ + hdf5_read(dw->hdfile, image, 1, 0.0); + dw->image_dirty = 0; + if ( dw->cmfilter ) filter_cm(image); + if ( dw->noisefilter ) filter_noise(image, NULL); + + /* Deal with the old image, if existing */ + if ( dw->image != NULL ) { + image->features = dw->image->features; + if ( dw->image->data != NULL ) free(dw->image->data); + free(dw->image); + } + + dw->image = image; + + } + + data = render_bin(dw->image->data, hdfile_get_width(dw->hdfile), + hdfile_get_height(dw->hdfile), binning, max); + + return data; +} + + /* NB This function is shared between render_get_image() and * render_get_colour_scale() */ static void render_free_data(guchar *data, gpointer p) @@ -250,7 +257,6 @@ static void show_marked_features(struct image *image, guchar *data, } -#ifdef HAVE_GTK /* Return a pixbuf containing a rendered version of the image after binning. * This pixbuf might be scaled later - hopefully mostly in a downward * direction. */ @@ -345,7 +351,6 @@ GdkPixbuf *render_get_colour_scale(size_t w, size_t h, int scale) return gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, FALSE, 8, w, h, w*3, render_free_data, NULL); } -#endif /* HAVE_GTK */ int render_png(DisplayWindow *dw, const char *filename) @@ -566,3 +571,5 @@ int render_tiff_int16(DisplayWindow *dw, const char *filename) #endif return 0; } + +#endif /* HAVE_GTK */ -- cgit v1.2.3