xp_comm_proj/ReadGeoTiff/libtiff/tif_getimage.c
/*
 * Get an tile-organized image that has
 *	 SamplesPerPixel > 1
 *	 PlanarConfiguration separated
 * We assume that all such images are RGB.
 */
Get an tile-organized image that has
SamplesPerPixel > 1
PlanarConfiguration separated
We assume that all such images are RGB.
Get an tile - organized image that has SamplesPerPixel > 1 PlanarConfiguration separated We assume that all such images are RGB .
static int
gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
{
    TIFF* tif = img->tif;
    tileSeparateRoutine put = img->put.separate;
    uint16 orientation;
    uint32 col, row, y;
    uint32 tw, th;
    unsigned char* buf;
    unsigned char* r;
    unsigned char* g;
    unsigned char* b;
    unsigned char* a;
    tsize_t tilesize;
    int32 fromskew, toskew;
    int alpha = img->alpha;
    uint32 nrow;
    tilesize = TIFFTileSize(tif);
    buf = (unsigned char*) _TIFFmalloc(4*tilesize);
    if (buf == 0) {
	TIFFError(TIFFFileName(tif), "No space for tile buffer");
	return (0);
    }
    r = buf;
    g = r + tilesize;
    b = g + tilesize;
    a = b + tilesize;
    if (!alpha)
	memset(a, 0xff, tilesize);
    TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
    TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
    y = setorientation(img, h);
    orientation = img->orientation;
    toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w);
    for (row = 0; row < h; row += th) {
	nrow = (row + th > h ? h - row : th);
	for (col = 0; col < w; col += tw) {
	    if (TIFFReadTile(tif, r, col, row,0,0) < 0 && img->stoponerr)
		break;
	    if (TIFFReadTile(tif, g, col, row,0,1) < 0 && img->stoponerr)
		break;
	    if (TIFFReadTile(tif, b, col, row,0,2) < 0 && img->stoponerr)
		break;
	    if (alpha && TIFFReadTile(tif,a,col,row,0,3) < 0 && img->stoponerr)
		break;
	    if (col + tw > w) {
		uint32 npix = w - col;
		fromskew = tw - npix;
		(*put)(img, raster+y*w+col, col, y,
		    npix, nrow, fromskew, toskew + fromskew, r, g, b, a);
	    } else {
		(*put)(img, raster+y*w+col, col, y,
		    tw, nrow, 0, toskew, r, g, b, a);
	    }
	}
	y += (orientation == ORIENTATION_TOPLEFT ?
	    -(int32) nrow : (int32) nrow);
    }
    _TIFFfree(buf);
    return (1);
}
static int gtTileSeparate ( TIFFRGBAImage * img , uint32 * raster , uint32 w , uint32 h ) { TIFF * tif = img -> tif ; tileSeparateRoutine put = img -> put . separate ; uint16 orientation ; uint32 col , row , y ; uint32 tw , th ; unsigned char * buf ; unsigned char * r ; unsigned char * g ; unsigned char * b ; unsigned char * a ; tsize_t tilesize ; int32 fromskew , toskew ; int alpha = img -> alpha ; uint32 nrow ; tilesize = TIFFTileSize ( tif ) ; buf = ( unsigned char * ) _TIFFmalloc ( 4 * tilesize ) ; if ( buf == 0 ) { TIFFError ( TIFFFileName ( tif ) , " " ) ; return ( 0 ) ; } r = buf ; g = r + tilesize ; b = g + tilesize ; a = b + tilesize ; if ( ! alpha ) memset ( a , 0xff , tilesize ) ; TIFFGetField ( tif , TIFFTAG_TILEWIDTH , & tw ) ; TIFFGetField ( tif , TIFFTAG_TILELENGTH , & th ) ; y = setorientation ( img , h ) ; orientation = img -> orientation ; toskew = - ( int32 ) ( orientation == ORIENTATION_TOPLEFT ? tw + w : tw - w ) ; for ( row = 0 ; row < h ; row += th ) { nrow = ( row + th > h ? h - row : th ) ; for ( col = 0 ; col < w ; col += tw ) { if ( TIFFReadTile ( tif , r , col , row , 0 , 0 ) < 0 && img -> stoponerr ) break ; if ( TIFFReadTile ( tif , g , col , row , 0 , 1 ) < 0 && img -> stoponerr ) break ; if ( TIFFReadTile ( tif , b , col , row , 0 , 2 ) < 0 && img -> stoponerr ) break ; if ( alpha && TIFFReadTile ( tif , a , col , row , 0 , 3 ) < 0 && img -> stoponerr ) break ; if ( col + tw > w ) { uint32 npix = w - col ; fromskew = tw - npix ; ( * put ) ( img , raster + y * w + col , col , y , npix , nrow , fromskew , toskew + fromskew , r , g , b , a ) ; } else { ( * put ) ( img , raster + y * w + col , col , y , tw , nrow , 0 , toskew , r , g , b , a ) ; } } y += ( orientation == ORIENTATION_TOPLEFT ? - ( int32 ) nrow : ( int32 ) nrow ) ; } _TIFFfree ( buf ) ; return ( 1 ) ; }
Get an tile-organized image that has
       SamplesPerPixel > 1
       PlanarConfiguration separated
 We assume that all such images are RGB.
Get an tile - organized image that has SamplesPerPixel > 1 PlanarConfiguration separated We assume that all such images are RGB .
/*
		 * Tile is clipped horizontally.  Calculate
		 * visible portion and skewing factors.
		 */