AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2001.11.20 09:48 "How to display *tiled* RGB TIFFs?", by Ben Fischer
2001.11.20 11:01 "Re: How to display *tiled* RGB TIFFs?", by Bruno LEDOUX

2001.11.20 09:48 "How to display *tiled* RGB TIFFs?", by Ben Fischer

I have a problem with displaying RGB(A) images that are tiled. First of all: Is the TIFFReadTile command correctly able to read tiled RGB images?

8 bit Grayscale images are no problem, but the tiles get messed up when I try to display RGB images.

I use this to read the tiles:

tdata_t buffer = _TIFFmalloc( TIFFTileSize( mpData->mpTiffFile ) ); if ( NULL == buffer )

        return false;

uint32 pixels_tile = mpData->mTileWidth * mpData->mTileHeight;

uint32 x = j * mpData->mTileWidth;
uint32 y = i * mpData->mTileHeight;

TIFFReadTile( mpData->mpTiffFile, buffer, x, y, 0, 0 );

unsigned char* ptr = new unsigned char [pixels_tile];
if ( 0 == ptr )
        return false;
unsigned char* ptr_begin = ptr;
unsigned char* raster = ( unsigned char* ) buffer;
uint32 k;
for ( k = 0; k < pixels_tile; ++k )
       *ptr++ = *raster++;
delete mpData->mpTileTable[i][j];
mpData->mpTileTable[i][j] = ptr_begin;
_TIFFfree( buffer );

And then I use this to display them:

for ( int row = mTileOffsetY; row < max_index_y; ++row )
{
 for ( int column = mTileOffsetX; column < max_index_x; ++column )
 {
  glDrawPixels( ( GLsizei ) pImage->GetTileWidth(),
                ( GLsizei ) pImage->GetTileHeight(),
                  GL_RGB,
                  GL_UNSIGNED_BYTE,
                ( GLvoid* ) pImage->GetTile( row, column ));

  glBitmap( 0, 0, 0.0f, 0.0f, move_x,
            0.0f, NULL );
 }
 glBitmap( 0, 0, 0.0f, 0.0f,
                  -mTilesX * move_x,
                  -move_y, NULL );
}

Any ideas what I am doing wrong?

Thanks,

Ben Fischer