| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2007.08.07 14:57 "Re: Indexed Images", by Christian HenningThanks for the hint. But that's not it. The following crashes too:
short* p = new short[ palette_size ];
std::fill( p, p + palette_size, 0 );
TIFFSetField( file, TIFFTAG_COLORMAP, p );
std::vector should be compatible with c arrays, anyway.
Christian
On 8/7/07, Toby Thain <toby@smartgames.ca> wrote:
>
> On 7-Aug-07, at 11:41 AM, Christian Henning wrote:
>
> > 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?
>
> For one reason, I expect it wants a pointer to C array of short, not
> an STL vector.
>
> --Toby
>
> >
> > Thanks a lot,
> > Christian
> > _______________________________________________
> > Tiff mailing list: Tiff@lists.maptools.org
> > http://lists.maptools.org/mailman/listinfo/tiff
> > http://www.remotesensing.org/libtiff/
>
>
|
|||||||