2001.11.20 11:01 "Re: How to display *tiled* RGB TIFFs?", by Bruno LEDOUX
On 20/11/01 10:48, "Ben Fischer" <email@example.com> wrote:
TIFF library fully supports Tiled TIFFs in any of the pixels flavors, we have been using it for years with this kind of images without any problems. Concerning your problem I think it is simply a coding problem whichj causes a buffer overflow (see my comments below),
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 )
uint32 pixels_tile = mpData->mTileWidth * mpData->mTileHeight;
Shouldn't you multiply by the number of chanels (3-> RGB / 4->RGBA) too? You should handle the case of 16bits images too if you are likely to open 3rd parts tiled images.
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 )
unsigned char* ptr_begin = ptr;
unsigned char* raster = ( unsigned char* ) buffer;
for ( k = 0; k < pixels_tile; ++k )
*ptr++ = *raster++;
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(),
( 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?