Received: by cthulhu.engr.sgi.com (940707.SGI.8.6.9/911001.SGI)
	for tiff-list id EAA24812; Sun, 10 Jul 1994 04:46:34 -0700
Return-Path: <owner-tiff>
Received: from sgi.sgi.com by cthulhu.engr.sgi.com via ESMTP (940707.SGI.8.6.9/911001.SGI)
	for <tiff-relay@cthulhu.engr.sgi.com> id EAA24807; Sun, 10 Jul 1994 04:46:30 -0700
Received: from psi.com by sgi.sgi.com via SMTP (940627.SGI.8.6.9/910110.SGI)
	for <tiff@sgi.com> id EAA21142; Sun, 10 Jul 1994 04:46:28 -0700
Received: from etsinc.com (port11.atlanta.ga.pub-ip.psi.net) by psi.com (4.1/2.1-PSI/PSINet)
	id AA28326; Sun, 10 Jul 94 07:46:23 EDT
Received: by etsinc.com (4.1/SMI-4.1)
	id AA02036; Sun, 10 Jul 94 07:46:02 EDT
Date: Sun, 10 Jul 94 07:46:02 EDT
From: dkelly@etsinc.com (Dwight Kelly)
Message-Id: <9407101146.AA02036@etsinc.com>
Subject: tiff separated problem
To: tiff@sgi.sgi.com
Sender: owner-tiff@sgi.sgi.com
Precedence: bulk


I need to write a separated CMYK 1-bit file using the libtiff routines.
There is not a problem when I write one plane at a time, however,
when I try to write one scanline for each color I get a core dump in
DumpEncode. Below is sample code that demonstrates the problem. 


#include <tiffio.h>

int 
main()
{
	TIFF *bitsFile;
	int clr, hpix;
	unsigned char *buf[4];

	bitsFile = TIFFOpen("output.001", "w");
	TIFFSetField(bitsFile, TIFFTAG_IMAGEWIDTH, 2550);
	TIFFSetField(bitsFile, TIFFTAG_IMAGELENGTH, 3300);
	TIFFSetField(bitsFile, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_SEPARATED);
	TIFFSetField(bitsFile, TIFFTAG_INKSET, INKSET_CMYK);
	TIFFSetField(bitsFile, TIFFTAG_SAMPLESPERPIXEL, 4);
	TIFFSetField(bitsFile, TIFFTAG_BITSPERSAMPLE, 1);
	TIFFSetField(bitsFile, TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE);
	for (clr = 0; clr < 4; clr++) {
		buf[clr] = (unsigned char *) malloc(TIFFScanlineSize(bitsFile));
	}
	for (hpix = 0; hpix < 3300; hpix++) {
		for (clr = 0; clr < 4 ; clr++) {
			TIFFWriteScanline(bitsFile, buf[clr], hpix, clr);
		}
	}
	TIFFClose(bitsFile);
	return 0;
}

-- 
Dwight Kelly
Essential Technical Services, Inc.
3375 Summit Trail Cumming, GA 30131
(404) 889-2848  (404) 889-2624 fax
Internet: dkelly@etsinc.com

