Received: from mailgate004.isp.belgacom.be (mailgate004.isp.belgacom.be [195.238.6.89])
	by maildelivery015.isp.belgacom.be (Postfix) with ESMTP id D4D244F803C
	for <joris.at.lebbeke@skynet.be>; Tue,  7 Aug 2007 16:52:24 +0200 (CEST)
Received: from r153.dmsolutions.ca (HELO duke.maptools.org) ([209.217.116.153])
  by in.mx.skynet.be with ESMTP; 07 Aug 2007 16:52:23 +0200
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id l77Efetg013792;
	Tue, 7 Aug 2007 10:41:59 -0400
Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.247])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id l77Efbhj013789
	for <tiff@lists.maptools.org>; Tue, 7 Aug 2007 10:41:38 -0400
Received: by an-out-0708.google.com with SMTP id d31so325717and
	for <tiff@lists.maptools.org>; Tue, 07 Aug 2007 07:41:37 -0700 (PDT)
DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta;
	h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
	b=P5na64S3F3UQV9KgX4EIMuR+V1yDazdyHgH1EDuIhTtOBySMUYXtsIZSu7H5U1cgJ1dSbgMowQ9Zaruc/DtDKAn5GJafffyHCIAXcqKVva2gfm7CT0ieL03fMx+07BXxUTvK8/wgZtxAMaMzaiaVGnPUtOB6axPpC/R2sx+AyMQ=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta;
	h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
	b=V/z6kiaMGLyQP8sCRKZ8wORrV0mv3lMSXMQjGbbZhFQqoA0evoa2bTJ3b77JXs1TKBdL9Qyp7AuZPp/cyZCnkyyBVY/U34ScPboUQuualc+GPdjdEXX1AA05OaEOo+nAIppcOOLag31Xchj+Tc17ifz65EeCLMGsZYXy4RBBcTo=
Received: by 10.100.14.19 with SMTP id 19mr3849830ann.1186497696160;
	Tue, 07 Aug 2007 07:41:36 -0700 (PDT)
Received: by 10.100.141.12 with HTTP; Tue, 7 Aug 2007 07:41:36 -0700 (PDT)
Message-ID: <949801310708070741w676379bevc86ed2de5286ca1d@mail.gmail.com>
Date: Tue, 7 Aug 2007 10:41:36 -0400
From: "Christian Henning" <chhenning@gmail.com>
To: "libtiff - Liste" <tiff@lists.maptools.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Subject: [Tiff] Indexed Images
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.000026ef
X-MSP-STORE: Tue, 07 Aug 2007 16:52:25 +0200
Status:   

Hi there, I'm trying to write a 4-bit indexed image using libtiff
3.8.2 on a Windows machine. For some reasons writing the color map
always crashes and I have no idea why. Here is my code, it's very
straight forward:

int main()
{
   tsize_t width  = 100;
   tsize_t height = 100;
   tsize_t bits_per_sample = 4;
   tsize_t samples_per_pixel = 1;

   tsize_t image_size_in_bytes = ( width * height ) / 2;
   tsize_t palette_size = 16 * 3;

   TIFF* file = TIFFOpen( "palette.tif", "w" );

   TIFFSetField( file, TIFFTAG_IMAGEWIDTH     , width               );
   TIFFSetField( file, TIFFTAG_IMAGELENGTH    , height              );
   TIFFSetField( file, TIFFTAG_BITSPERSAMPLE  , bits_per_sample     );
   TIFFSetField( file, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel   );
   TIFFSetField( file, TIFFTAG_ROWSPERSTRIP   , height              );

   std::vector< short > palette( palette_size );
   std::fill( palette.begin(), palette.end(), 0 );

   TIFFSetField( file, TIFFTAG_COLORMAP, &palette.front() );


   std::vector< unsigned char > image( image_size_in_bytes );
   std::fill( image.begin(), image.end(), 0 );

   TIFFWriteEncodedStrip( file
                        , 0
                        , &image.front()
                        , image_size_in_bytes );

   TIFFClose( file );
}

Can anyone tell me why the line

TIFFSetField( file, TIFFTAG_COLORMAP, &palette.front() );

always crashes?

Thanks a lot,
Christian
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
