AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
August 2007

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2007.08.07 14:41 "Indexed Images", by Christian Henning
2007.08.07 14:48 "Re: Indexed Images", by Toby Thain
2007.08.07 15:23 "Re: Indexed Images", by Frank Warmerdam
2007.08.07 15:41 "Re: Indexed Images", by Toby Thain
2007.08.07 14:57 "Re: Indexed Images", by Christian Henning

2007.08.07 14:41 "Indexed Images", by Christian Henning

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