next up previous
Next: READMAP - read Up: C Examples Previous: MAKEBIGIO - make

READBIGIO - read a big image

/*   READBIGIO.C - read and print all the values in a bigimage */

#include <stdio.h>
#include <errno.h>

#include "bigio.h"

int main ( int argc, char **argv )
{
   char mapname[132];        /* name of directory to hold bigimage */
   int bd;                   /* bigimage descriptor */
   int status;               /* status */
   short values[20];         /* values read from the bigimage */
   int lane;                 /* lane number */
   int row;                  /* row number */
   int j;                    /* loop counter */
   char errmsg[80];          /* error message */

/*   Initialise a row of pixel values */

   for ( j=0; j<20; j++ )
   {
      values[j] = (short)0;
   }

/*   Extract the mapname, which is the name of the directory to hold the
     bigimage */

   if ( argc == 2 )
   {
      strcpy ( mapname, argv[1] );
      status = 0;

/*   Open the bigimage, read the data a row at a time and print it. */

      bigio_open ( mapname, "update", &bd, &status );
      if ( status != 0 )
      {
         printf ( "failed to open map\n" );
         bigio_errtran ( 80, errmsg, &status );
         printf ( "%s\n", errmsg );
      }
      else
      {
         for ( lane=1; lane<=3; lane++ )
         {
            for ( row=1; row<=30; row++ )
            {
               bigio_getrow ( bd, lane, row, (char *)values, &status );
              for ( j=0; j<20; j++ )
              {
                 printf ( "%d ", values[j] );
              }
              printf ( "\n" );
            }
         }
         if ( status != 0 )
         {
            printf ( "failed to read map\n" );
            bigio_errtran ( 80, errmsg, &status );
            perror ( errmsg );
         }
      }
   }
   else
   {
      printf ( "readbigio: usage:- readbigio mapname\n" );
   }
   return 0;
}



SuperCOSMOS development
Tue Aug 20 12:02:13 BST 1996