aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-12-02 22:56:28 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:07 +0100
commitc25120f4b71da8b82476c8a14b1617c8f7b72d57 (patch)
treee9675a9f569cc4ef592ff72727df2f689e6643e4 /src
parentfcf49763c544e280567b1b31f159fb134beac727 (diff)
Fix Cairo conditionals
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile.in21
-rw-r--r--src/cubeit.c1
-rw-r--r--src/render.c163
-rw-r--r--src/render.h9
5 files changed, 107 insertions, 89 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 98508dd0..75ef8063 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -67,9 +67,11 @@ facetron_SOURCES = facetron.c cell.c hdf5-file.c utils.c detector.c peaks.c \
beam-parameters.c symmetry.c post-refinement.c hrs-scaling.c
facetron_LDADD = @LIBS@
+if HAVE_CAIRO
cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c render.c \
filters.c image.c symmetry.c stream.c thread-pool.c
cubeit_LDADD = @LIBS@
+endif
reintegrate_SOURCES = reintegrate.c cell.c hdf5-file.c utils.c detector.c \
peaks.c image.c stream.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index d7833b13..11b0eabf 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -70,10 +70,15 @@ am_compare_hkl_OBJECTS = compare_hkl.$(OBJEXT) sfac.$(OBJEXT) \
statistics.$(OBJEXT) symmetry.$(OBJEXT)
compare_hkl_OBJECTS = $(am_compare_hkl_OBJECTS)
compare_hkl_DEPENDENCIES =
-am_cubeit_OBJECTS = cubeit.$(OBJEXT) cell.$(OBJEXT) \
- hdf5-file.$(OBJEXT) utils.$(OBJEXT) detector.$(OBJEXT) \
- render.$(OBJEXT) filters.$(OBJEXT) image.$(OBJEXT) \
- symmetry.$(OBJEXT) stream.$(OBJEXT) thread-pool.$(OBJEXT)
+am__cubeit_SOURCES_DIST = cubeit.c cell.c hdf5-file.c utils.c \
+ detector.c render.c filters.c image.c symmetry.c stream.c \
+ thread-pool.c
+@HAVE_CAIRO_TRUE@am_cubeit_OBJECTS = cubeit.$(OBJEXT) cell.$(OBJEXT) \
+@HAVE_CAIRO_TRUE@ hdf5-file.$(OBJEXT) utils.$(OBJEXT) \
+@HAVE_CAIRO_TRUE@ detector.$(OBJEXT) render.$(OBJEXT) \
+@HAVE_CAIRO_TRUE@ filters.$(OBJEXT) image.$(OBJEXT) \
+@HAVE_CAIRO_TRUE@ symmetry.$(OBJEXT) stream.$(OBJEXT) \
+@HAVE_CAIRO_TRUE@ thread-pool.$(OBJEXT)
cubeit_OBJECTS = $(am_cubeit_OBJECTS)
cubeit_DEPENDENCIES =
am_estimate_background_OBJECTS = estimate_background.$(OBJEXT) \
@@ -180,7 +185,7 @@ SOURCES = $(calibrate_detector_SOURCES) $(check_hkl_SOURCES) \
$(process_hkl_SOURCES) $(reintegrate_SOURCES) \
$(render_hkl_SOURCES)
DIST_SOURCES = $(calibrate_detector_SOURCES) $(check_hkl_SOURCES) \
- $(compare_hkl_SOURCES) $(cubeit_SOURCES) \
+ $(compare_hkl_SOURCES) $(am__cubeit_SOURCES_DIST) \
$(estimate_background_SOURCES) $(facetron_SOURCES) \
$(get_hkl_SOURCES) $(am__hdfsee_SOURCES_DIST) \
$(am__indexamajig_SOURCES_DIST) \
@@ -333,10 +338,10 @@ facetron_SOURCES = facetron.c cell.c hdf5-file.c utils.c detector.c peaks.c \
beam-parameters.c symmetry.c post-refinement.c hrs-scaling.c
facetron_LDADD = @LIBS@
-cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c render.c \
- filters.c image.c symmetry.c stream.c thread-pool.c
+@HAVE_CAIRO_TRUE@cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c render.c \
+@HAVE_CAIRO_TRUE@ filters.c image.c symmetry.c stream.c thread-pool.c
-cubeit_LDADD = @LIBS@
+@HAVE_CAIRO_TRUE@cubeit_LDADD = @LIBS@
reintegrate_SOURCES = reintegrate.c cell.c hdf5-file.c utils.c detector.c \
peaks.c image.c stream.c \
index.c dirax.c templates.c geometry.c symmetry.c \
diff --git a/src/cubeit.c b/src/cubeit.c
index 4b32e11b..c5766d6f 100644
--- a/src/cubeit.c
+++ b/src/cubeit.c
@@ -25,6 +25,7 @@
#include <fenv.h>
#include <pthread.h>
#include <libgen.h>
+#include <cairo.h>
#include "utils.h"
#include "hdf5-file.h"
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 <config.h>
#endif
-#include <stdlib.h>
+
+#ifdef HAVE_GTK
#include <gdk-pixbuf/gdk-pixbuf.h>
+#endif
+
+#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <png.h>
@@ -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<w; x++ ) {
- for ( y=0; y<h; y++ ) {
-
- double total;
- size_t xb, yb;
-
- total = 0;
- for ( xb=0; xb<binning; xb++ ) {
- for ( yb=0; yb<binning; yb++ ) {
-
- total += in[binning*x+xb + (binning*y+yb)*inw];
-
- }
- }
-
- data[x+w*y] = total / ((double)binning * (double)binning);
- if ( data[x+w*y] > 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<w; x++ ) {
+ for ( y=0; y<h; y++ ) {
+
+ double total;
+ size_t xb, yb;
+
+ total = 0;
+ for ( xb=0; xb<binning; xb++ ) {
+ for ( yb=0; yb<binning; yb++ ) {
+
+ total += in[binning*x+xb + (binning*y+yb)*inw];
+
+ }
+ }
+
+ data[x+w*y] = total / ((double)binning * (double)binning);
+ if ( data[x+w*y] > 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 */
diff --git a/src/render.h b/src/render.h
index 902ec278..ae9fb637 100644
--- a/src/render.h
+++ b/src/render.h
@@ -20,7 +20,7 @@
#include <stddef.h>
-#include "displaywindow.h"
+
#include "image.h"
enum {
@@ -32,18 +32,21 @@ enum {
extern void render_scale(float val, float max, int scale,
float *rp, float *gp, float *bp);
+
#ifdef HAVE_GTK
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include "displaywindow.h"
extern GdkPixbuf *render_get_image(DisplayWindow *dw);
extern GdkPixbuf *render_get_colour_scale(size_t w, size_t h, int scale);
-#endif /* HAVE_GTK */
-
extern int render_png(DisplayWindow *dw, const char *filename);
extern int render_tiff_fp(DisplayWindow *dw, const char *filename);
extern int render_tiff_int16(DisplayWindow *dw, const char *filename);
+#endif /* HAVE_GTK */
+
+
#endif /* RENDER_H */