#!/bin/csh -f
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
#  This is a csh script that uses the Utah Raster Toolket (URT) to
#  convert raw RGB 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 the following lines to customize this script.
#
@ aframe = 600				#starting location on Abekas
@ xsize  = 256				#image X size
@ ysize  = 256				#image Y size
@ fsize  = 40				#font size
set font = NewCenturySchlbk-Bold	#font name
#  NOTE: The following line must have an "*" in it (probably at the end).
set files = /work/i3e/s10/movies/s10*	#pathname of files to convert
#
#  Make some text to be placed at the top of all images.
#
texttorle Helvetica 50 0 0 250 "RGBToAbekas" | repos -p 250 380 >/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 RGB image into URT format
#    Flip it right-side-up
#    Scale it to roughly fit the Abekas screen
#    Locate the origin here
#    Composite text.rle over this image
#    Composite the title text over this image
#    Crop the image to fit the Abekas perfectly
#    Convert the whole sh-bang into YUV format
#
   echo "Converting $file..."
   rawtorle -w $xsize -h $ysize -n 3 -N $file \
	| rleflip -v \
	| fant -p 0 0 -s 0.8 0.8\
	| 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 /tmp/title.rle
      exit
   endif
end
#
#  Clean up shop.
#
rm /tmp/junk.yuv /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
