- 2007.08.07 03:46 "[Tiff] bilevel image scrambling when size not divisible by 8", by Lee Cooper
- 2007.08.07 14:48 "Re: [Tiff] Indexed Images", by Toby Thain
- 2007.08.07 15:23 "Re: [Tiff] Indexed Images", by Frank Warmerdam
- 2007.08.13 22:43 "[Tiff] 16-bit palette image", by Christian Henning
2007.08.07 14:41 "[Tiff] 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