# UTILITY SCRIPT NAME : mkras2bit.sh
#              AUTHOR : Bill Facey
#
# ABSTRACT : This utility script converts ia raster image to a
#            bit image with a map header.
#
# INPUT: 3 arguments are input to this script.
#         1st argument - infile - input file
#         2nd argument - out file - output file
#         3rd argument - hgt of chart in terms of scanlines
#
echo "History: FEB     2001 - Initial Implementation"
#
set -x
infile=$1
outfile=$2
hgt=$3

   #----------------------------------------------------------------
   #    Pack 8 bit pixels into one bit bits
   #----------------------------------------------------------------

   export pgm=ras2bit;. prep_step

   export XLFUNIT_11="$infile"
   export XLFUNIT_59="ras2bit.out"

   fssize=`cat $infile | wc -c`

   echo $fssize  >fin         # raster file size
   echo 1728 >>fin       # pixels per scan line
   echo $hgt >>fin       # number of scan lines

   msg="$pgm start"
   postmsg "$jlogfile" "$msg"

   $EXECgraph/ras2bit < fin   >> $pgmout 2>> errfile
   err=$?; export err; err_chk
 #
   #----------------------------------------------------------------
   # now have bit image but need cntr map header
   # attach cntr map header to bitstream beginning
   #----------------------------------------------------------------

   if test $hgt -gt 1500
   then
     cp $FIXgraph/graph_fdfax.header fdfax.header
   else
     cp $FIXgraph/graph_fdfax_small.header fdfax.header
   fi
   cat fdfax.header ras2bit.out > "$outfile"

exit



