next up previous
Next: WRITEMAP - write Up: C Examples Previous: READBIGIO - read

READMAP - read a map from a big image

/*   READMAP - read a test area from a big image */


#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[200];        /* values read from the bigimage */
   int j;                    /* loop counter */
   int i;                    /* loop counter */
   char errmsg[80];          /* error message */

/*   Initialise the input array */

   for ( j=0; j<200; 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, extract a 2-D rectangular map from it, and print
     out the map */

      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
      {
         bigio_getmap ( bd, 5, 5, 14, 24, (char *)values, &status );
         for ( j=0; j<20; j++ )
         {
            for ( i=0; i<10; i++ )
            {
               printf ( "%d ", (int)values[j*10+i] );
            }
            printf ( "\n" );
         }

         if ( status != 0 )
         {
            printf ( "failed to read map\n" );
            bigio_errtran ( 80, errmsg, &status );
            perror ( errmsg );
         }
      }
   }
   else
   {
      printf ( "readmap: usage:- readmap mapname\n" );
   }
   return 0;
}



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