aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure15
-rw-r--r--configure.ac9
-rw-r--r--src/displaywindow.c9
-rw-r--r--src/render.c41
4 files changed, 70 insertions, 4 deletions
diff --git a/configure b/configure
index b85ee57e..4b07d22c 100755
--- a/configure
+++ b/configure
@@ -739,6 +739,7 @@ with_gsl
enable_opencl
enable_gtk
enable_gtktest
+with_libtiff
'
ac_precious_vars='build_alias
host_alias
@@ -1388,6 +1389,7 @@ Optional Packages:
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-hdf5 specify location of HDF5 library
--with-gsl specify location of GSL
+ --with-libtiff specify location of libTIFF library
Some influential environment variables:
CC C compiler command
@@ -5719,8 +5721,21 @@ $as_echo "$as_me: error:
fi
+
+# Check whether --with-libtiff was given.
+if test "${with_libtiff+set}" = set; then
+ withval=$with_libtiff; LIBTIFF_CFLAGS="-I$withval/include"
+ LIBTIFF_LIBS="-L$withval/lib -ltiff"
+else
+ LIBTIFF_LIBS="-ltiff"
+fi
+
+
+
CFLAGS="$CFLAGS $HDF5_CFLAGS $GTK_CFLAGS $GSL_CFLAGS $OPENCL_CFLAGS -pthread"
+CFLAGS="$CFLAGS $LIBTIFF_CFLAGS"
LIBS="$LIBS $HDF5_LIBS -lm -lz $GSL_LIBS $GTK_LIBS $OPENCL_LIBS -pthread"
+LIBS="$LIBS $LIBTIFF_LIBS"
ac_config_files="$ac_config_files Makefile src/Makefile data/Makefile"
diff --git a/configure.ac b/configure.ac
index 9fb61bc2..17caaaae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,7 +104,16 @@ else
fi
+AC_ARG_WITH(libtiff,
+[AS_HELP_STRING([--with-libtiff], [specify location of libTIFF library])],
+[LIBTIFF_CFLAGS="-I$withval/include"
+ LIBTIFF_LIBS="-L$withval/lib -ltiff"],
+[LIBTIFF_LIBS="-ltiff"])
+
+
CFLAGS="$CFLAGS $HDF5_CFLAGS $GTK_CFLAGS $GSL_CFLAGS $OPENCL_CFLAGS -pthread"
+CFLAGS="$CFLAGS $LIBTIFF_CFLAGS"
LIBS="$LIBS $HDF5_LIBS -lm -lz $GSL_LIBS $GTK_LIBS $OPENCL_LIBS -pthread"
+LIBS="$LIBS $LIBTIFF_LIBS"
AC_OUTPUT(Makefile src/Makefile data/Makefile)
diff --git a/src/displaywindow.c b/src/displaywindow.c
index 259cb454..1d737748 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -586,9 +586,12 @@ static gint displaywindow_save(GtkWidget *widget, DisplayWindow *dw)
l = gtk_label_new("Save as type:");
gtk_box_pack_end(GTK_BOX(hbox), GTK_WIDGET(l), FALSE, FALSE, 5);
- gtk_combo_box_append_text(GTK_COMBO_BOX(cb), "PNG - 8 bit RGB");
- gtk_combo_box_append_text(GTK_COMBO_BOX(cb), "TIFF - Floating point");
- gtk_combo_box_append_text(GTK_COMBO_BOX(cb), "TIFF - 16 bit integer");
+ gtk_combo_box_append_text(GTK_COMBO_BOX(cb),
+ "PNG - 8 bit RGB (colour, binned)");
+ gtk_combo_box_append_text(GTK_COMBO_BOX(cb),
+ "TIFF - Floating point (mono, unbinned)");
+ gtk_combo_box_append_text(GTK_COMBO_BOX(cb),
+ "TIFF - 16 bit integer (mono, unbinned)");
gtk_combo_box_set_active(GTK_COMBO_BOX(cb), 0);
cd = malloc(sizeof(*cd));
diff --git a/src/render.c b/src/render.c
index e0189b0a..627c5233 100644
--- a/src/render.c
+++ b/src/render.c
@@ -18,6 +18,7 @@
#include <math.h>
#include <stdint.h>
#include <png.h>
+#include <tiffio.h>
#include "hdf5-file.h"
#include "render.h"
@@ -427,7 +428,45 @@ int render_png(DisplayWindow *dw, const char *filename)
int render_tiff_fp(DisplayWindow *dw, const char *filename)
{
- return 1;
+ TIFF *th;
+ struct image *image;
+ float *line;
+ int y;
+
+ /* Get raw, unbinned image data */
+ image = malloc(sizeof(struct image));
+ if ( image == NULL ) return 1;
+ image->features = NULL;
+ image->data = NULL;
+ hdf5_read(dw->hdfile, image);
+ if ( dw->cmfilter ) filter_cm(image);
+ if ( dw->noisefilter ) filter_noise(image, NULL);
+
+ th = TIFFOpen(filename, "w");
+ if ( th == NULL ) return 1;
+
+ TIFFSetField(th, TIFFTAG_IMAGEWIDTH, image->width);
+ TIFFSetField(th, TIFFTAG_IMAGELENGTH, image->height);
+ TIFFSetField(th, TIFFTAG_SAMPLESPERPIXEL, 1);
+ TIFFSetField(th, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
+ TIFFSetField(th, TIFFTAG_BITSPERSAMPLE, 32);
+ TIFFSetField(th, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
+ TIFFSetField(th, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
+ TIFFSetField(th, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+ TIFFSetField(th, TIFFTAG_ROWSPERSTRIP,
+ TIFFDefaultStripSize(th, image->width*4));
+
+ line = _TIFFmalloc(TIFFScanlineSize(th));
+ for ( y=0; y<image->height; y++ ) {
+ memcpy(line, &image->data[(image->height-1-y)*image->width],
+ image->width*4);
+ TIFFWriteScanline(th, line, y, 0);
+ }
+ _TIFFfree(line);
+
+ TIFFClose(th);
+
+ return 0;
}