diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2006-07-31 20:34:14 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2006-07-31 20:34:14 +0200 |
commit | ff7773a8da615e4dc91320636beb4e6877777a01 (patch) | |
tree | 990349d8a1fbeea99f73fb37e41bed44d0c1d462 /src/DataImage.cxx | |
parent | d258151391bead3a167f54068096a8d727ba273a (diff) |
initial tiff write support
Diffstat (limited to 'src/DataImage.cxx')
-rw-r--r-- | src/DataImage.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
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; +} |