NAME
RgetRow - read one row from a CSF raster file
SYNOPSIS
#include "csf.h"
size_t RgetRow
(
MAP *map,
size_t rowNr,
void *buf
);
PARAMETERS
-
MAP *map
-
map handle
-
size_t rowNr
-
row number to be read
-
void *buf
-
write-only. buffer large enough to hold
cell values of one row in both the file
and in-app cell representation
DESCRIPTION
RgetRow reads one row of cells from a
file.
RETURNS
Number of cells successfully read
EXAMPLE
#include
#include "csf.h"
/* process a raster per row
* minimal checking
*/
extern void DoThatWithRow(REAL4 *, size_t );
void main(int argc, char *argv[] )
{
REAL4 *buf;
MAP *map;
size_t r;
size_t nrOfCells;
if (argc != 2)
{
fprintf(stderr,"%s: no file specified\n",argv[0]);
exit(1);
}
map = Mopen(argv[1], M_READ_WRITE);
if (map == NULL)
{
Mperror(argv[1]);
exit(1);
}
nrOfCells = RgetNrCols(map);
(void)RuseAs(map, CR_REAL4);
buf = (REAL4 *)Rmalloc(map, nrOfCells);
for(r=0; r < RgetNrRows(map); r++ )
{
RgetRow(map, r, buf);
DoThatWithRow(buf, nrOfCells);
RputRow(map,r, buf);
}
Mclose(map);
free(buf);
exit(0);
}