From 018bff49cd1f5fbd3071b092d0546be67147e893 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 21 Mar 2018 16:53:31 +0100 Subject: Separate tests for gdk-pixbuf-2.0 and GDK --- src/dw-hdfsee.c | 9 ++++++--- src/geoptimiser.c | 43 ++++++++++++++++++++++++------------------- src/hdfsee-render.c | 39 ++++++++++++++++----------------------- src/hdfsee-render.h | 16 ++++++---------- 4 files changed, 52 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index c1bb39cc..c5c4d85a 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -1653,7 +1653,8 @@ static gint displaywindow_save_response(GtkWidget *d, gint response, "Therefore, it can't be saved as TIFF."); r = 0; } else { - r = render_tiff_fp(dw, dw->image, file); + r = render_tiff_fp(dw->image, file, dw->min_x, + dw->max_x, dw->min_y, dw->max_y); } } else if ( type == 2 ) { if ( !single_panel_data_source(dw->image->det, NULL) ) { @@ -1662,8 +1663,10 @@ static gint displaywindow_save_response(GtkWidget *d, gint response, "Therefore, it can't be saved as TIFF."); r = 0; } else { - r = render_tiff_int16(dw, dw->image, file, - dw->boostint); + r = render_tiff_int16(dw->image, file, + dw->boostint, dw->min_x, + dw->max_x, dw->min_y, + dw->max_y); } } else if ( type == 3 ) { if ( !single_panel_data_source(dw->image->det, NULL) ) { diff --git a/src/geoptimiser.c b/src/geoptimiser.c index 3d859a61..f63ba81b 100644 --- a/src/geoptimiser.c +++ b/src/geoptimiser.c @@ -44,11 +44,14 @@ #include #ifdef HAVE_CAIRO -#ifdef HAVE_GTK -#define HAVE_SAVE_TO_PNG 1 +#ifdef HAVE_GDK +#ifdef HAVE_GDKPIXBUF #include +#include #include -#endif /* HAVE_GTK */ +#define CAN_SAVE_TO_PNG +#endif /* HAVE_GDKPIXBUF */ +#endif /* HAVE_GDK */ #endif /* HAVE_CAIRO */ #include "detector.h" @@ -1636,7 +1639,7 @@ static double compute_rotation_and_stretch(struct rg_collection *connected, } -#ifdef HAVE_SAVE_TO_PNG +#ifdef CAN_SAVE_TO_PNG static void draw_panel(struct image *image, cairo_t *cr, cairo_matrix_t *basic_m, GdkPixbuf **pixbufs, int i) { @@ -1813,7 +1816,17 @@ static int save_data_to_png(char *filename, struct detector *det, return 0; } -#endif /* HAVE_SAVE_TO_PNG */ +#else /* CAN_SAVE_TO_PNG */ + +static int save_data_to_png(char *filename, struct detector *det, + struct gpanel *gpanels) +{ + ERROR("WARNING: geoptimiser was compiled without gdk-pixbuf and cairo " + "support. Error maps will not be saved.\n"); + return 0; /* Return "success" so that program continues */ +} + +#endif /* CAN_SAVE_TO_PNG */ int check_and_enforce_cspad_dist(struct geoptimiser_params *gparams, @@ -2212,8 +2225,6 @@ int optimize_geometry(struct geoptimiser_params *gparams, STATUS("Saving error map before correction.\n"); -#ifdef HAVE_SAVE_TO_PNG - if ( save_data_to_png("error_map_before.png", det, gpanels) ) { ERROR("Error while writing data to file.\n"); free(conn_data); @@ -2221,12 +2232,6 @@ int optimize_geometry(struct geoptimiser_params *gparams, return 1; } -#else /* HAVE_SAVE_TO_PNG */ - - ERROR("WARNING: geoptimiser was compiled without GTK and cairo " - "support. Error maps will not be saved.\n"); - -#endif /* HAVE_SAVE_TO_PNG */ } @@ -2265,7 +2270,7 @@ int optimize_geometry(struct geoptimiser_params *gparams, if ( gparams->error_maps ) { -#ifdef HAVE_SAVE_TO_PNG +#ifdef CAN_SAVE_TO_PNG STATUS("Saving error map after correction.\n"); @@ -2276,12 +2281,12 @@ int optimize_geometry(struct geoptimiser_params *gparams, return 1; } -#else /* HAVE_SAVE_TO_PNG */ +#else /* CAN_SAVE_TO_PNG */ - STATUS("ERROR: geoptimiser was compiled without GTK and cairo " + STATUS("geoptimiser was compiled without GTK and Cairo " "support.\n Error maps will not be saved.\n"); -#endif /* HAVE_SAVE_TO_PNG */ +#endif /* CAN_SAVE_TO_PNG */ } @@ -2301,12 +2306,12 @@ int optimize_geometry(struct geoptimiser_params *gparams, STATUS("All done!\n"); if ( gparams->error_maps ) { -#ifdef HAVE_SAVE_TO_PNG +#ifdef CAN_SAVE_TO_PNG STATUS("Be sure to inspect error_map_before.png and " "error_map_after.png !!\n"); -#endif /* HAVE_SAVE_TO_PNG */ +#endif /* CAN_SAVE_TO_PNG */ } free(conn_data); diff --git a/src/hdfsee-render.c b/src/hdfsee-render.c index 5e1de2f1..d9da469e 100644 --- a/src/hdfsee-render.c +++ b/src/hdfsee-render.c @@ -30,15 +30,16 @@ #include #endif -#ifdef HAVE_GTK - -#include - #include #include #include #include + +#ifdef HAVE_GDKPIXBUF +#include +#endif + #ifdef HAVE_TIFF #include #endif @@ -46,8 +47,6 @@ #include #include -#include "dw-hdfsee.h" - static float *get_binned_panel(struct image *image, int binning, int pi, double *max, int *pw, int *ph) { @@ -107,6 +106,8 @@ static float *get_binned_panel(struct image *image, int binning, } +#ifdef HAVE_GDKPIXBUF + /* NB This function is shared between render_get_image() and * render_get_colour_scale() */ static void render_free_data(guchar *data, gpointer p) @@ -260,17 +261,15 @@ GdkPixbuf *render_get_colour_scale(size_t w, size_t h, int scale) w, h, w*3, render_free_data, NULL); } +#endif /* HAVE_GDKPIXBUF */ -int render_tiff_fp(DisplayWindow *dw, struct image *image, const char *filename) +int render_tiff_fp(struct image *image, const char *filename, int min_x, int max_x, + int min_y, int max_y) { #ifdef HAVE_TIFF TIFF *th; int16_t *line; int x, y; - int min_x = (int)dw->min_x; - int max_x = (int)dw->max_x; - int min_y = (int)dw->min_y; - int max_y = (int)dw->max_y; int width = max_x - min_x; int height = max_y - min_y; float *buf; @@ -331,24 +330,20 @@ int render_tiff_fp(DisplayWindow *dw, struct image *image, const char *filename) TIFFClose(th); free(buf); -#else +#else /* HAVE_TIFF */ STATUS("No TIFF support.\n"); -#endif +#endif /* HAVE_TIFF */ return 0; } -int render_tiff_int16(DisplayWindow *dw, struct image *image, - const char *filename, double boost) +int render_tiff_int16(struct image *image, const char *filename, double boost, + int min_x, int max_x, int min_y, int max_y) { #ifdef HAVE_TIFF TIFF *th; int16_t *line; int x, y; - int min_x = (int)dw->min_x; - int max_x = (int)dw->max_x; - int min_y = (int)dw->min_y; - int max_y = (int)dw->max_y; int width = max_x - min_x; int height = max_y - min_y; int16_t *buf; @@ -417,10 +412,8 @@ int render_tiff_int16(DisplayWindow *dw, struct image *image, TIFFClose(th); free(buf); -#else +#else /* HAVE_TIFF */ STATUS("No TIFF support.\n"); -#endif +#endif /* HAVE_TIFF */ return 0; } - -#endif /* HAVE_GTK */ diff --git a/src/hdfsee-render.h b/src/hdfsee-render.h index 7e87b79e..414e6ecd 100644 --- a/src/hdfsee-render.h +++ b/src/hdfsee-render.h @@ -33,25 +33,21 @@ #include #endif - -#ifdef HAVE_GTK - +#ifdef HAVE_GDKPIXBUF #include -#include "dw-hdfsee.h" - extern GdkPixbuf **render_panels(struct image *image, int binning, int scale, double boost, int *n_pixbufs); extern GdkPixbuf *render_get_colour_scale(size_t w, size_t h, int scale); -extern int render_tiff_fp(DisplayWindow *dw, struct image *image, - const char *filename); -extern int render_tiff_int16(DisplayWindow *dw, struct image *image, - const char *filename, double boost); +#endif /* HAVE_GDKPIXBUF */ -#endif /* HAVE_GTK */ +extern int render_tiff_fp(struct image *image, const char *filename, int min_x, + int max_x, int min_y, int max_y); +extern int render_tiff_int16(struct image *image, const char *filename, double boost, + int min_x, int max_x, int min_y, int max_y); #endif /* HDFSEE_RENDER_H */ -- cgit v1.2.3