summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-07-31 20:34:14 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-07-31 20:34:14 +0200
commitff7773a8da615e4dc91320636beb4e6877777a01 (patch)
tree990349d8a1fbeea99f73fb37e41bed44d0c1d462
parentd258151391bead3a167f54068096a8d727ba273a (diff)
initial tiff write support
-rw-r--r--configure.ac4
-rw-r--r--src/DataImage.H2
-rw-r--r--src/DataImage.cxx32
-rw-r--r--src/gipfel.cxx1
4 files changed, 39 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 6d4f557..74c693a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,5 +52,9 @@ LIBS="`$FLTKCONFIG --use-images --ldflags` $LIBS"
AC_CHECK_HEADERS([ccmath.h], [], [echo "Error: ccmath.h not found."; exit 1;])
AC_CHECK_LIB([ccm], [open], [], [echo "Error: ccmath.so not found."; exit 1;])
+# Check for libtiff
+AC_CHECK_HEADERS([tiffio.h], [], [echo "Error: tiffio.h not found."; exit 1;])
+AC_CHECK_LIB([tiff], [TIFFOpen], [], [echo "Error: libtiff.so not found."; exit 1;])
+
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
diff --git a/src/DataImage.H b/src/DataImage.H
index 49cd952..a8fb100 100644
--- a/src/DataImage.H
+++ b/src/DataImage.H
@@ -40,6 +40,8 @@ class DataImage : public Fl_Widget {
int write_jpeg(const char *file, int quality);
+ int write_tiff(const char *file);
+
static int get_pixel(Fl_Image *img, int x, int y,
char *r, char *g, char *b);
diff --git a/src/DataImage.cxx b/src/DataImage.cxx
index f7968b2..2f1ad80 100644
--- a/src/DataImage.cxx
+++ b/src/DataImage.cxx
@@ -25,6 +25,7 @@
#include <math.h>
extern "C" {
#include <jpeglib.h>
+#include <tiffio.h>
}
#include <Fl/fl_draw.h>
@@ -161,3 +162,34 @@ DataImage::write_jpeg(const char *file, int quality) {
return 0;
}
+
+int
+DataImage::write_tiff(const char *file) {
+ TIFF *output;
+ uint32 width, height;
+ char *raster;
+
+ // Open the output image
+ if((output = TIFFOpen(file, "w")) == NULL){
+ fprintf(stderr, "can't open %s\n", file);
+ return 1;
+ }
+
+ // Write the tiff tags to the file
+ TIFFSetField(output, TIFFTAG_IMAGEWIDTH, w());
+ TIFFSetField(output, TIFFTAG_IMAGELENGTH, h());
+ TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE);
+ TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+ TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
+ TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, 8);
+ TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, 3);
+
+ // Actually write the image
+ if(TIFFWriteEncodedStrip(output, 0, data, w() * h() * 3) == 0){
+ fprintf(stderr, "Could not write image\n");
+ return 2;
+ }
+
+ TIFFClose(output);
+ return 0;
+}
diff --git a/src/gipfel.cxx b/src/gipfel.cxx
index acdd1de..309ee9d 100644
--- a/src/gipfel.cxx
+++ b/src/gipfel.cxx
@@ -435,6 +435,7 @@ int stitch(int stitch_w, int stitch_h, int argc, char **argv) {
st->resample(img, 0.0, 7.0);
img->write_jpeg("/tmp/bla.jpg", 90);
+ img->write_tiff("/tmp/bla.tiff");
Fl::run();
exit(0);
}