AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2002.02.20 13:39 "TIFFWriteScanline query...", by Clint Tevlin
2002.02.21 00:06 "RE: TIFFWriteScanline query...", by Kiriakos Georgiou

2002.02.21 00:06 "RE: TIFFWriteScanline query...", by Kiriakos Georgiou

This should help. -K

void tiff::write(const char *filename){

        TIFF *tif_out;
        tsize_t x;
        tsize_t len;

        if (NULL == (tif_out = TIFFOpen (filename, "w")))
                exit (1); /* could not open tif image, simply exit */

        TIFFSetField(tif_out, TIFFTAG_IMAGELENGTH, len=this->len());
        TIFFSetField(tif_out, TIFFTAG_IMAGEWIDTH, this->wid());
        TIFFSetField(tif_out, TIFFTAG_PHOTOMETRIC, this->pho());
        TIFFSetField(tif_out, TIFFTAG_PLANARCONFIG, this->planarconf());
        TIFFSetField(tif_out, TIFFTAG_SAMPLESPERPIXEL, this->samplespp());
        TIFFSetField(tif_out, TIFFTAG_BITSPERSAMPLE, this->bitsps());
        TIFFSetField(tif_out, TIFFTAG_COMPRESSION, this->compr());
        TIFFSetField(tif_out, TIFFTAG_FILLORDER, this->fillord());
        TIFFSetField(tif_out, TIFFTAG_ROWSPERSTRIP, this->rowsps());
        TIFFSetField(tif_out, TIFFTAG_XRESOLUTION, this->xres());
        TIFFSetField(tif_out, TIFFTAG_YRESOLUTION, this->yres());
        TIFFSetField(tif_out, TIFFTAG_SOFTWARE, "libtiff++, kg@olympiakos.com");

        for (x=0; x < len; x++)
                TIFFWriteScanline (tif_out, this->buf + this->scanlinewidth * x, x, 0);

        TIFFClose (tif_out);
}