AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2002.03.19 17:54 "I don't want multiple strips", by Stephen Rasku
2002.03.19 18:02 "Re: I don't want multiple strips", by Dwight Kelly
2002.03.19 18:12 "Re: I don't want multiple strips", by Stephen Rasku

2002.03.19 17:54 "I don't want multiple strips", by Stephen Rasku

The attached program generates a TIFF file that tiffinfo doesn't like. I want all the rows in one strip but it creates multiple strip offsets and when I run tiffinfo on the generated tiff, I get:

tiffcreate.tif: Warning, incorrect count for field "StripOffsets" (10, expecting 1); tag ignored.

Stephen Rasku                   E-mail: stephen@tgivan.com
Senior Software Engineer      Web:    http://www.pop-star.net/
TGI Technologies

/************************************************************************
 *   Entity Id         : $Id$
 *   Package              : tiff
 *   Purpose              :
 *
 *   Date of Creation        : Feb 27, 2002
 *   Version Number       : $Revision$
 *   Last Updated   : $Date$
 *
 *   Functions                :
 *
 *   Author          : Stephen Rasku
 *   Notes               :
 *
 *   Copyright 2002 by TGI Technologies Ltd.  All rights reserved.
 ************************************************************************/

#ifndef lint
static const char tiffcreate_c_id[] = "@(#) tiff::tiffcreate.c       $Revision$";
#endif

#define __tiffcreate_c
#include <stdio.h>
#include <stdarg.h>
#include "tiffio.h"

#define OUTFILE         "tiffcreate.tif"
#define NUMROWS         10
#define IMAGE_WIDTH   16
#define BYTES_PER_BUF IMAGE_WIDTH/8

unsigned char blackbuf[BYTES_PER_BUF];
unsigned char whitebuf[BYTES_PER_BUF];

void myHandler(const char *module, const char *fmt, va_list ap)
{
    fprintf(stderr, "%s: ", module);
    fprintf(stderr, fmt, ap);
    fprintf(stderr, "\n");
}

main(int argc, char *argv[])
{

    TIFFSetErrorHandler(myHandler);
    do {
   TIFF *tif;
      int row;

        memset(blackbuf, -1, BYTES_PER_BUF);
    memset(whitebuf, 0, BYTES_PER_BUF);

     if ( !( tif = TIFFOpen(OUTFILE, "w") ) )
        {
           fprintf(stderr, "%s: Error opening file %s\n", argv[0], OUTFILE);
       break;
      }

       if ( !(TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX3) &&
     TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (unsigned)IMAGE_WIDTH) &&
         TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (unsigned)NUMROWS) &&
            TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, (unsigned)NUMROWS) &&
           TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG) &&
         TIFFSetField(tif, TIFFTAG_YRESOLUTION, 196.) &&
         TIFFSetField(tif, TIFFTAG_XRESOLUTION, 204.) ) ) break;
     for (row = 0; row < NUMROWS; ++row)
        if ( TIFFWriteEncodedStrip(tif, row, row % 2 ? blackbuf : whitebuf,
          BYTES_PER_BUF) == -1) break;

    TIFFWriteDirectory(tif);

        TIFFClose(tif);
    } while(0);
    return(1);
}