#!/bin/csh -f
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
#  This is a csh script that uses the Utah Raster Toolket (URT) to
#  convert raw grayscale image date into YUV files suitable for display
#  on the Abekas A60.
#
#  This script also incorporates the new text capability made possible
#  by the IRIS font manager routines.  This is done by creating a text
#  string and putting it in a separate URT file.  This text image can
#  later by composited on top of any image data.
#
#  Author:     Wesley C. Barris
#              AHPCRC
#              Minnesota Supercomputer Center, Inc.
#  Date:       Mar. 15, 1991
#
#  Copyright @ 1991, Minnesota Supercomputer Center, Inc.
#
#  RESTRICTED RIGHTS LEGEND
#
#  Use, duplication, or disclosure of this software and its documentation
#  by the Government is subject to restrictions as set forth in subdivision
#  { (b) (3) (ii) } of the Rights in Technical Data and Computer Software
#  clause at 52.227-7013.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
#  Edit these lines to customize this script.
#
@ aframe = 156					#starting location on Abekas
@ xsize  = 1024					#image X size
@ ysize  = 1024					#image Y size
@ fsize  = 40					#font size
set font = NewCenturySchlbk-Bold		#font name
set files = /work/i3e/sabot-diag/p14d110*	#files to convert
#
#  Make some static text.
#
texttorle Helvetica 70 255 125 50 "GrayToAbekas" \
	| repos -p 230 400 >/tmp/title.rle
#
#  Execute this loop once for each file.
#
foreach file ($files)
#
#  First make some text and specify a position:
#
#             font  point red grn blu  text             xpos ypos
   texttorle $font $fsize 250 250 055 $file:t | repos -p 260 240 >text.rle
#
#  This is a list of what happens in the next chunk.
#  NOTE: Comments cannot be placed within the continuations.
#
#    Convert a raw grayscale image into URT format
#    Flip it right-side-up
#    Scale it to roughly fit the Abekas screen
#    Turn it into an RGB URT file
#    Locate the origin here
#    Crop it to the Abekas size
#    Composite text.rle over this image
#    Composite the title text over this image
#    Convert the whole sh-bang into YUV format
#
   echo "Converting $file..."
   rawtorle -w $xsize -h $ysize -n 1 $file \
	| rleflip -v \
	| rlezoom 0.4 \
	| rleswap -f 0,0,0 \
	| repos -p 150 40 \
	| crop 0 0 719 485 \
	| rlecomp /tmp/title.rle over - \
	| rlecomp text.rle over - \
	| rletoabA60 \
	>/tmp/junk.yuv
   echo "Sending to frame $aframe on the Abekas A60..."
   rcp /tmp/junk.yuv abekas:$aframe
#
#  Increment the frame counter for the Abekas and check if it's full.
#
   @ aframe++
   if ($aframe > 749) then
      echo "The Abekas is full."
      rm /tmp/junk.yuv /usr/tmp/junk1.rle /usr/tmp/text1.rle /tmp/title.rle
      exit
   endif
end
#
#  Clean up shop.
#
rm /tmp/junk.yuv /usr/tmp/junk1.rle /tmp/title.rle
#
#
#  FYI, here are some font names.
#
#
#set font = Boston
#set font = Charter-BlackItalic
#set font = Charter-Black
#set font = Charter-Italic
#set font = Charter-Roman
#set font = Courier
#set font = Courier-Bold
#set font = Courier-BoldOblique
#set font = Courier-Oblique
#set font = Cursor
#set font = GFont
#set font = Helvetica
#set font = Helvetica-Bold
#set font = Helvetica-BoldOblique
#set font = Helvetica-Oblique
#set font = Icon
#set font = International
#set font = Iris
#set font = Kanji
#set font = NineBy
#set font = NewCenturySchlbk-BoldItalic
#set font = NewCenturySchlbk-Bold
#set font = NewCenturySchlbk-Italic
#set font = NewCenturySchlbk-Roman
#set font = Screen
#set font = Screen-Bold
#set font = Symbol
#set font = Space
#set font = Times-Bold
#set font = Times-BoldItalic
#set font = Times-Italic
#set font = Times-Roman
#set font = cursor
#set font = type
