[comp.sources.x] v10i079: xv - display and manipulate images, Part01/10

bradley@halibut.cis.upenn.edu (John Bradley) (11/28/90)

Submitted-by: bradley@halibut.cis.upenn.edu (John Bradley)
Posting-number: Volume 10, Issue 79
Archive-name: xv/part01

Sources to XV, patchlevel 2.  Lots of bug fixes, '#ifdefs' for various 
machines, and some new features.

Overview (from the man page)
_____________
xv is an X11 program that displays images in the GIF, PBM, PGM, PPM, 
X11 bitmap, and PM formats on 1-, 4-, 6-, 8-, 24-, and 32-bit X displays.  

xv displays one image at a time in an output window.  You can arbitrarily
stretch or compress the window, and the picture will be rescaled to fit.  
You can rotate the picture in 90-degree steps.  You can repeatedly 'crop'
a picture (define a rectangular 'region-of-interest' and 'throw away' the
rest).  You can magnify any portion of the picture by 
any amount, up to the maximum size of your screen.  
_____________

New Features:  bi-direction rotation, 'maxpect' button (maximum size, but
preserve aspect ratio), 'autocrop' button (gets rid of constant-color borders),
new ability to center pictures on the root window.

This is complete posting, as A) the patches would've been nearly as large, and
B) considering the problems of the previous postings...

Also, this is all available for anonymous ftp from expo.lcs.mit.edu, as
contrib/xv.pl2.tar.Z.

John Bradley  -  GRASP Lab  -  University of Pennsylvania
     bradley@cis.upenn.edu

----------------------------(cut here)------------------------
#!/bin/sh
# to extract, remove the header and type "sh filename"
if `test ! -d ./docs`
then
  mkdir ./docs
  echo "mkdir ./docs"
fi
if `test ! -s ./docs/xv.blurb`
then
echo "writting ./docs/xv.blurb"
cat > ./docs/xv.blurb << '\BARFOO\'
XV is a direct successor to XGIF.  

New features include:
  * more graphic formats supported (GIF, PBM/PGM/PPM, and X11 bitmap)

  * works on most X displays (1-, 4-, 6-, 8-, and 24-bit displays are
    supported)

  * arbitrary scaling, cropping, rotation (in 90-degree steps)

  * can write files in all formats listed above

  * arbitrary gamma correction curve for brightness/contrast control
    and interesting effects

  * cool-whizo user interface

  * better color allocation code, including the ability to install its own
    colormap if necessary

  * more robust error handling

  * and more bug fixes than we'd care to discuss...


Full Description:
-----------------
XV is a program that displays image files in GIF, PBM/PGM/PPM, and X11 Bitmap
formats.  It is a direct sequel to XGIF, and fixes most (if not all) of the
shortcomings of that program.  XV runs on nearly ALL X displays, 1-bit,
4-bit, 6-bit, 8-bit, and 24-bit, color, grayscale, and black/white.  

XV displays one image at a time in an output window.  You can arbitrarily
stretch or compress the window, and the picture will be rescaled to fit.  
You can rotate the picture in 90-degree steps.  You can repeatedly 'crop'
a picture (define a rectangular 'region-of-interest' and 'throw away' the
rest).  You can magnify any portion of the picture by any amount, up to the 
maximum size of your screen.  

XV allows you click on the picture to determine pixel RGB values and x,y 
coordinates.  You can perform arbitrary 'gamma correction' on the picture
both in RGB space and HSV space.  You can specify the maximum number of colors
that XV should use, for some interesting visual effects.  You can have
the program produce a stippled version of the picture using black and white,
or any other pair of colors.  

XV can write images in a variety of formats, with many of the modifications 
you may have made to the picture saved as well.  You can use XV to do format 
conversion.  XV will also automatically uncompress compress-ed files, as well 
as read files from stdin.


John Bradley                    University of Pennsylvania  -  GRASP Lab
     bradley@cis.upenn.edu

     October 9, 1990
\BARFOO\
else
  echo "will not over write ./docs/xv.blurb"
fi
if `test ! -s ./bitmaps.h`
then
echo "writting ./bitmaps.h"
cat > ./bitmaps.h << '\BARFOO\'
#define grasp_width 64
#define grasp_height 64
static char grasp_bits[] = {
   0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
   0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x05, 0x00, 0x00,
   0x00, 0x00, 0xfc, 0xff, 0xff, 0xbf, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0x01, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
   0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xf0, 0xff, 0xff,
   0xff, 0xff, 0x0f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xc0, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0x07,
   0x54, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0x00, 0xc0, 0xff, 0x07,
   0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0x0f, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0xfe, 0x1f, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xf8, 0x3f,
   0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0xff, 0xff, 0x1f, 0x00,
   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
   0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00,
   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xf8, 0x01, 0x03, 0x8f, 0x3f,
   0xff, 0xff, 0xfc, 0xf9, 0x83, 0x83, 0x9f, 0x7f, 0xff, 0x7f, 0xfe, 0xfb,
   0x87, 0xc7, 0xbf, 0x7f, 0xff, 0x3f, 0x8e, 0x3b, 0xc7, 0xc7, 0xb9, 0x73,
   0x00, 0x00, 0x0e, 0x38, 0xc7, 0xce, 0x83, 0x73, 0x00, 0x00, 0xee, 0xbb,
   0xc7, 0x8e, 0x8f, 0x7b, 0x00, 0x00, 0xee, 0xfb, 0xe3, 0x0f, 0x9f, 0x3f,
   0x00, 0x00, 0x8e, 0xfb, 0xe1, 0x1f, 0xb8, 0x1f, 0x00, 0x00, 0x9e, 0xbb,
   0xe3, 0xde, 0xb9, 0x03, 0x00, 0x00, 0xfc, 0xbb, 0x73, 0xdc, 0xbf, 0x03,
   0x00, 0x00, 0xfc, 0x39, 0x77, 0xb8, 0x9f, 0x03, 0x00, 0x00, 0xf0, 0x38,
   0x77, 0x38, 0x8f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x10, 0x20,
   0x00, 0x40, 0x00, 0x00, 0xff, 0x7f, 0x10, 0xec, 0xee, 0xec, 0xee, 0x0a,
   0xff, 0xff, 0x10, 0xaa, 0x2a, 0x4a, 0x2a, 0x0a, 0xff, 0xff, 0xf1, 0xfe,
   0x2e, 0xde, 0x2e, 0x0e, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x08,
   0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0xff, 0x0f, 0x00,
   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
   0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0xff, 0xff, 0x7f, 0x00,
   0x00, 0x00, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xfe, 0x1f,
   0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0x0f, 0xff, 0xff, 0xff, 0x03,
   0x00, 0xc0, 0xff, 0x07, 0xfe, 0xff, 0xff, 0x07, 0x54, 0xff, 0xff, 0x03,
   0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xe0, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff,
   0xff, 0xff, 0x1f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
   0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x80, 0xff, 0xff,
   0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x01, 0x00,
   0x00, 0x00, 0xf8, 0xff, 0xff, 0xbf, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
   0xff, 0x05, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x17, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0x00};
#define penn_width 64
#define penn_height 64
static char penn_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
   0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x18, 0x00, 0x00,
   0x00, 0x00, 0x18, 0x00, 0x00, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x1b, 0x00,
   0x00, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x1b, 0x00, 0x00, 0xd8, 0xab, 0xff,
   0xff, 0xd5, 0x1b, 0x00, 0x00, 0x58, 0x7d, 0xfd, 0xbf, 0xbe, 0x1a, 0x00,
   0x00, 0xd8, 0x93, 0x1f, 0xf7, 0xc9, 0x1b, 0x00, 0x00, 0x58, 0x01, 0x0d,
   0xb2, 0x80, 0x1a, 0x00, 0x00, 0xd8, 0x11, 0xef, 0xee, 0x88, 0x1b, 0x00,
   0x00, 0x58, 0x01, 0x15, 0xad, 0x80, 0x1a, 0x00, 0x00, 0xd8, 0x11, 0x67,
   0xe2, 0x88, 0x1b, 0x00, 0x00, 0x58, 0x01, 0xf5, 0xb1, 0x80, 0x1a, 0x00,
   0x00, 0xd8, 0x39, 0xff, 0xff, 0x9c, 0x1b, 0x00, 0x00, 0x58, 0xff, 0xfd,
   0xbf, 0xff, 0x1a, 0x00, 0x00, 0xd8, 0xaa, 0xfe, 0x7f, 0x55, 0x1b, 0x00,
   0x00, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x1b, 0x00, 0x00, 0xd8, 0xff, 0xff,
   0xff, 0xff, 0x1b, 0x00, 0x00, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x1b, 0x00,
   0x00, 0x58, 0x00, 0x80, 0x01, 0x00, 0x1a, 0x00, 0x00, 0x58, 0x00, 0xc0,
   0x03, 0x00, 0x1a, 0x00, 0x00, 0x58, 0x00, 0xe0, 0x07, 0x00, 0x1a, 0x00,
   0x00, 0x58, 0x00, 0xf0, 0x0f, 0x00, 0x1a, 0x00, 0x00, 0x58, 0x00, 0xf8,
   0x1f, 0x00, 0x1a, 0x00, 0x00, 0x58, 0x00, 0x7c, 0x3e, 0x00, 0x1a, 0x00,
   0x00, 0x58, 0x00, 0x1e, 0x78, 0x00, 0x1a, 0x00, 0x00, 0x98, 0x00, 0x1f,
   0xf8, 0x00, 0x19, 0x00, 0x00, 0xb8, 0x80, 0x0f, 0xf0, 0x01, 0x1d, 0x00,
   0x00, 0xb0, 0xc0, 0x0f, 0xf0, 0x03, 0x0d, 0x00, 0x00, 0xb0, 0xe0, 0x1f,
   0xf8, 0x07, 0x0d, 0x00, 0x00, 0xb0, 0xf0, 0x1f, 0xf8, 0x0f, 0x0d, 0x00,
   0x00, 0x30, 0x79, 0x7e, 0x7e, 0x9e, 0x0c, 0x00, 0x00, 0x60, 0x1d, 0xf8,
   0x1f, 0xb8, 0x06, 0x00, 0x00, 0x60, 0x1f, 0xf8, 0x1f, 0xf8, 0x06, 0x00,
   0x00, 0x60, 0x0e, 0xf0, 0x0f, 0x70, 0x06, 0x00, 0x00, 0xc0, 0x0e, 0xf0,
   0x0f, 0x70, 0x03, 0x00, 0x00, 0xc0, 0x1c, 0x78, 0x1e, 0x38, 0x03, 0x00,
   0x00, 0x80, 0x1d, 0x38, 0x1c, 0xb8, 0x01, 0x00, 0x00, 0x80, 0x79, 0x1e,
   0x78, 0x9e, 0x01, 0x00, 0x00, 0x00, 0xfb, 0x0f, 0xf0, 0xdf, 0x00, 0x00,
   0x00, 0x00, 0xf3, 0x07, 0xe0, 0xcf, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x03,
   0xc0, 0x67, 0x00, 0x00, 0x00, 0x00, 0xec, 0x01, 0x80, 0x37, 0x00, 0x00,
   0x00, 0x00, 0xcc, 0x00, 0x00, 0x33, 0x00, 0x00, 0x3c, 0x00, 0x98, 0x00,
   0x00, 0x19, 0x00, 0x3c, 0x6e, 0x78, 0x30, 0x01, 0x80, 0x0c, 0x1e, 0x76,
   0xda, 0x87, 0x60, 0x06, 0x60, 0x06, 0xe1, 0x5b, 0xfa, 0x88, 0xc1, 0x08,
   0x10, 0x83, 0x19, 0x5f, 0x1a, 0x46, 0x81, 0x33, 0xcc, 0x81, 0x72, 0x59,
   0xda, 0x70, 0x01, 0xc7, 0xe3, 0x80, 0x0e, 0x59, 0x96, 0xbf, 0x01, 0x1c,
   0x38, 0x80, 0xfd, 0x69, 0x60, 0x8a, 0x07, 0x78, 0x1e, 0xe0, 0x59, 0x06,
   0xc0, 0xcb, 0x1d, 0xe0, 0x07, 0xb8, 0xd3, 0x03, 0xc0, 0x69, 0xf0, 0x80,
   0x01, 0x0f, 0x96, 0x03, 0x00, 0x08, 0x09, 0x1f, 0xf8, 0x60, 0x10, 0x00,
   0x00, 0x90, 0x5d, 0xe0, 0x07, 0xf6, 0x08, 0x00, 0x00, 0x60, 0x48, 0x0b,
   0xd0, 0x16, 0x06, 0x00, 0x00, 0x80, 0x25, 0xe3, 0xdc, 0x87, 0x01, 0x00,
   0x00, 0x00, 0x8e, 0xe4, 0x94, 0x70, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01,
   0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
#define down_width 16
#define down_height 16
static char down_bits[] = {
   0xff, 0xff, 0x01, 0x80, 0x01, 0x80, 0xf1, 0x87, 0x11, 0x84, 0x11, 0x84,
   0x11, 0x84, 0x1f, 0xbc, 0x05, 0x90, 0x09, 0x88, 0x11, 0x84, 0x21, 0x82,
   0x41, 0x81, 0x81, 0x80, 0x01, 0x80, 0xff, 0xff};
#define down1_width 16
#define down1_height 16
static char down1_bits[] = {
   0xff, 0xff, 0x01, 0x80, 0x01, 0x80, 0xf1, 0x87, 0xf1, 0x87, 0xf1, 0x87,
   0xf1, 0x87, 0xff, 0xbf, 0xfd, 0x9f, 0xf9, 0x8f, 0xf1, 0x87, 0xe1, 0x83,
   0xc1, 0x81, 0x81, 0x80, 0x01, 0x80, 0xff, 0xff};
#define up_width 16
#define up_height 16
static char up_bits[] = {
   0xff, 0xff, 0x01, 0x80, 0x81, 0x80, 0x41, 0x81, 0x21, 0x82, 0x11, 0x84,
   0x09, 0x88, 0x05, 0x90, 0x1f, 0xbc, 0x11, 0x84, 0x11, 0x84, 0x11, 0x84,
   0xf1, 0x87, 0x01, 0x80, 0x01, 0x80, 0xff, 0xff};
#define up1_width 16
#define up1_height 16
static char up1_bits[] = {
   0xff, 0xff, 0x01, 0x80, 0x81, 0x80, 0xc1, 0x81, 0xe1, 0x83, 0xf1, 0x87,
   0xf9, 0x8f, 0xfd, 0x9f, 0xff, 0xbf, 0xf1, 0x87, 0xf1, 0x87, 0xf1, 0x87,
   0xf1, 0x87, 0x01, 0x80, 0x01, 0x80, 0xff, 0xff};
#define scrlgray_width 8
#define scrlgray_height 8
static char scrlgray_bits[] = {
   0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44};
#define gray50_width 8
#define gray50_height 8
static char gray50_bits[] = {
   0x33, 0xcc, 0x33, 0xcc, 0x33, 0xcc, 0x33, 0xcc};
#define gray25_width 8
#define gray25_height 8
static char gray25_bits[] = {
   0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22};
#define i_fifo_width 20
#define i_fifo_height 13
static char i_fifo_bits[] = {
   0x80, 0x0f, 0xf0, 0x80, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0x80, 0x0f, 0xf0,
   0xff, 0xff, 0xff, 0xf0, 0x7f, 0xf0, 0xff, 0xff, 0xff, 0xc0, 0x1f, 0xf0,
   0xff, 0xff, 0xff, 0x00, 0x07, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0xf0,
   0xff, 0xff, 0xff};
#define i_chr_width 20
#define i_chr_height 13
static char i_chr_bits[] = {
   0xe0, 0x7f, 0x00, 0x20, 0x40, 0x00, 0x20, 0x40, 0x00, 0x20, 0x40, 0x00,
   0x20, 0x40, 0x00, 0x20, 0x40, 0x00, 0x20, 0x40, 0x00, 0xe0, 0x7f, 0x00,
   0x00, 0x09, 0x00, 0xf0, 0xff, 0x00, 0x50, 0xd5, 0x00, 0xb0, 0xaa, 0x00,
   0xf0, 0xff, 0x00};
#define i_dir_width 20
#define i_dir_height 13
static char i_dir_bits[] = {
   0xf0, 0x01, 0x00, 0x08, 0x02, 0x00, 0xfe, 0xff, 0x07, 0x02, 0x00, 0x04,
   0x02, 0x00, 0x04, 0x02, 0x00, 0x04, 0x02, 0x00, 0x04, 0x02, 0x00, 0x04,
   0x02, 0x00, 0x04, 0x02, 0x00, 0x04, 0x02, 0x00, 0x04, 0x02, 0x00, 0x04,
   0xfe, 0xff, 0x07};
#define i_blk_width 20
#define i_blk_height 13
static char i_blk_bits[] = {
   0x40, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x0c, 0x02, 0x00, 0x03, 0xcc, 0x01,
   0x0d, 0x3a, 0x06, 0xb1, 0x19, 0x06, 0x41, 0xe8, 0x05, 0x41, 0x88, 0x04,
   0x41, 0x88, 0x04, 0x41, 0x88, 0x04, 0x43, 0x9c, 0x06, 0x4c, 0xb2, 0x01,
   0xf0, 0xc1, 0x00};
#define i_lnk_width 20
#define i_lnk_height 13
static char i_lnk_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xc0, 0x01, 0xc0, 0xff, 0x07,
   0xe0, 0xff, 0x07, 0x30, 0xc0, 0x01, 0x30, 0x40, 0x00, 0xe0, 0x0f, 0x00,
   0xc0, 0x1f, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0xfe, 0x1f, 0x00,
   0xfe, 0x0f, 0x00};
#define i_sock_width 20
#define i_sock_height 13
static char i_sock_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x84, 0xf0, 0x0f,
   0x8c, 0x10, 0x00, 0x9f, 0x5a, 0x05, 0xbf, 0xb5, 0x0a, 0x9f, 0xff, 0x0f,
   0x8c, 0xff, 0x0f, 0x84, 0xff, 0x0f, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00};
#define i_reg_width 20
#define i_reg_height 13
static char i_reg_bits[] = {
   0xc0, 0x7f, 0x00, 0xa0, 0x40, 0x00, 0x90, 0x40, 0x00, 0xf0, 0x40, 0x00,
   0x10, 0x40, 0x00, 0x10, 0x40, 0x00, 0x10, 0x40, 0x00, 0x10, 0x40, 0x00,
   0x10, 0x40, 0x00, 0x10, 0x40, 0x00, 0x10, 0x40, 0x00, 0x10, 0x40, 0x00,
   0xf0, 0x7f, 0x00};
#define rb_off_width 15
#define rb_off_height 15
static char rb_off_bits[] = {
   0xe0, 0x03, 0x18, 0x0c, 0x04, 0x10, 0x02, 0x20, 0x02, 0x20, 0x01, 0x40,
   0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x02, 0x20, 0x02, 0x20,
   0x04, 0x10, 0x18, 0x0c, 0xe0, 0x03};
#define rb_on_width 15
#define rb_on_height 15
static char rb_on_bits[] = {
   0xe0, 0x03, 0x18, 0x0c, 0x04, 0x10, 0xc2, 0x21, 0xf2, 0x27, 0xf1, 0x47,
   0xf9, 0x4f, 0xf9, 0x4f, 0xf9, 0x4f, 0xf1, 0x47, 0xf2, 0x27, 0xc2, 0x21,
   0x04, 0x10, 0x18, 0x0c, 0xe0, 0x03};
#define rb_off1_width 15
#define rb_off1_height 15
static char rb_off1_bits[] = {
   0xe0, 0x03, 0xf8, 0x0f, 0x1c, 0x1c, 0x06, 0x30, 0x06, 0x30, 0x03, 0x60,
   0x03, 0x60, 0x03, 0x60, 0x03, 0x60, 0x03, 0x60, 0x06, 0x30, 0x06, 0x30,
   0x1c, 0x1c, 0xf8, 0x0f, 0xe0, 0x03};
#define rb_on1_width 15
#define rb_on1_height 15
static char rb_on1_bits[] = {
   0xe0, 0x03, 0xf8, 0x0f, 0x1c, 0x1c, 0xc6, 0x31, 0xf6, 0x37, 0xf3, 0x67,
   0xfb, 0x6f, 0xfb, 0x6f, 0xfb, 0x6f, 0xf3, 0x67, 0xf6, 0x37, 0xc6, 0x31,
   0x1c, 0x1c, 0xf8, 0x0f, 0xe0, 0x03};
#define fc_left_width 16
#define fc_left_height 16
static char fc_left_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x04, 0x70, 0x82, 0x8c, 0xe2,
   0x22, 0x9c, 0x2d, 0x90, 0x2d, 0x80, 0x21, 0x90, 0x22, 0x9c, 0x1c, 0xe3,
   0x70, 0x82, 0x80, 0x02, 0x00, 0x07, 0x00, 0x00};
#define fc_leftm_width 16
#define fc_leftm_height 16
static char fc_leftm_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x07, 0xf0, 0x83, 0xfc, 0xe3,
   0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xfc, 0xe3,
   0xf0, 0x83, 0x80, 0x03, 0x00, 0x07, 0x00, 0x00};
#define fc_mid_width 16
#define fc_mid_height 16
static char fc_mid_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x80, 0x03, 0x40, 0x04, 0x20, 0x08,
   0xe0, 0x0e, 0xe0, 0x0e, 0x20, 0x08, 0xa0, 0x0b, 0xe0, 0x0f, 0xa0, 0x0b,
   0x40, 0x04, 0x80, 0x03, 0x80, 0x03, 0x00, 0x00};
#define fc_midm_width 16
#define fc_midm_height 16
static char fc_midm_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f,
   0xe0, 0x0f, 0xe0, 0x0f, 0xe0, 0x0f, 0xe0, 0x0f, 0xe0, 0x0f, 0xe0, 0x0f,
   0xc0, 0x07, 0x80, 0x03, 0x80, 0x03, 0x00, 0x00};
#define fc_right_width 16
#define fc_right_height 16
static char fc_right_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x20, 0x03, 0x41, 0x0e, 0x47, 0x30,
   0x39, 0x44, 0x09, 0xb4, 0x01, 0xb4, 0x09, 0x84, 0x39, 0x44, 0xc7, 0x38,
   0x41, 0x0e, 0x40, 0x01, 0xe0, 0x00, 0x00, 0x00};
#define fc_rightm_width 16
#define fc_rightm_height 16
static char fc_rightm_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0xe0, 0x03, 0xc1, 0x0f, 0xc7, 0x3f,
   0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xc7, 0x3f,
   0xc1, 0x0f, 0xc0, 0x01, 0xe0, 0x00, 0x00, 0x00};
#define fc_left1_width 16
#define fc_left1_height 16
static char fc_left1_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x02, 0xe0, 0x14, 0x10, 0x1f,
   0xd8, 0x14, 0xd8, 0x14, 0x08, 0x10, 0x08, 0x14, 0xd0, 0x14, 0x70, 0x1e,
   0x60, 0x13, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00};
#define fc_left1m_width 16
#define fc_left1m_height 16
static char fc_left1m_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x03, 0xe0, 0x17, 0xf0, 0x1f,
   0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf0, 0x1f, 0xf0, 0x1f,
   0xe0, 0x13, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00};
#define fc_right1_width 16
#define fc_right1_height 16
static char fc_right1_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x03, 0x28, 0x07, 0xf8, 0x08,
   0x28, 0x1b, 0x28, 0x1b, 0x08, 0x10, 0x28, 0x10, 0x28, 0x0b, 0x38, 0x0e,
   0xc8, 0x06, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00};
#define fc_right1m_width 16
#define fc_right1m_height 16
static char fc_right1m_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, 0xe8, 0x07, 0xf8, 0x0f,
   0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x0f, 0xf8, 0x0f,
   0xc8, 0x07, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00};
#define icon_width 48
#define icon_height 29
static char icon_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x3e, 0x00, 0x7c, 0x7c, 0x00, 0x7c, 0x5c, 0x00, 0x2e, 0x5c, 0x00, 0x5c,
   0xb8, 0x00, 0x17, 0xb8, 0x00, 0x2e, 0x70, 0x81, 0x0b, 0xb8, 0x00, 0x2e,
   0x70, 0x81, 0x0b, 0x70, 0x01, 0x17, 0xe0, 0xc2, 0x05, 0x70, 0x01, 0x17,
   0xc0, 0xe5, 0x02, 0xe0, 0x82, 0x0b, 0x80, 0x7b, 0x01, 0xe0, 0x82, 0x0b,
   0x00, 0xb7, 0x00, 0xc0, 0xc5, 0x05, 0x00, 0x56, 0x00, 0xc0, 0xc5, 0x05,
   0x00, 0x2e, 0x00, 0x80, 0xeb, 0x02, 0x00, 0x56, 0x00, 0x80, 0xeb, 0x02,
   0x00, 0xb7, 0x00, 0x00, 0x77, 0x01, 0x80, 0x7b, 0x01, 0x00, 0x77, 0x01,
   0xc0, 0xe5, 0x02, 0x00, 0xae, 0x00, 0xe0, 0xc2, 0x05, 0x00, 0xae, 0x00,
   0x70, 0x81, 0x0b, 0x00, 0x5c, 0x00, 0x70, 0x81, 0x0b, 0x00, 0x5c, 0x00,
   0xb8, 0x00, 0x17, 0x00, 0x38, 0x00, 0x5c, 0x00, 0x2e, 0x00, 0x38, 0x00,
   0x3e, 0x00, 0x7c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
\BARFOO\
else
  echo "will not over write ./bitmaps.h"
fi
if `test ! -s ./pm.h`
then
echo "writting ./pm.h"
cat > ./pm.h << '\BARFOO\'
/* include file defining constants/macros for PM files.  Used by xvpm.c 
 */

/*
 * Copyright 1989, 1990 by the University of Pennsylvania
 *
 * Permission to use, copy, and distribute for non-commercial purposes,
 * is hereby granted without fee, providing that the above copyright
 * notice appear in all copies and that both the copyright notice and this
 * permission notice appear in supporting documentation.
 *
 * The software may be modified for your own purposes, but modified versions
 * may not be distributed.
 *
 * This software is provided "as is" without any express or implied warranty.
 */

#define	PM_MAGICNO	0x56494557		/* Hex for VIEW */
#define PM_MAXNELM	1024
#define PM_MAXNBAND	1024
#define PM_NOSHIFT	0
#define PM_SHIFT	1

#define	PM_A		0x8000
#define	PM_C		0x8001
#define	PM_S		0x8002
#define	PM_I		0x8004
#define PM_F		0xc004

#define PM_RED 0xff
#define PM_GREEN 0xff00
#define PM_BLUE 0xff0000
#define PM_ALPHA 0xff000000
#define PM_BW 0

#define	PM_CMAX		0xff
#define PM_SMAX		0x7fff
#define	PM_IMAX		0x7fffffff
#define PM_FMAX		1.7E38

#define PM_IOHDR_SIZE	(sizeof(pmpic)-(2*sizeof(char*)))

#define	pm_max(pm)	((pm)->pm_form == PM_C ? PM_CMAX :		  \
				(pm)->pm_form == PM_S ? PM_SMAX :	  \
					(pm)->pm_form == PM_I ? PM_IMAX : \
						 PM_FMAX)

#define pm_index(fm)	(((fm)&0xff)-(((fm)>>14)&01))
#define	pm_sel(fm,fn)	(*((fn)[pm_index(fm)]))
#define pm_iindex(a,nc,cr,cc)	((a)+((cr)*(nc))+(cc))
 
#define pm_nelm(p)	((p)->pm_ncol * (p)->pm_nrow)
#define pm_nbelm(p)	(pm_nelm(p) * (p)->pm_nband)
#define pm_psize(p)	(pm_nbelm(p) * (((p)->pm_form)&0xff))
#define pm_isize(p)	((p)->pm_np * pm_psize(p))
#define pm_npix(p)      (pm_nbelm(p) * (p)->pm_np)

#include <sys/types.h>

typedef struct {
	int	pm_id;		/* Magic number for pm format files.	*/
	int	pm_np;		/* Number of planes. Normally 1.	*/
	int	pm_nrow;	/* Number of rows. 1 - MAXNELM.		*/
	int	pm_ncol;	/* Number of columns. 1 - MAXNELM.	*/
	int	pm_nband;	/* Number of bands.			*/
	int	pm_form;	/* Pixel format.			*/
	int	pm_cmtsize;	/* Number comment bytes. Includes NULL. */
	char	*pm_image;	/* The image itself.			*/
	char	*pm_cmt;	/* Transforms performed.		*/
} pmpic;

typedef	struct {
	int	pm_x;		/* X Position. */
	int	pm_y;		/* Y Position. */
	int	pm_z;		/* Z Position. */
	float	pm_ux;		/* Uncertainty in x. */
	float	pm_uy;		/* Uncertainty in y. */
	float	pm_uz;		/* Uncertainty in z. */
} pmxyz;

#define	PM_EBASE	100
#define PM_EMALLOC	101
#define PM_EBADPARAM	102
#define PM_EBADPIC	103
#define PM_EBADFORM	104
#define PM_EBADMAGIC	105
#define PM_ENULLPIC	106    /* picture given was NULL */
#define PM_EBADPLANES   107  /* invalid # of planes chosen for format */
#define PM_EBADBANDS 	108 /* invalid # of bands chosen for format */
#define PM_EBADSIZE 	109 /* # of rows/cols and x offsets, y offsets
			   too big for ikonas */
#define PM_EBADCOLORS 	110 /* invalid number of colors chosen for format */
#define PM_EBADCOLORPLANE 111 /* invalid color plane entered */


#define PM_NERROR	12
#define PM_ERROR(e)	(((e) < PM_EBASE || (e) > (PM_EBASE + PM_NERROR)) ? \
				0 : (e) - PM_EBASE)
extern char	*pm_errmsg[];

pmpic	*pm_add();
pmpic	*pm_addcmt();
pmpic	*pm_alloc();
pmpic	*pm_and();
pmpic	*pm_bthresh();
pmpic	*pm_cast();
char	*pm_cmt();
pmpic	*pm_conv();
pmpic	*pm_ebadform();
int	pm_getcmt();
pmpic	*pm_ikrd();
pmpic	*pm_ikwr();
pmpic	*pm_neg();
pmpic	*pm_or();
pmpic	*pm_prep();
pmpic	*pm_rdhdr();
pmpic	*pm_read();
pmpic	*pm_scale();
pmpic	*pm_sub();
pmpic	*pm_thresh();
pmpic	*pm_write();

pmxyz	*pm_centroid();

\BARFOO\
else
  echo "will not over write ./pm.h"
fi
if `test ! -s ./xv.h`
then
echo "writting ./xv.h"
cat > ./xv.h << '\BARFOO\'
/*
 *  xv.h  -  header file for xv, but you probably guessed as much
 */

/*
 * Copyright 1989, 1990 by the University of Pennsylvania
 *
 * Permission to use, copy, and distribute for non-commercial purposes,
 * is hereby granted without fee, providing that the above copyright
 * notice appear in all copies and that both the copyright notice and this
 * permission notice appear in supporting documentation.
 *
 * The software may be modified for your own purposes, but modified versions
 * may not be distributed.
 *
 * This software is provided "as is" without any express or implied warranty.
 */

#define REVDATE   "Rev: 11/26/90  (Patchlevel 2)"

#ifdef SVR4             /* SysV release 4 uses dirent */
#ifndef sgi             /* but Silicon Graphics doesn't */
#define DIRENT
#endif
#endif


/* include files */
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
extern int   errno;             /* this SHOULD be in errno.h */
extern char *sys_errlist[];     /* this SHOULD be in errno.h */

#ifndef __convexc__             /* Convex doesn't have <memory.h> */
#include <memory.h>             /* for 'memset()' prototype */
#endif

/* neither IBM AOS 4.3, Convex, nor BSD 4.3 on VAX have <malloc.h> */
#if !defined(ibm032) && !defined(__convexc__) && \
    !(defined(vax) && !defined(ultrix))
#if defined(hp300) || defined(hp800)
#include <sys/malloc.h>                /* it's in 'sys' on HPs*/
#else
#include <malloc.h>
#endif
#endif


#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>


#if defined(NEEDSTIME) || defined(NEEDSDIR)
#include <sys/types.h>    /* only include <sys/types.h> once */
#endif

#ifdef NEEDSTIME
#ifndef sgi              /* silicon graphics doesn't have timeb.h */
#include <sys/timeb.h>
#endif
#include <signal.h>
#if defined(sco) && !defined(NOTIMER)
#include <sys/itimer.h>
#endif
#ifndef  sigmask
#define  sigmask(m)      (1 << ((m)-1))
#endif
#endif

#ifdef NEEDSDIR
#ifdef sco
#include <sys/ndir.h>
#define lstat stat
#else
#ifndef ATT
#include <sys/dir.h>
#endif  /* ATT */
#endif  /* sco */
#include <sys/param.h>
#include <sys/stat.h>
#ifdef DIRENT
#include <dirent.h>
#endif
#endif

#ifdef NEEDSVARARGS
#include <varargs.h>
#endif

/* signal macros */
#ifdef SVR4
#define HOLD_SIG         sighold(SIGALRM)  /* block ALRM sig from occurring */
#define RELEASE_SIG      sigrelse(SIGALRM) /* 
#define PAUSE_SIG        sigpause(SIGALRM) /* sleep until ALRM signal */
#else
#define HOLD_SIG         sigblock(sigmask(SIGALRM))
#define RELEASE_SIG      sigblock(0)
#define PAUSE_SIG        sigpause(0)
#endif


#ifdef i386
#define MAXPATHLEN    500
#define UNCOMPRESS    "/usr/local/bin/uncompress"   /* uncompress program */
#undef  HOLD_SIG
#define HOLD_SIG      /* don't know how to handle signals  MWS 10/18/90 */
#undef  RELEASE_SIG
#define RELEASE_SIG   /* */
#undef  PAUSE_SIG
#define PAUSE_SIG     /* */
#else
#define UNCOMPRESS "/usr/ucb/uncompress"   /* for uncompressing .Z files */
#endif

#define PROGNAME  "xv"             /* used in resource database */

#define DEFINFOGEOM "-10+10"       /* default position of info window */
#define DEFDIRGEOM  "-10-10"       /* default position of directory window */
#define DEFCTRLGEOM "+400+400"     /* default position of ctrl window */
#define DEFGAMGEOM  "+10-10"       /* default position of gamma window */

#define INFOWIDE 500               /* (fixed) size of info window */
#define INFOHIGH 250

#define CTRLWIDE 440               /* (fixed) size of control window */
#define CTRLHIGH 295

#define DIRWIDE  300               /* (fixed) size of directory window */
#define DIRHIGH  420

#define GAMWIDE  366               /* (fixed) size of Gamma window */
#define GAMHIGH  356

#define MAXNAMES 1024   /* max # of files (more than this?  Get REAL!)

/* strings in the INFOBOX (used in SetISTR and GetISTR) */
#define NISTR         9    /* number of ISTRs */
#define ISTR_INFO     0
#define ISTR_WARNING  1
#define ISTR_FILENAME 2
#define ISTR_FORMAT   3
#define ISTR_RES      4
#define ISTR_CROP     5
#define ISTR_EXPAND   6
#define ISTR_COLOR    7
#define ISTR_COLOR2   8

/* potential values of 'infomode', used in info box drawing routines */
#define INF_NONE 0    /* empty box */
#define INF_STR  1    /* just ISTR_INFO */
#define INF_PART 2    /* filename, format, size and infostr */
#define INF_FULL 3    /* INF_PART + clipping, expansion, colorinfo */


/* buttons in the ctrl window */
#define NBUTTS  20
#define BNEXT   0
#define BPREV   1
#define BCROP   2
#define BUNCROP 3
#define BNORM   4
#define BMAX    5
#define BUP2    6
#define BDN2    7
#define BUP10   8
#define BDN10   9
#define BQUIT   10
#define B4BY3   11
#define BSAVE   12
#define BROTL   13
#define BINFO   14
#define BGAMMA  15
#define BASPECT 16
#define BROTR   17
#define BMAXPECT 18
#define BACROP   19

/* buttons in the 'save' window */
#define S_NBUTTS 4
#define S_BOPEN  0
#define S_BSAVE  1
#define S_BCANC  2
#define S_BQUIT  3


/* buttons in the 'gamma' window */
#define G_NBUTTS  17
#define G_BAPPLY  0
#define G_BNOGAM  1
#define G_BRESET  2
#define G_BDEF    3
#define G_BGTYPE  4
#define G_BCLOSE  5
#define G_BUP_BR  6
#define G_BDN_BR  7
#define G_BUP_CN  8
#define G_BDN_CN  9
#define G_BHSVRGB 10
#define G_B1      11
#define G_B2      12
#define G_B3      13
#define G_B4      14
#define G_BSET    15
#define G_BUNDO   16


/* definitions of first char of dirnames[i] (filetype) */
#define C_FIFO  'f'    /* FIFO special file */
#define C_CHR   'c'    /* character special file */
#define C_DIR   'd'    /* directory */
#define C_BLK   'b'    /* block special file */
#define C_LNK   'l'    /* symbolic link */
#define C_SOCK  's'    /* socket */
#define C_REG   ' '    /* regular file */


/* random string-placing definitions */
#define SPACING 3      /* vertical space between strings */
#define ASCENT   (mfinfo->ascent)
#define DESCENT  (mfinfo->descent)
#define CHIGH    (ASCENT + DESCENT)
#define LINEHIGH (CHIGH + SPACING)


#define STDINSTR "<stdin>"


#ifndef MAIN
#define WHERE extern
#else
#define WHERE
#endif

typedef unsigned char byte;

typedef struct { Window win;            /* window ID */
		 int len;               /* length of major axis */
		 int vert;              /* true if vertical, else horizontal */
		 int active;            /* true if scroll bar can do anything*/
		 int min,max;           /* min/max values 'pos' can take */
		 int val;               /* 'value' of scrollbar */
		 int page;              /* amt val change on pageup/pagedown */
		 int tpos;              /* thumb pos. (pixels from tmin) */
		 int tmin,tmax;         /* min/max thumb offsets (from 0,0) */
		 int tsize;             /* size of thumb (in pixels) */
		 unsigned long fg,bg;   /* colors */
		 void (*drawobj)();     /* redraws obj controlled by scrl*/
		 int uplit, dnlit;      /* true if up&down arrows are lit */
	       } SCRL;

typedef struct { Window win;            /* parent window */
		 int x,y,w,h;           /* size of button rectangle */
		 int lit;               /* if true, invert colors */
		 int active;            /* if false, stipple gray */
		 int toggle;            /* if true, clicking toggles state */
		 unsigned long fg,bg;   /* colors */
		 char *str;             /* string in button */
	       } BUTT;


typedef struct { Window win;            /* window */
		 int x,y,w,h;           /* size of window */
		 unsigned long fg,bg;   /* colors */
		 char **str;            /* ptr to list of strings */
		 int   nstr;            /* number of strings */
		 int   selected;        /* number of 'selected' string */
		 int   nlines;          /* number of lines shown at once */
		 SCRL  scrl;            /* scrollbar that controls list */
		 int   filetypes;       /* true if filetype icons to be drawn*/
		 int   dirsonly;        /* if true, only dirs selectable */
	       } LIST;


typedef struct rbutt { Window        win;      /* parent window */
		       int           x,y;      /* position in parent */
		       char         *str;      /* the message string */
		       int           selected; /* selected or not */
		       int           active;   /* selectable? */
		       struct rbutt *next;     /* pointer to next in group */
		       unsigned long fg,bg;    /* colors */
		     } RBUTT;

/* MACROS */
#define CENTERX(f,x,str) ((x)-XTextWidth(f,str,strlen(str))/2)
#define CENTERY(f,y) ((y)-((f->ascent+f->descent)/2)+f->ascent)

/* RANGE forces a to be in the range b..c (inclusive) */
#define RANGE(a,b,c) { if (a<b) a=b;  if (a>c) a=c; }

/* PTINRECT returns '1' if x,y is in rect (inclusive) */
#define PTINRECT(x,y,rx,ry,rw,rh) \
           ((x)>=(rx) && (y)>=(ry) && (x)<=(rx)+(rw) && (y)<=(ry)+(rh))

/* MONO returns total intensity of r,g,b components */
#define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5)  /*.33R+ .5G+ .17B*/



/* X stuff */
WHERE Display       *theDisp;
WHERE int           theScreen;
WHERE unsigned int  ncells, dispWIDE, dispHIGH, dispDEEP;
WHERE Colormap      theCmap, LocalCmap;
WHERE Window        rootW, mainW;
WHERE GC            theGC;
WHERE unsigned long black, white, fg, bg, infofg, infobg;
WHERE Font          mfont, monofont;
WHERE XFontStruct   *mfinfo, *monofinfo;
WHERE Visual        *theVisual;
WHERE Cursor        arrow, cross;
WHERE Pixmap        iconPix;

/* global vars used by LOAD routines */
WHERE byte          *pic;                   /* ptr to loaded picture */
WHERE unsigned int   pWIDE,pHIGH;           /* size of 'pic' */
WHERE byte           r[256],g[256],b[256];  /* colormap */
WHERE char          *cmd;                   /* program name for printf's */
WHERE int            DEBUG;                 /* print debugging info */
WHERE int            mono;                  /* true if displaying grayscale */


/* more global variables, used by xv and xvmisc */
WHERE byte          *cpic;         /* cropped version of pic */
WHERE unsigned int  cWIDE, cHIGH,  /* size of cropped region */
                    cXOFF, cYOFF;  /* offset of region from 0,0 of pic */

WHERE byte          *epic;         /* expanded version of cpic */
                                   /* points to pic when at 1:1 expansion */
                                   /* this is converted to 'theImage' */
WHERE unsigned int  eWIDE, eHIGH;  /* size of epic */
WHERE unsigned int  normFact;      /* factor to shrink picture by for 'norm' */

WHERE byte           rorg[256],gorg[256],borg[256];  /* ORIGINAL colormap */
WHERE byte           gamcr[256];   /* gamma correction curve */
WHERE byte           fsgamcr[256]; /* gamma correction curve (for FS dither) */


WHERE XImage        *theImage;     /* X version of epic */


WHERE unsigned long freecols[256]; /* list of pixel values to free */
WHERE int           nfcols;        /* number of colors to free */
WHERE unsigned long cols[256];     /* maps pic pixel values to X pixel vals */
WHERE int           fc2pcol[256];  /* maps freecols into pic pixel values */
WHERE int           numcols;       /* # of desired colors in picture */
WHERE int           ncols;         /* max # of (different) colors to alloc */

WHERE char          str[128];      /* dummy string used for error messages */

WHERE int           expand,        /* expansion amount */
                    bwidth,        /* border width of created windows */
                    noglob,        /* force to only use colors it alloced */
                    revvideo,      /* reverse video */
                    perfect,       /* perfect color.  install own colormap */
                    fixedaspect,   /* fixed aspect ratio */
                    slow24,        /* use slow 24to8 algorithm */
                    ninstall,      /* true if using icccm-complaint WM
				      (a WM that will does install CMaps */
                    useroot,       /* true if we should draw in rootW */
                    noqcheck,      /* true if we should NOT do QuickCheck */
                    rwcolor,       /* true if we should use R/W color cells */
                    rwthistime,    /* true if we DID use R/W color cells */
                    brokeFreeCols, /* true if server has broken XFreeColors */
                    fish,          /* turn on annoying fish */
                    fishrunning;   /* true if fish are in operation */

WHERE float         defaspect,     /* default aspect ratio to use */
                    normaspect;    /* normal aspect ratio of this picture */

WHERE int           crx1, cry1,    /* dimensions of cropping rectangle */
                    crx2, cry2;



/* stuff used for 'info' box */
WHERE Window        infoW;
WHERE int           infoUp;       /* boolean:  whether infobox is visible */
WHERE int           infoMode;


/* stuff used for 'ctrl' box */
WHERE Window        ctrlW;
WHERE int           ctrlUp;       /* boolean:  whether ctrlbox is visible */
WHERE char         *namelist[MAXNAMES];  /* list of file names from argv */
WHERE char         *dispnames[MAXNAMES]; /* truncated names shown in listbox */
WHERE int           numnames, curname;
WHERE LIST          nList;
WHERE BUTT          but[NBUTTS];         /* command buttons in ctrl window */
WHERE Pixmap        grayTile, grayStip;  /* for drawing dim things */

/* stuff used for 'directory' box */
WHERE Window        dirW, ddirW, dnamW;
WHERE int           dirUp;       /* is dirW mapped or not */
WHERE LIST          dList;       /* list of filenames in current directory */
WHERE BUTT          dbut[S_NBUTTS];

/* stuff used for 'gamma' box */
#define NUMHANDS 4
WHERE Window        gamW,graphW;
WHERE int           gamUp;       /* is gamW mapped or not */
WHERE BUTT          gbut[G_NBUTTS];
WHERE XPoint        ghand[NUMHANDS];

#undef WHERE





/* function declarations for externally-callable functions */

#ifdef __STDC__ 
/****************************** XV.C ****************************/
void DrawWindow(int, int, int, int);
void WCrop(int, int);
void WUnCrop(void);
void WResize(int, int);
void WRotate(void);
void InvCropRect(void);
void MakeRootPic(void);

/*************************** XVMISC.C ***************************/
Window CreateWindow(char *, char *, unsigned int, unsigned int, 
		    unsigned long, unsigned long);
void Resize(int, int);
void Rotate(int);
void SortColormap(void);
void AllocColors(void);
void AllocRWColors(void);
void DoMonoAndRV(void);
void DoCrop(void);
void UnCrop(void);
void AutoCrop(void);
void FSDither(byte *, int, int, byte *);
void CreateXImage(void);
void CenterString(Window, char *, int, int);
void ULineString(Window, char *, int, int);
int  StringWidth(char *);
void FakeButtonPress(BUTT *);
void SetCropString(void);
void Warning(void);
void FatalError(char *);
void LoadFishCursors(void);
void SetCursors(int);
void WaitCursor(void);
void Quit(int);
void Timer(int);

/*************************** XV24TO8.C **************************/
int  Conv24to8(byte *, int, int, int);
void InitFSDTables(void);

/**************************** XVCTRL.C **************************/
void CreateCtrl(char *);
void CtrlBox(int);
void RedrawCtrl(int, int, int, int);
int  ClickCtrl(int, int);
void DrawCtrlStr(void);
void ScrollToCurrent(void);

void LSCreate(LIST *, Window, int, int, int, int, int, char **, int, 
	      unsigned long, unsigned long, void (*)(void), int, int);
void LSRedraw(LIST *);
int  LSClick (LIST *, XButtonEvent *);
void LSNewData(LIST *, char **, int);


/*************************** XVINFO.C ***************************/
void  CreateInfo(char *);
void  InfoBox(int);
void  RedrawInfo(int, int, int, int);
void  SetInfoMode(int);
void  SetISTR(int, ...);
char *GetISTR(int);

/**************************** XVDIR.C ***************************/
void CreateDirW(char *);
void DirBox(int);
void RedrawDirW(int,int,int,int);
int  ClickDirW(int, int);
void LoadCurrentDirectory(void);
void RedrawDDirW(void);
void RedrawDNamW(void);
void SelectDir(int);
void DirOpenActive(void);
void TrackDDirW(int,int);
int  DirKey(int);
int  DoSave(void);
void SetDirFName(char *);


/**************************** XVGAM.C **************************/
void CreateGam(char *);
void GamBox(int);
void RedrawGam(int, int, int, int);
void RedrawGraph(int, int, int, int);
void ClickGam(int, int);
void TrackGraph(int, int);
void GenerateGamma(void);
void GenerateFSGamma(void);
void GammifyColors(void);
void SetGPreset(int, int, int, int, int, int, int);

/*************************** XVSCRL.C ***************************/
void SCCreate  (SCRL *, Window, int, int, int, int, int, int, int, int, 
                      unsigned long, unsigned long, void (*)(void));
void SCSetRange(SCRL *, int, int, int, int);
void SCSetVal  (SCRL *, int);
void SCRedraw  (SCRL *);
void SCTrack   (SCRL *, int, int);


/**************************** XVBUTT.C ***************************/

void BTCreate(BUTT *, Window, int, int, int, int, char *, 
	      unsigned long, unsigned long);
void BTSetActive(BUTT *, int);
void BTRedraw(BUTT *);
int  BTTrack (BUTT *);


RBUTT *RBCreate(RBUTT *, Window, int, int, char*, 
		unsigned long, unsigned long);
void   RBRedraw(RBUTT *, int);
void   RBSelect(RBUTT *, int);
int    RBWhich(RBUTT *);
int    RBCount(RBUTT *);
void   RBSetActive(RBUTT *, int, int);
int    RBClick(RBUTT *, int, int);
void   RBTrack(RBUTT *, int);


/**************************** XVGIF.C ***************************/
int LoadGIF(char *, int);

/*************************** XVGIFWR.C **************************/
int WriteGIF(FILE *, byte *, int, int, byte *, byte *, byte *, int, int);

/**************************** XVPM.C ****************************/
int LoadPM(char *, int);
int WritePM(FILE *, byte *, int, int, byte *, byte *, byte *, int, int);

/**************************** XVPBM.C ***************************/
int LoadPBM(char *, int);
int WritePBM(FILE *, byte *, int, int, byte *, byte *, byte *, int, int, int);

/**************************** XVXBM.C ***************************/
int LoadXBM(char *, int);
int WriteXBM(FILE *, byte *, int, int, char *);





#else     /* using non-ANSI cc.  Function defs, but no params */




/****************************** XV.C ****************************/
void DrawWindow(), WCrop(), WUnCrop(), WResize(), WRotate(), InvCropRect();
void MakeRootPic();

/*************************** XVMISC.C ***************************/
Window CreateWindow();
void   Resize(), Rotate(), SortColormap(), AllocColors(), DoCrop(), UnCrop();
void   AutoCrop(), DoMonoAndRV();
void   AllocRWColors(), FSDither(), CenterString(), ULineString();
int    StringWidth();
void   FakeButtonPress(), SetCropString(), Warning(), FatalError(), Quit();
void   Timer(), CreateXImage(), LoadFishCursors(), SetCursors(), WaitCursor();

/*************************** XV24TO8.C **************************/
int  Conv24to8();
void InitFSDTables();

/**************************** XVCTRL.C **************************/
void CreateCtrl(), CtrlBox(), RedrawCtrl(), DrawCtrlStr(), ScrollToCurrent();
int  ClickCtrl();

void LSCreate(), LSRedraw(), LSNewData();
int  LSClick();

/*************************** XVINFO.C ***************************/
void  CreateInfo(), InfoBox(), RedrawInfo(), SetInfoMode(), SetISTR();
char *GetISTR();

/**************************** XVDIR.C ***************************/
void CreateDirW(), DirBox(), RedrawDirW(), LoadCurrentDirectory();
int  ClickDirW(), DoSave(), DirKey();
void RedrawDDirW(), RedrawDNamW(), SelectDir(), DirOpenActive(), TrackDDirW();
void SetDirFName();

/**************************** XVGAM.C **************************/
void CreateGam(), GamBox(), RedrawGam(), RedrawGraph(), ClickGam();
void TrackGraph(), GenerateGamma(), GenerateFSGamma(), GammifyColors();
void SetGPreset();

/*************************** XVSCRL.C ***************************/
void SCCreate(), SCSetRange(), SCSetVal(), SCRedraw(), SCTrack();

/**************************** XVBUTT.C ***************************/
void BTCreate(), BTSetActive(), BTRedraw();
int  BTTrack();

RBUTT *RBCreate();
void   RBRedraw(), RBSelect(), RBSetActive(), RBTrack();
int    RBWhich(), RBCount(), RBClick();

/**************************** XVGIF.C ***************************/
int LoadGIF();

/*************************** XVGIFWR.C **************************/
int WriteGIF();

/**************************** XVPM.C ****************************/
int LoadPM(), WritePM();

/**************************** XVPBM.C ***************************/
int LoadPBM(), WritePBM();

/**************************** XVXBM.C ***************************/
int LoadXBM(), WriteXBM();


#endif
\BARFOO\
else
  echo "will not over write ./xv.h"
fi
echo "Finished archive 1 of 10"
exit

dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.
--
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.