[Gdal-dev] question on RawRasterBand constructor

Frank Warmerdam warmerdam at pobox.com
Fri Aug 31 12:58:55 EDT 2007


Jared Rubin wrote:
> what exactly are nPixelOffset and nLineOffset? I am using the RawRasterBand 
> class and I have an internally developed image file type from work that is 
> scan line orientated, not tiled.  It would seem that the offsets are if you 
> want to skip over image pixels. Our image file type is stored contigously  in 
> memory where the 1st row of image pixels is followed by the 2nd row, followed 
> by the 3rd row, etc.. So I thought that the RawRasterBand would be used to 
> just read in a row of pixels at a time. 
> 
> 
> RawRasterBand::RawRasterBand( FILE * fpRaw, vsi_l_offset nImgOffset,
>                               int nPixelOffset, int nLineOffset,
>                               GDALDataType eDataType, int bNativeOrder,
>                               int nXSize, int nYSize, int bIsVSIL )

Jared,

The arguments to the RawRasterBand are intended to describe the layout
of the data on the disk file referenced by fpRaw.

nPixelOffset is the byte offset from the start of one pixel to the start
of the next on the same scanline.

nLineOffset is the byte offset from the start of one scanline to the
start of the next.

With appropriate values these can be used to described a variety of
interleaving schemes.

For a single band image 8bit image on disk with tight packing, the
nPixelOffset would be 1, and nLineOffset would be the width of the
image.  But if you have a 3 band 16bit pixel intereleaved file,
nPixelOffset would be 6 and LineOffset would be nXSize * 6.  If
the same data was line interleaved nPixelOffset would be 2, and
nLineOffset would be nXSize * 6.

I hope that helps a bit.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list