xp_comm_proj/ReadGeoTiff/libtiff/tif_getimage.c
/*
 * Get a strip-organized image with
 *	 SamplesPerPixel > 1
 *	 PlanarConfiguration separated
 * We assume that all such images are RGB.
 */
Get a strip-organized image with
SamplesPerPixel > 1
PlanarConfiguration separated
We assume that all such images are RGB.
Get a strip - organized image with SamplesPerPixel > 1 PlanarConfiguration separated We assume that all such images are RGB .
static int
gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
{
    TIFF* tif = img->tif;
    tileSeparateRoutine put = img->put.separate;
    uint16 orientation;
    unsigned char *buf;
    unsigned char *r, *g, *b, *a;
    uint32 row, y, nrow;
    tsize_t scanline;
    uint32 rowsperstrip;
    uint32 imagewidth = img->width;
    tsize_t stripsize;
    int32 fromskew, toskew;
    int alpha = img->alpha;
    stripsize = TIFFStripSize(tif);
    r = buf = (unsigned char *)_TIFFmalloc(4*stripsize);
    if (buf == 0) {
	TIFFError(TIFFFileName(tif), "No space for tile buffer");
	return (0);
    }
    g = r + stripsize;
    b = g + stripsize;
    a = b + stripsize;
    if (!alpha)
	memset(a, 0xff, stripsize);
    y = setorientation(img, h);
    orientation = img->orientation;
    toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w);
    TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
    scanline = TIFFScanlineSize(tif);
    fromskew = (w < imagewidth ? imagewidth - w : 0);
    for (row = 0; row < h; row += rowsperstrip) {
	nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
	if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
	    r, nrow*scanline) < 0 && img->stoponerr)
	    break;
	if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 1),
	    g, nrow*scanline) < 0 && img->stoponerr)
	    break;
	if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 2),
	    b, nrow*scanline) < 0 && img->stoponerr)
	    break;
	if (alpha &&
	    (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 3),
	    a, nrow*scanline) < 0 && img->stoponerr))
	    break;
	(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, r, g, b, a);
	y += (orientation == ORIENTATION_TOPLEFT ?
	    -(int32) nrow : (int32) nrow);
    }
    _TIFFfree(buf);
    return (1);
}
static int gtStripSeparate ( TIFFRGBAImage * img , uint32 * raster , uint32 w , uint32 h ) { TIFF * tif = img -> tif ; tileSeparateRoutine put = img -> put . separate ; uint16 orientation ; unsigned char * buf ; unsigned char * r , * g , * b , * a ; uint32 row , y , nrow ; tsize_t scanline ; uint32 rowsperstrip ; uint32 imagewidth = img -> width ; tsize_t stripsize ; int32 fromskew , toskew ; int alpha = img -> alpha ; stripsize = TIFFStripSize ( tif ) ; r = buf = ( unsigned char * ) _TIFFmalloc ( 4 * stripsize ) ; if ( buf == 0 ) { TIFFError ( TIFFFileName ( tif ) , " " ) ; return ( 0 ) ; } g = r + stripsize ; b = g + stripsize ; a = b + stripsize ; if ( ! alpha ) memset ( a , 0xff , stripsize ) ; y = setorientation ( img , h ) ; orientation = img -> orientation ; toskew = - ( int32 ) ( orientation == ORIENTATION_TOPLEFT ? w + w : w - w ) ; TIFFGetFieldDefaulted ( tif , TIFFTAG_ROWSPERSTRIP , & rowsperstrip ) ; scanline = TIFFScanlineSize ( tif ) ; fromskew = ( w < imagewidth ? imagewidth - w : 0 ) ; for ( row = 0 ; row < h ; row += rowsperstrip ) { nrow = ( row + rowsperstrip > h ? h - row : rowsperstrip ) ; if ( TIFFReadEncodedStrip ( tif , TIFFComputeStrip ( tif , row , 0 ) , r , nrow * scanline ) < 0 && img -> stoponerr ) break ; if ( TIFFReadEncodedStrip ( tif , TIFFComputeStrip ( tif , row , 1 ) , g , nrow * scanline ) < 0 && img -> stoponerr ) break ; if ( TIFFReadEncodedStrip ( tif , TIFFComputeStrip ( tif , row , 2 ) , b , nrow * scanline ) < 0 && img -> stoponerr ) break ; if ( alpha && ( TIFFReadEncodedStrip ( tif , TIFFComputeStrip ( tif , row , 3 ) , a , nrow * scanline ) < 0 && img -> stoponerr ) ) break ; ( * put ) ( img , raster + y * w , 0 , y , w , nrow , fromskew , toskew , r , g , b , a ) ; y += ( orientation == ORIENTATION_TOPLEFT ? - ( int32 ) nrow : ( int32 ) nrow ) ; } _TIFFfree ( buf ) ; return ( 1 ) ; }
Get a strip-organized image with
       SamplesPerPixel > 1
       PlanarConfiguration separated
 We assume that all such images are RGB.
Get a strip - organized image with SamplesPerPixel > 1 PlanarConfiguration separated We assume that all such images are RGB .