Commit e05ea5a2 authored by Thomas White's avatar Thomas White
Browse files

hdfsee: Add floating point TIFF exporter

parent 094d9271
......@@ -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"
......
......@@ -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)
......@@ -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));
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment