home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume10 / xv / part02 < prev    next >
Encoding:
Internet Message Format  |  1990-12-07  |  61.6 KB

  1. Path: wuarchive!usc!apple!sun-barr!newstop!exodus!appserv!halibut.cis.upenn.edu
  2. From: bradley@halibut.cis.upenn.edu (John Bradley)
  3. Newsgroups: comp.sources.x
  4. Subject: v10i080: xv - display and manipulate images, Part02/10
  5. Message-ID: <318@appserv.Eng.Sun.COM>
  6. Date: 27 Nov 90 20:08:09 GMT
  7. References: <csx-10i079:xv@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 1283
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: bradley@halibut.cis.upenn.edu (John Bradley)
  13. Posting-number: Volume 10, Issue 80
  14. Archive-name: xv/part02
  15.  
  16. #!/bin/sh
  17. # to extract, remove the header and type "sh filename"
  18. if `test ! -d ./docs`
  19. then
  20.   mkdir ./docs
  21.   echo "mkdir ./docs"
  22. fi
  23. if `test ! -s ./docs/gif.aspect`
  24. then
  25. echo "writting ./docs/gif.aspect"
  26. cat > ./docs/gif.aspect << '\BARFOO\'
  27. XV also supports the GIF 'aspect ratio' extension that was discussed on 
  28. comp.graphics.  Here's the description:
  29. ----------------------------------------------------------------------------
  30.  
  31. There was quite a discussion in comp.graphics a few weeks ago, with a
  32. lot of people complaining about GIF images coming with many different
  33. aspect ratios, but no indication what the initial aspect ratio was.
  34.  
  35. Several suggestions were made, the best of which was Chris Schoeneman
  36. (i think) suggesting the following extension block be added to specify
  37. the aspect ratio:
  38. #   7 6 5 4 3 2 1 0   Byte #
  39. #  +---------------+
  40. #  |0 0 1 0 0 0 0 1|    1        '!' - GIF extension block introducer
  41. #  +---------------+
  42. #  |0 1 0 1 0 0 1 0|    2        'R' - For 'aspect Ratio'
  43. #  +---------------+
  44. #  |0 0 0 0 0 0 1 0|    3         2  - Two bytes in block
  45. #  +---------------+
  46. #  |  pixel width  |    4            - First part of ratio (numerator)
  47. #  +---------------+
  48. #  | pixel height  |    5            - Second part of ratio (denominator)
  49. #  +---------------+
  50. #  |0 0 0 0 0 0 0 0|    6         0  - extension block end code
  51. #  +---------------+
  52. #
  53. #Let byte four equal 'x' and byte five equal 'y'  Then x:y is the _pixel_
  54. #aspect ratio.  'x' and 'y' should be relatively prime (ie they should
  55. #have no common divisor except one), but they don't have to be.
  56.  
  57. Jef Paskanzer [of PBMPLUS fame]  modified his
  58. gif decoder to recognize this. I also modified my own, not that I count :-)
  59. Jef and I cross-checked ours and these diffs are compatible with both.
  60.  
  61. This code, by the way, isn't terrible robust, and will only skip extensions
  62. found BEFORE the image separator, but it is a lot better than nothing.
  63.  
  64. Since then, there has been a seemingly official announcement about a GIF89a
  65. standard from CompuServe, and the possibility of both GIF's becoming outlawed
  66. because of the Unisys LZW patent,  etc. etc. etc. oh, well... life goes on.
  67.  
  68. anyway... I hope this is of some help. you are welcome to post these patches
  69. to wherever is appropriate (i didnt do a patch on patchlevel.h, b.t.w.), or
  70. incorporate them into your new program, or whatever. I relinquish all claims,
  71. etc. etc.
  72.  
  73. -steve
  74. -------------------------------------------------------+"Come, Watson, come!"
  75.  Steve Swales                (716) 275-0265,-3857,-5101| he cried. "The game is
  76.  steve@bat.lle.rochester.edu           (128.151.32.111)| afoot. Not a word!
  77.  {decvax,harvard,ames,rutgers}!rochester!ur-laser!steve| Into your clothes and
  78.  University of Rochester            250 East River Road| come!"        S.H.
  79.  Laboratory for Laser Energetics    Rochester, NY 14623|     'The Abbey Grange'
  80.  
  81. \BARFOO\
  82. else
  83.   echo "will not over write ./docs/gif.aspect"
  84. fi
  85. if `test ! -s ./docs/README`
  86. then
  87. echo "writting ./docs/README"
  88. cat > ./docs/README << '\BARFOO\'
  89. Documentation on the various file formats read/written by XV, and some other
  90. miscellaneous stuff.
  91.  
  92. \BARFOO\
  93. else
  94.   echo "will not over write ./docs/README"
  95. fi
  96. if `test ! -s ./docs/credits`
  97. then
  98. echo "writting ./docs/credits"
  99. cat > ./docs/credits << '\BARFOO\'
  100. Thanks go out to many people:
  101.  
  102. *  To Patrick J. Naughton (naughton@wind.sun.com) for writing 'gif2ras.c', a 
  103. program that converts GIF files to Sun Rasterfiles.  This program was the 
  104. basis of the original xgif, and as such, could be said to have 'started it all'
  105.  
  106. This same code remains mostly unchanged in 'xvgif.c'.
  107.  
  108. *  To Michael Maudlin (mlm@cs.cmu.edu) for writing a short, READABLE version
  109. of the 'gif writing' code, which I've modified to a small degree.  This code
  110. became 'xvgifwr.c'.
  111.  
  112. *  To Jef Poskanzer (jef@well.sf.ca.us) for coming up with cool-whizo 
  113. 'general' formats (pbm, pgm, ppm) and for having a large collection of X11
  114. bitmap files (providing the impetus for reading/writing THAT format).
  115.  
  116. *  To Steve Swales (steve@bat.lle.rochester.edu) for telling me about the
  117. GIF aspect ratio extension.
  118.  
  119. And, most importantly, to John Dotts Hagan (hagan@dccs.upenn.edu) whose 
  120. continued harrassment has proved invaluable.  Suffice it to say that XV 
  121. probably wouldn't have been written were it not for all the abuse he gave me
  122. about the shortcomings of 'xgif'.
  123.  
  124. --jhb 8/30/90
  125. \BARFOO\
  126. else
  127.   echo "will not over write ./docs/credits"
  128. fi
  129. if `test ! -s ./docs/info`
  130. then
  131. echo "writting ./docs/info"
  132. cat > ./docs/info << '\BARFOO\'
  133. Note:  This is somewhat obsolete, but may be of interest to any one who
  134. feels like hacking 'xv' 
  135.  
  136.    --jhb, 8/31/90
  137. ------------------------------------------------------------------------------
  138.  
  139.  
  140.   general concepts:
  141.  
  142.   1. main program should do command line parsing, call a LOAD routine of some
  143.      sort, and display the result.  It will sit in a loop parsing keyboard
  144.      commands until a file-changing command is given.
  145.  
  146.      Keyboard Commands:
  147.        Q:         quit
  148.        CR,SP:     next file
  149.        BS,DEL:    previous file
  150.        ,:         shrink picture 10%
  151.        .:         grow picture 10%
  152.        <:         shrink picture by factor of 2
  153.        >:         grow picture by factor of 2
  154.        N:         home.  (Show picture at normal size)
  155.        M:         max.   (grow picture to size of screen)
  156.        C:         crop picture
  157.        U:         uncrop picture
  158.        I:         info box
  159.        4:         4x3-ify the picture
  160.  
  161.      Mouse Commands:
  162.        Button1:  lets you draw a cropping rectangle
  163.        Button2:  
  164.        Button3:  
  165.  
  166.   2. LOAD routines:  given a file name.  They'll do optional suffix-tacking-on
  167.      if they wish to.  They will do whatever needs to be done to the picture
  168.      to get it into an 8-plane image with a colormap.  
  169.  
  170.      The load routines will return several things (in global variables):
  171.      pWIDE, pHIGH, a pWIDE*pHIGH array of pixels (pic) (one byte per), 0,0 is
  172.      the top-left corner of the image, a colormap (three 256-element arrays
  173.      of bytes, for r,g and b (called 'r', 'g', and 'b', oddly enough)
  174.  
  175.      load routines will return '0' if successful, a slew of non-zero things if
  176.      not 
  177.  
  178.   3. A common routine for colormap sort/compression (SortColormap()).
  179.      the colormap will be compressed.  That is, if only 37 colors
  180.      in the 256-element colormap are used, they will be the first 37 entries
  181.      in the colormap.  This way, the display portion of the code won't waste
  182.      resources allocating unused colors.  This routine will also modify the
  183.      PIC array accordingly.  
  184.  
  185.      This routine calculates 'numcols'.
  186.  
  187.      Thought:  have the colormap compression algorithm sort the colormap
  188.      so that the most-used color is first, and the other colors are in order
  189.      of decreasing distance from the first color.  (That is, the second color
  190.      will be the 'most unlike' the first color, the third color will be the
  191.      'second most unlike' the first color, and so on.)
  192.  
  193.      Justification:  Since we allocate colors in the order they're stored
  194.      in the colormap, it'd probably be better to get all the major colors
  195.      first, and then pick up the subtle shade differences if there's any
  196.      colors left.
  197.  
  198.      Improved sort algorithm.  Slower, but possibly more desirable.
  199.      (besides, the speed of this routine is not likely to be a problem)
  200.      Problem with previous algorithm:  a picture with a blue sky, a green
  201.      ground, and a dark blue car.  The previous algorithm will allocate the
  202.      sky blue (most used), and then try to allocate ALL THE SHADES OF GREEN
  203.      before trying for the dark blue.  Suboptimal.
  204.  
  205.      Solution, find the most used color, put it first in the cmap.
  206.      find the color the greatest distance from that, put it second in the cmap
  207.      NOW, find the color that is farthest away from BOTH of those colors
  208.      (that is, for each color left in the cmap, compute the min of it's 
  209.      distances from the ones that have been allocated already.  Then, take the
  210.      one that's got the largest min distance and allocate it.  continue)
  211.  
  212.      Still more modification to sort algorithm: The modified algorithm 
  213.      described above is a good thing, but runs on the order O(3).  Practical
  214.      upshot is that doing it for all 256 colors in a picture takes far too
  215.      long.  New idea: run that algorithm for the first 32 colors (an
  216.      arbitrary smallish number, and plenty fast), then sort the remaining 
  217.      colors in order of decreasing use.
  218.  
  219.   4. A common routine for 24-bit RGB -> 8 bit colormap conversion.
  220.      Since several different data formats might want to do this, this
  221.      routine will exist for their calling pleasure.  Input will be a wide*high
  222.      * 3 byte array of pixels, 3 bytes per (in order R, G, and B).  The
  223.      procedure will do the 'thing' and store results in all the global
  224.      variables that the load routines are supposed to return.  A load routine
  225.      should be able to just call this routine (once it's built the 24-bit
  226.      image) and return.  
  227.  
  228.      Input will also be number of colors to use.  That is, while it will still
  229.      produce a 8-bit PIC array, you might want it to only use 16 colors,
  230.      rather than 256.  (Say, if you're on a 4 bit display).  The reason you'd
  231.      want it to do this is that it'll probably do a better job of creating a
  232.      16-color picture than the DISPLAY routine would (if it was handed a 256
  233.      color picture and asked to display it on a 16-color display).
  234.      
  235.      The 24to8 routine (Conv24to8) will be clever, and if it knows you're
  236.      displaying on a monochrome screen (or -mono is set) or that you're
  237.      displaying on a 1-bit display (or -nc 0), it will just return an
  238.      8-bit greyscale version of the picture.  This is because running the
  239.      full 24-bit RGB to 8-bit pseudocolor conversion takes a long time,
  240.      and shouldn't be done if not necessary.
  241.  
  242.   5. Display routines.  Do whatever is necessary to show PIC on display.
  243.      This includes things like building an Ximage in the correct depth,
  244.      expanding/compressing size of image
  245.  
  246.      There will be a AllocColors() routine that will take the desired colormap
  247.      and see what it can do, based on the type of display you're using.
  248.      This routine will be called once per picture, before doing Resize()
  249.      (As Resize() calls CreateXImage()...)
  250.      
  251.      if (based on 'theVisual', or '-mono') we appear to be running on a 
  252.      GrayScale or StaticGray display, this algorithm will FIRST run through
  253.      the desired colormap (the 'epic' colormap) and replace the r,g,b values
  254.      for each entry with the corresponding intensity value (I=(.3r+.5g+.2b)/3)
  255.      This way, pictures will be correctly displayed on mono screens.
  256.  
  257.      Algorithm:  for >1 bit displays (ie, greyscale/color), alloc colors in
  258.      the X colormap in the order that the SortColormap routine returned.
  259.      Colors that couldn't be allocated are matched to the closest colors in
  260.      the global X colormap, or the just the colors allocated (based on the
  261.      value of 'noglob')
  262.  
  263.      the 'cols[]' array will hold the mapping between 'epic' colors and X
  264.      colors.  (ie, color #37 in epic and the epic colormap will correspond to 
  265.      color # cols[37] in the X image and the X colormap)
  266.  
  267.      the 'freecols[]' array (and nfcols, the length of it) will hold the X
  268.      pixel values of the colors that were allocated, so that they may be
  269.      later un-allocated.  Also, it will NOT have duplicate entries in it.
  270.      (ie, if allocating (15,15,15) and (16,16,16) both return pixel #2,
  271.      pixel #2 will be in freecols ONCE.)
  272.  
  273.      More algorithm:  for 1 bit displays there's only going to be two
  274.      colors, 'black' and 'white'.  (What the two colors actually look like
  275.      on the screen (ie, maybe it's blue and white, or black and green), is
  276.      not important.  So what we do here is, rather than try to allocate any
  277.      colors (it'd probably fail anyhow), run the Floyd Steinberg dithering
  278.      algorithm over the picture, and just use 'black' and 'white'
  279.  
  280.   6. There's several variables that seem to do the same thing.  They don't.
  281.      Here's what they do:
  282.  
  283.        pic, pWIDE, pHIGH:   This is the 8-bit image ret. by the load routine
  284.  
  285.        cpic, cWIDE, cHIGH,
  286.        cXOFF, cYOFF:        This is the cropped version of pic.  If there is
  287.                             no cropping going on, it will point to pic.
  288.                 cXOFF and cYOFF specify the offset from 0,0 of 
  289.                 the original pic.  (ie, pixel cXOFF,cYOFF in the
  290.                 original picture will be at 0,0 in the cpic image
  291.  
  292.        epic, eWIDE, eHIGH:  This is another 8-bit image.  This is an expanded/
  293.                             compressed version of cpic.  Generated in the
  294.                 Resize() function.  When there is no expansion
  295.                 (ie, eWIDE=pWIDE, eHIGH=pHIGH) epic *will* point
  296.                 to 'cpic'.  This way the X conversion routines
  297.                 can simply use epic, eWIDE, and eHIGH.
  298.  
  299.        theImage:  This is an Ximage version of epic.  It'll be in whatever
  300.                   depth/format is deemed appropriate for the X display.
  301.           It is generated from epic after epic has been Resize()'d
  302.           It's generated in the function CreateXImage()
  303.  
  304.      What happens to a picture from loading to display:
  305.        picture is loaded in some native format  
  306.            (local to LOAD routine)
  307.        picture is converted to 8-bit colortable routine  (pic)
  308.            (in LOAD routine.  native format data is thrown away)
  309.        LOOP
  310.          'pic' is cropped, if desired.  cpic points to picture data
  311.      'cpic' is expanded, if desired.  epic points to data
  312.      'epic' is converted to theImage 
  313.              (an X Format in the depth of the screen)
  314.        REPEAT
  315.  
  316.  
  317.   7. It should be noted that the several functions break on machines where
  318.      'int' is <32 bits.  These machines are wrong.
  319.  
  320.   8. added a 'perfect' mode, where it installs it's own colormap
  321.  
  322.   9. further thoughts...
  323.      add an ability to display multiple iconified-files at once (has to
  324.      be done in 'mono' mode... (contact sheets, Hagan calls them)
  325.  
  326.  10. color usage.  six colors can be specified via command-line/resource
  327.      database.  They are white,black, foreground,background, and 
  328.      info.foreground,info.background.  white and black are only used in
  329.      the 1-bit dithering routines (FloydDitherize8 and FloydDitherize1)
  330.  
  331.      foreground,background specify the colors of the window/frame
  332.      info.{fore,back}ground specifies the colors of the info box 
  333. \BARFOO\
  334. else
  335.   echo "will not over write ./docs/info"
  336. fi
  337. if `test ! -s ./docs/bggen.man`
  338. then
  339. echo "writting ./docs/bggen.man"
  340. cat > ./docs/bggen.man << '\BARFOO\'
  341. .TH bggen l
  342. .SH NAME
  343. bggen \- generates colored backgrounds on X11 displays
  344. .SH SYNTAX
  345. \fBbggen\fP [-w width] [-s size] [-b bits] r1 g1 b1 [r2 g2 b2 ... rn gn bn]
  346. .SH DESCRIPTION
  347. \fBbggen\fP is a program that generates a width-pixel wide by size-pixels high
  348. vertical stripe.  The top of the stripe is in color (r1,g1,b1), and the
  349. bottom of the stripe is in color (rn,gn,bn).  Intermediate colors are 
  350. interpolated between these colors.  If you specify more than 2 colors, the
  351. stripe passes through all the specified colors, in the order specified.
  352. .PP
  353. The '-b' option specifies the number of significant bits in the (output)
  354. color specifications.  It must range between 1 and 8, inclusive.  Use
  355. values less than 8 (the default) to limit color use by increasing the color
  356. granularity.
  357. .PP
  358. Values for 'r', 'g', and 'b' should range between 0 and 255, inclusive.  0
  359. means 'off', and 255 means 'fully on'.
  360. .PP
  361. \fBbggen\fP doesn't actually affect your background directly.  \fBbggen\fP
  362. merely generates a small PPM (Portable Pixmap Format) datafile that XV can
  363. read and display.
  364. .PP
  365. To use \fBbggen\fP, you should pipe its output into an XV command, such as:
  366. "xv -root -quit -slow24"
  367. .PP
  368. The default 'size' is 1024 pixels, which should be as tall as your display.  
  369. If your display is taller than that, you should specify its actual height,
  370. otherwise you will get a bizarre repeating effect, that you probably didn't 
  371. want.  Note:  If you specify small values of '-s', you can get some neat
  372. effects.
  373. .PP
  374. The '-w' argument has been added to improve the performance of various
  375. stippling algorithms (as in XV).  More information to work with, and such.
  376. Try using '-w 16' on these command lines to see what is meant.
  377. .SH TRY THESE
  378. .nf
  379. Light Blue to Dark Blue
  380.     bggen 100 100 255  50 50 150  | xv -ro -q -s
  381. RGB Rainbow
  382.     bggen 0 0 255  0 255 0  255 0 0 | xv -ro -q -s
  383. Green Cylinders
  384.     bggen 0 0 0  0 255 0  0 0 0 -s 128 | xv -ro -q -s
  385. Blue to Magenta
  386.     bggen 0 0 255  200 0 100 | xv -ro -q -s
  387. Full Rainbow
  388.     bggen 0 0 255  0 255 255  0 255 0  255 255 0  255 0 0 | xv -ro -q -s
  389. Repeating Rainbow
  390.     bggen 0 0 255  0 255 255  0 255 0  255 255 0  255 0 0 
  391.           255 0 255  0 0 255 -s 256 | xv -ro -q -s
  392. .fi
  393. .PP BUGS
  394. It'd probably be nice if the program used some X calls to determine screen
  395. size.  It'd also probably be nice if the program could take colors by 'name',
  396. and also by hexadecimal value.
  397. .SH AUTHOR
  398. John Bradley  -  bradley@cis.upenn.edu
  399.  
  400. \BARFOO\
  401. else
  402.   echo "will not over write ./docs/bggen.man"
  403. fi
  404. if `test ! -s ./docs/xv.man`
  405. then
  406. echo "writting ./docs/xv.man"
  407. cat > ./docs/xv.man << '\BARFOO\'
  408. .TH xv l
  409. .SH NAME
  410. \fBxv\fP \- displays and manipulates images on X11 displays
  411. .SH SYNTAX
  412. \fBxv\fP \fI[options] [filename [filename...]]\fP
  413. .SH DESCRIPTION
  414. \fIxv\fP is an X11 program that displays images in the GIF, PBM, PGM, PPM, 
  415. X11 bitmap, and PM formats on 1-, 4-, 6-, 8-, 24-, and 32-bit X displays.  
  416. .SH OVERVIEW
  417. \fIxv\fP displays one image at a time in an output window.  You can arbitrarily
  418. stretch or compress the window, and the picture will be rescaled to fit.  
  419. You can rotate the picture in 90-degree steps.  You can repeatedly 'crop'
  420. a picture (define a rectangular 'region-of-interest' and 'throw away' the
  421. rest).  You can magnify any portion of the picture by 
  422. any amount, up to the maximum size of your screen.  
  423. .PP
  424. \fIxv\fP allows you click on the picture to determine pixel RGB values and
  425. x,y coordinates.  You can perform arbitrary 'gamma correction' on the picture
  426. both in RGB space and HSV space.  You can specify the maximum number of colors
  427. that \fIxv\fP should use, for some interesting visual effects.  You can have
  428. the program produce a stippled version of the picture using black and white,
  429. or any other pair of colors.  
  430. .PP
  431. \fIxv\fP can write images in a variety of formats, with many of the 
  432. modifications you may have made to the picture saved as well.  You can use
  433. \fIxv\fP to do format conversion.  \fIxv\fP will also automatically 
  434. uncompress \fBcompress\fP\-ed files, as well as read files from stdin.
  435. .PP
  436. It slices, it dices, and it'll balance your checkbook if you aren't careful.
  437. .SH USING THE PROGRAM
  438. Start the program up by typing '\fIxv\fP \fIfilename\fP' After a short 
  439. delay, a window 
  440. will appear with the desired image displayed in it.  If you change the size 
  441. of the window, (however your particular window manager lets you do this), the 
  442. picture will rescale to fit the window.
  443. .PP
  444. Clicking (and dragging) the Left mouse button inside the image window will
  445. display pixel information.  The first two numbers are the x and y offset,
  446. in pixels, from the top-left corner of the image.  The first group of three
  447. numbers are the red, green, and blue values of that pixel from the original
  448. data (after any 24-bit to 8-bit conversions...).  The second group of
  449. three numbers are the red, green, and blue values of that pixel AFTER any gamma
  450. correction (and the '\fB\-rv\fP' option).  If you actually want to measure some
  451. pixels, it will probably help to crop to a small region, and expand that 
  452. region quite a bit, to the point where you can see individual pixels.
  453. .PP
  454. If you type 'h', '?' or click the Right mouse button inside this window,
  455. the CONTROL BOX window will appear.  This box will contain a list of 
  456. file names (just one in this example) and many buttons.
  457. .PP
  458. Note:  unless specified otherwise, 'click' means 'click with the Left mouse
  459. button'.
  460. .SH THE CONTROL BOX
  461. Most of the buttons in the control box let you adjust the size of the
  462. currently shown picture.  You can either click the button, or type a keyboard
  463. equivalent inside ANY \fIxv\fP window (except the SAVE BOX (see below)).  It
  464. should be noted that the 'resizing' controls do not MODIFY the picture in any
  465. way.  They simply change the way the picture is displayed, by duplicating or
  466. dropping pixels from the original picture to produce an image of the desired
  467. size.  As you expand images, they will get 'chunkier'.
  468. .PP
  469. The 'Max Size' button (or 'm' key) causes the picture to be redrawn so that it
  470. completely fills the screen.  Be warned that this might take a while,
  471. depending on the speed of your machine.  It also may cover all the other
  472. windows on the screen, including the control window.  If this happens, you can
  473. bring the control window back to the top by clicking the Right mouse button 
  474. in the picture window one or two times.
  475. .PP
  476. The 'Normal' button (or 'n' key) returns the picture to it's normal size.
  477. Normal size is defined as a 1 to 1 mapping between pixels in the image and
  478. pixels on the screen.  (i.e., if you have a 320x200 image, the 'Normal' command
  479. will set the 'on-screen' size to 320x200).
  480. .PP
  481. The only exception to this behavior is when the image is larger than your 
  482. screen.  In this case, the picture is 'halved' until it fits.  (For example,
  483. if you were trying to display a 1000x600 image on an 800x600 screen, 
  484. the 'Normal' command would set the 'on-screen' size to 500x300.)
  485. .PP
  486. The 'Dbl Size' button (or '>' key) doubles the width and height of the picture,
  487. under the constrant that the picture may not be larger than the screen.  (ie,
  488. if you have a 900x100 image, and a 1000x800 screen, doubling would result in
  489. a picture size of 1000x200 (the doubling of the '900' was clipped))
  490. .PP
  491. The 'Half Size' button (or '<' key) halves the width and height of the 
  492. picture.
  493. .PP
  494. The '+10%' button (or '.' key) adds 10% to the width and height of the 
  495. picture.  (Under the same constrant as 'Dbl Size'.)
  496. .PP
  497. The '-10%' button (or ',' key) subtracts 10% from the width and height of the
  498. picture.  
  499. .PP
  500. NOTE: The '+10%' and '-10%' buttons are NOT complementary.  If, for example, 
  501. you have a 100x100 picture, '+10%' will make it into a 110x110 picture.  If 
  502. you then do '-10%', you will have a 99x99 picture.  (10% of 110 = 11 ;
  503. 110 - 11 = 99)  The '+10%' and '-10%' buttons have no concept of an 'original
  504. size' to use as an increment/decrement basis.  They only expand or shrink
  505. the current picture by 10% of its current size.
  506. .PP
  507. The '4x3' button (or '4' key) attempts to resize the picture so that the ratio
  508. of width to height is equal to 4 to 3.  (eg, 320x240, 400x300, etc.)  This is
  509. quite useful because most images were meant to fill the screen of 
  510. whatever they were generated on, and nearly all video 
  511. screens have an aspect ratio of 4:3.  By issuing this command, the picture
  512. will be stretched so the proportions of things will (possibly) look right on 
  513. your X display.  (Most of which, thank god, have square pixels.)  
  514. This is particularly obvious on pictures that have really
  515. bizarre sizes (such as the 600x200 pictures presumably meant for CGA).
  516. .PP
  517. The 'Aspect' button (or 'a' key) applies the 'default aspect ratio' to the
  518. picture.  (This is done automatically when the image is first loaded.)  
  519. Normally, the default aspect ratio is '1:1', but certain GIF files may have
  520. an aspect ratio encoded in them.  You can also set the default aspect ratio
  521. via a command-line argument or an X Resource.  The idea here is that you'd
  522. stretch the picture manually (via your window manager) to roughly the size 
  523. you'd like, then you'd click on 'Aspect' to fix-up the proportions.
  524. .PP
  525. The 'Maxpect' button (or 'M' key) makes the picture as large as will fit on
  526. the screen, but preserves the aspect ratio.  
  527. .PP
  528. The 'Turn R' button (or 't' key) rotates the picture 90 degrees clockwise.
  529. It should be noted that when you rotate the picture, you are rotating the
  530. ENTIRE image, even if you're only viewing a small section of it (via 
  531. cropping).
  532. .PP
  533. The 'Turn L' button (or 'T' key) rotates the picture 90 degrees counter-
  534. clockwise.
  535. .PP
  536. The 'Gamma' button (or 'g' key) opens up the GAMMA BOX.  (See 'GAMMA BOX',
  537. below.)
  538. .PP
  539. The 'Info' button (or 'i' key) opens up the INFO BOX.  (See 'INFO BOX',
  540. below.)
  541. .PP
  542. The 'Save' button (or 's' key) opens up the SAVE BOX.  (See 'SAVE BOX',
  543. below.)
  544. .SH CROPPING
  545. In addition to being able to resize/rotate the image, you can do the same to
  546. any rectangular region of the image.  By pressing the Middle mouse button in
  547. the picture window, and dragging it, you'll be able to draw a rectangle.
  548. When this rectangle is visible, the 'Crop' button in the CONTROL BOX lights
  549. up, enabling the 'Crop' command.  
  550. .PP
  551. You can 'fine-tune' the cropping rectangle by using the arrow keys on your
  552. workstation.  The arrow keys (unmodified) will move the cropping rectangle in
  553. the requested direction, preserving its current size.  You can change the size
  554. of the cropping rectangle by holding the 'Shift' key down and using the 
  555. arrow keys.  'Shift-Left' makes the rectangle narrower, 'Shift-Up' makes it
  556. shorter, 'Shift-Right' makes it wider, and 'Shift-Down' makes it taller.
  557. For precise cropping, you'll probably want the INFO BOX visible, which will
  558. tell you the position and size of the cropping rectangle, in image coordinates.
  559. .PP
  560. If you press the 'Crop' button (or the 'c'
  561. key), the parts of the picture outside the rectangle will disappear, and the
  562. window will shrink to the size of the rectangle.  Also, the 'Crop' button 
  563. will 'dim', and the 'UnCrop' button will light up.
  564. .PP
  565. You can manipulate this portion of the image exactly as if it were the
  566. entire image.  You can even draw another 'cropping rectangle' on it and do
  567. the 'Crop' command again.
  568. .PP
  569. Pressing the 'UnCrop' button (or the 'u' key) (when lit) will return to
  570. manipulating the entire image.  It will try to keep the current 'expansion',
  571. but if that would result in a picture larger than the screen, it will use
  572. the 'normal' size (defined in the description of the 'Normal' button).
  573. .PP
  574. The 'AutoCrop' button (or the 'A' key) will crop off any constant borders 
  575. that exist in the picture.  It will crop to smallest rectangle that encloses
  576. the 'interesting' section of the picture.
  577. .SH MULTIPLE FILES
  578. If, when you started \fIxv\fP, you specified more than one file name, you'll be
  579. able to use the file-selection controls in the CONTROL BOX.
  580. .PP
  581. The CONTROL BOX will have a list of the filenames 
  582. that you specified on the command line.  The
  583. names will be shown without any common prefixes.  For example, if you started
  584. \fIxv\fP with the command '\fIxv /pic/gif/*\fP', the filenames will be shown 
  585. without the leading '/pic/gif/'.  The current filename will be shown 
  586. in reverse video.
  587. .PP
  588. If there's more than a screenful of file names the scrollbar will be enabled.
  589. .PP
  590. You can scroll through the list a line at a time by using the up and down
  591. arrow buttons in the scroll bar.  If you hold the button down, it will 
  592. auto-repeat.  If you click inside the gray region of the scrollbar, but not
  593. on the slider, the list will be scrolled up or down (depending on whether you
  594. clicked above or below the slider) a page at a time.  If you click on the 
  595. slider, you can drag it to another position and let go of it.
  596. .PP
  597. You can also scroll through the list by clicking on the list itself, (which
  598. will move the reverse video 'bar') and dragging up or down.
  599. .PP
  600. In short, it behaves like a Macintosh.
  601. .PP
  602. You can display any picture file by double-clicking on its filename.  The
  603. current picture will go away, and the new picture will be displayed,
  604. if possible.
  605. If \fIxv\fP was unable to load the selected picture, the previous picture will
  606. be re-displayed.
  607. .PP
  608. If there are multiple files, and you aren't at the end of the list, the 'Next'
  609. button will be enabled.  Clicking 'Next' (or pressing the RETURN or SPACEBAR 
  610. keys) will close the current picture and bring up the next one.  This is the
  611. normal way to view multiple images.
  612. .PP
  613. If there are multiple files, and you aren't at the beginning of the list,
  614. the 'Previous' button will be enabled.  Clicking 'Prev' (or pressing the
  615. BACKSPACE or DELETE keys) will close the current picture and bring up the
  616. previous one.
  617. .PP
  618. It should be pointed out that all of these commands work whether or not the
  619. CONTROL BOX is visible (though if it's not visible, you'll obviously have
  620. to use the keyboard equivalents.)
  621. .SH QUITTING THE PROGRAM
  622. Pressing the 'Quit' button (or the 'q' key) will exit the program.
  623. .PP
  624. .SH THE INFO BOX
  625. The INFO BOX displays several bits of information.  In addition to 
  626. credits and a revision date, the INFO BOX displays information about the 
  627. currently displayed picture.  It shows the current file name, the format of 
  628. the current file, its size, and its resolution.  This information is available
  629. early in the loading process, and is displayed as soon is it is known.  The
  630. rest of the lines are filled in after the picture has been loaded.
  631. .PP
  632. The 'Cropping' line displays the coordinates of the current cropping 
  633. rectangle.  Normally, this line says 'none', but if you draw a cropping
  634. rectangle on the picture (see CROPPING, above) it will display the size
  635. and position of the rectangle in Image Coordinates.  The first two numbers
  636. are the width and height of the rectangle, respectively.
  637. The second pair of numbers specifies where
  638. the upper-left corner of the rectangle is, as an offset from the upper-left
  639. corner of the entire image.
  640. .PP
  641. The 'Expansion' line shows the effects of any stretching that you may have
  642. done to the picture.  The first pair of numbers represent the stretching as
  643. a ratio of two scaling factors.  Normally, they will be '1x1', which indicates
  644. that one data pixel maps to one screen pixel, in both x and y axes.  For
  645. example, the values '2x3' would indicate that the image or sub-image
  646. has been made twice as
  647. wide as normal, and three times as high as normal.  The second pair of 
  648. numbers, (the ones in parenthesis) simply display the current screen size of
  649. the image.
  650. .PP
  651. The 'Colors' lines displays how successful the color allocation schemes have
  652. been.  Normally, \fIxv\fP uses a three-pass color allocation algorithm.  
  653. In the first pass, the program requests every color that the picture
  654. requires to be displayed properly.  The results of this attempt are printed
  655. on the first 'Colors' line.  If everything  worked out perfectly, this
  656. line will say "Got all \fIx\fP desired colors.", and may 
  657. append "(\fIy\fP unique)".
  658. In this string, \fIx\fP is the number of colors that the picture required.
  659. If the 'unique' string is appended, that means that some of the colors
  660. were duplicates of one another, and the picture only REALLY needed (and 
  661. was only allocated) \fIy\fP colors.
  662. .PP
  663. If \fIxv\fP wasn't able to get all the colors it wanted, it will run
  664. the second-pass color allocation code.  In this pass, the program will
  665. ask the display what colors it has available in its colormap,
  666. dtermine which of those colors are 'close' to the desired colors, and try
  667. to allocate those colors.
  668. The program will print "Got \fIx\fP 'close' colors." if it performed the
  669. second pass allocation.  This is so that the user will know that image 
  670. displayed is not as well as it could possibly be.
  671. .PP
  672. Finally, if even that didn't work, \fIxv\fP will normally attempt to 'borrow'
  673. colors from the colormap without actually allocating them.  These colors
  674. are not owned by the program, and they can change without \fIxv\fP's knowledge.
  675. If this third pass is executed, the program will 
  676. print "'Borrowed' \fIx\fP colors."
  677. .PP
  678. It should be noted that the '\fB\-noglob\fP', '\fB\-perfect\fP', 
  679. and '\fB\-rw\fP' options modify
  680. the way color allocation is handled in \fIxv\fP, and will therefore modify
  681. what will be displayed in the INFO BOX.  For example, if you 
  682. specify '\fB\-noglob\fP', 
  683. \fIxv\fP will never 'borrow' colors, so you'll never see a third-pass line.
  684. .PP
  685. Finally, the INFO BOX will display warning messages that occur while loading
  686. the image.  In particular the message 'File appears truncated, winging it'
  687. comes to mind, from the GIF image loading code.
  688. .PP
  689. .SH THE GAMMA BOX
  690. The GAMMA BOX is used to control image brightness, contrast, and to get some
  691. fairly bizarre effects.  The majority of this box is taken up by a window
  692. that displays the current gamma correction curve.  This curve defines a 
  693. mapping between the input values (0-255) along the \fIx\fP axis, and the
  694. output values (0-255) along the \fIy\fP axis.  How these values are interpreted
  695. depends on the setting of the 'HSV/RGB Mode' button.  (see below)
  696. .PP
  697. The gamma curve is defined by four 'control points', two of which are locked
  698. at the left and right edges of the window.  These two points may only move
  699. up and down.  The other two points may be moved freely around the window,
  700. subject only to the constraint that they cannot be moved past one another
  701. on the \fIx\fP axis.  The 'left' point must stay to the left of the 'right'
  702. point.
  703. .PP
  704. The gamma curve can be adjusted in a variety of ways.  You can change the
  705. curve directly by clicking on one of the control points and dragging it.
  706. Also, you can indirectly adjust the curve by using 
  707. the 'Brighter', 'Dimmer', 'Sharper', and 'Duller' buttons.
  708. .PP
  709. The 'Apply' button takes the current gamma curve, and applies it to the
  710. ORIGINAL picture data, according to the setting of the 'HSV/RGB Mode' button,
  711. and displays the results.  It's important to note that the gamma curve is
  712. always applied to the original data.  It is not applied to the 
  713. currently-displayed data.  Thus, if you draw a gamma curve that makes
  714. pictures darker, and click 'Apply' several times, it will only (noticably)
  715. do anything the first time.  It will NOT keep making the picture darker.
  716. Also, it should be noted that the apply button
  717. is very often unnecessary.  If you specified the '\fB\-rw\fP' option on the 
  718. command line,
  719. the gamma curve will be automatically applied every time it is 
  720. changed.  (Keyboard equivalent: 'p')
  721. .PP
  722. The 'No Gamma' button shows the original picture with no gamma correction,
  723. but does not affect the current gamma curve.  It just ignores it.  You can
  724. use this command to do A/B comparisions between the original picture and
  725. your 'improved' version.
  726. .PP
  727. The 'Linear' button sets the gamma curve to a straight line from 0,0 to 
  728. 255,255.  This has the effect of displaying the picture without any
  729. apparent gamma correction, much like the 'No Gamma' command, however, this
  730. command also resets the curve.  This command serves as an "Aaah!  I've 
  731. screwed it up horribly!" fix.
  732. .PP
  733. The 'Default' button sets the gamma curve to its default setting.  Normally,
  734. this is a straight line, exactly the same as the 'Linear' command.  However,
  735. by specifying the '\fB\-GAMMA\fP' option on the command line, or by 
  736. defining the 'xv.gamma' resource, it is possible to the the default
  737. gamma correction to something else entirely.
  738. .PP
  739. The 'Spline' button is actually a two-state switch that displays its
  740. current setting.  It controls how the four control points are connected.
  741. By default, they are connected by a spline curve.  Unfortunately, some
  742. gamma curves are hard to get (or impossible) in this mode.  Clicking
  743. the 'Spline' button will toggle it to 'Lines'.  The control points will now
  744. be connected by straight lines.  Clicking the button again will set it back 
  745. to 'Spline'.
  746. .PP
  747. The 'Close' button hides the GAMMA BOX.  Use the 'Gamma' command (see
  748. CONTROL BOX, above) to make it visible again.
  749. .PP
  750. The 'Brighter' button makes the picture brighter.  Unless you're running 
  751. in '\fB\-rw\fP' mode, you'll have to press 'Apply' to see the effect.
  752. .PP
  753. The 'Dimmer' button makes the picture dimmer.
  754. .PP
  755. The 'Sharper' button increases the contrast of the picture.
  756. .PP
  757. The 'Duller' button decreases the contrast of the picture.
  758. .PP
  759. The 'HSV/RGB Mode' button is a two-state switch that displays its current
  760. setting.  It affects HOW the gamma curve is used.  By default, it is 
  761. in 'HSV Mode'.  In this mode, the colors of the picture are converted from
  762. the RGB model (red, green, and blue) into the HSV model (hue, saturation, 
  763. and value).  The gamma curve is applied to the 'value' (brightness) of the
  764. HSV colors.  The (modified) HSV colors are converted back to RGB colors so
  765. that they may be displayed.  In this mode, colors are made brighter or
  766. dimmer, according to the curve, but their Hue and Saturation is not changed.
  767. This is generally the more desirable way to apply gamma correction to color
  768. pictures.
  769. .PP
  770. When the 'HSV/RGB Mode' button is in 'RGB Mode', the gamma curve is applied to
  771. each of the RGB components (red, green, and blue) separately.  This can have
  772. some interesting effects, particularly when you use a drastic gamma correction
  773. curve.  For example, assume a gamma curve that is a straight line from 0,255 to
  774. 255,0 (top-left to bottom-right, instead of the 'normal' bottom-left 
  775. to top-right).  In HSV Mode, this curve will merely take 'dark' colors and 
  776. make them 'light', and vice-versa.  (i.e., dark blue <-> light blue).
  777. The RGB Mode, on the other hand will COMPLEMENT the colors.  (blue <-> yellow,
  778. red <-> cyan, and green <-> violet).  Both modes will do (black <-> white),
  779. however.  The RGB Mode is mainly for amusement value.
  780. .PP
  781. It should be noted that when viewing greyscale pictures, it makes no difference
  782. whether you are in HSV or RGB mode.  Both modes will behave exactly the same.
  783. Also, note that when the '\fB\-rw\fP' option is specified, gamma correction 
  784. is performed AFTER the reversal.
  785. .PP
  786. \fIxv\fP allows you to have four gamma 'presets'.  By default, they have
  787. four vaguely useful curves.  You can 'load' them by clicking
  788. on the '1', '2', '3', or '4' buttons, respectively.  You can 'write' them by
  789. clicking 'Set', and clicking one of the numbered buttons.  The current gamma
  790. correction curve will be 'stored' in the preset number you clicked, and
  791. will remain there until overwritten, or until you exit the program.
  792. .PP
  793. Notes:  The Spline/Lines and HSV/RGB settings are NOT stored in the presets.
  794. A weakness, admittedly.  You can specify your own 'default settings' for
  795. the presets by setting the X resources 'xv.gamma1', 'xv.gamma2', etc.
  796. .PP
  797. The 'Undo' button undoes the last change to the gamma curve.  Currently, the
  798. undo buffer is eight slots long, so you can undo up to the last eight 
  799. changes.  There is no way to 'undo an undo', however.  As with presets, the
  800. Spline/Lines and HSV/RGB settings are not saved, nor are they 
  801. considered 'changes'.
  802. .PP
  803. At the top of the GAMMA BOX are six numbers that define the current gamma
  804. correction curve.  The numbers are, in order, the y-coordinate of the first
  805. control point, the x- and y-coordinates of the second and third control points,
  806. and the y-coordinate of the fourth control point.  These numbers appear in
  807. the same order that they would be specifed to the '\fB\-GAMMA\fP' command line
  808. option, or the 'xv.gamma', 'xv.gamma[1-4]' X resources.
  809. .PP
  810. .SH THE SAVE BOX
  811. When you issue the 'Save' command (by clicking the 'Save' button in the CONTROL
  812. BOX (above), or typing 's' in any of the \fIxv\fP windows, the SAVE BOX will
  813. appear, giving you an opportunity to write the current file to disk.  The file
  814. will consist of the currently-visible portion of the picture.  Normally, this
  815. would be the entire picture, but if you 'crop' first, and then save, it will
  816. only save the cropped-to region.
  817. If the picture has been rotated, the rotation will also be saved in the
  818. file.  If a gamma correction curve has been applied to a picture, the picture
  819. will be saved with the gamma correction.
  820. .PP
  821. Major Bummer:  As noted elsewhere, \fIxv\fP stores images internally as
  822. 8-bit colormapped images.  If you load a 24-bit color image, it is converted
  823. to an 8-bit image IMMEDIATELY, and the 24-bit version is thrown away.  As such,
  824. you do not REALLY want to use \fIxv\fP to modify (crop, rotate, etc.) 
  825. 24-bit images, as much of the information will be lost in the translation.
  826. .PP
  827. Saved images are not affected by the display that they were saved on.  
  828. For example, if you displayed a full-color image on a 1-bit b/w display, it
  829. would be dithered in black and white.  If you save the image, by default, it
  830. will be saved as a full-color image.  All the data will still be there.
  831. .PP
  832. When you open up the SAVE BOX, it will display the contents of the current
  833. directory in a scrollable list.  
  834. Next to each file name will be an icon
  835. representing its file type.  Subdirectories will be shown as 'file folders', 
  836. for instance.  You can go 'down' the directory tree by 'Open'-ing a
  837. subdirectory, either by clicking on its name and clicking the 'Open'
  838. button, or by double clicking on the name.  (Note:  You can only 'Open' 
  839. directories and symbolic links.  Other files are displayed merely as a
  840. navigational aid.)
  841. .PP
  842. You can go 'up' the directory tree by clicking on the button at the very top
  843. of the SAVE BOX.  A pop-up menu will appear, with the current directory name
  844. at the top, and its parent directories listed below it.  Drag the mouse to any
  845. directory in this list and let go.  You will switch to that directory.
  846. .PP
  847. Once you are in the correct directory, you can save the file by typing a
  848. simple file name (no /'s) and clicking 'Save' or pressing return.  Ctrl-U
  849. or Ctrl-K will clear the line.  By default, the file will be saved as a
  850. full-color GIF file, in 'Normal Size'.  You can choose the format by clicking
  851. on the buttons at the bottom of the window.  Note that some combinations are
  852. not possible (for example, X11 Bitmaps can only be saved as 'B/W Dithered').
  853. Also, the 'PBM (raw)' and 'PBM (ascii)' formats actually cover all PBM/PGM/PPM
  854. formats.  The particular format is chosen according to the setting of 
  855. the 'Colors' control.
  856. .PP
  857. The 'Cancel' button gets rid of the SAVE BOX.  You'll have to issue the 'Save'
  858. command to make it visible again.
  859. .PP
  860. The 'Quit' button exits \fIxv\fP.  It is provided as a convenience, as you'll
  861. often want to quit immediately after saving a file.
  862. .PP
  863. Note:  Since the SAVE BOX is expecting you to type a file name, you cannot
  864. execute keyboard commands (see 'Shortcuts', below) while the keyboard 
  865. focus is in this window (generally, whenever the mouse is in this window).
  866. .PP
  867. .SH COMMAND LINE OPTIONS
  868. There are a Vast Multitude of options.  Note: only the first few 
  869. unique characters of an option name are required.  For example, '\fB\-d\fP' 
  870. is a legal abbreviation for '\fB\-display\fP', but you'd have to 
  871. give '\fB\-nc\fP' as an abbreviation for '\fB\-ncols\fP', because 
  872. there's another option that starts with the letter 'n'.
  873. .PP
  874. That said...
  875. .SH GENERAL OPTIONS
  876. .IP \fB\-help\fP 12
  877. Print usage instructions, listing the current available command-line options.
  878. Any unrecognized option will do this as well.  
  879. .IP \fB\-display\fP 12
  880. Specifies the display that \fIxv\fP should attempt to 
  881. connect to.  If you don't specify a display, \fIxv\fP will use the 
  882. environment variable $DISPLAY.
  883. .IP \fB\-fg\fP 12
  884. Sets the foreground color used by the windows.  (Resource name:  foreground.
  885. Type: string)
  886. .IP \fB\-bg\fP 12
  887. Sets the background color used by the windows.  (Resource name:  background.
  888. Type: string)
  889. .IP \fB\-bw\fP 12
  890. Sets the width of the border on the windows.  Your window
  891. manager may choose to ignore this, however.  (Resource name:  borderWidth.
  892. Type: integer)
  893. .PP
  894. .SH WINDOW SIZING OPTIONS
  895. .IP \fB\-geometry\fP 12
  896. Lets you specify the size and placement of the 'image' window.  It's most
  897. useful when you only specify a position, and let \fIxv\fP choose the size.
  898. If you specify a size as well, \fIxv\fP will create a window of that size,
  899. unless '\fB\-fixed\fP' is specified.  (Resource name: geometry.  Type: string)
  900. .IP \fB\-fixed\fP 12
  901. Only used in conjunction with the '\fB\-geometry\fP'
  902. option.  If you specify a window size with the '\fB\-geometry\fP' 
  903. option, \fIxv\fP
  904. will normally stretch the picture to exactly that size.  This is not
  905. always desirable, as it may seriously distort the aspect ratio of the
  906. picture.  Specifying the '\fB\-fixed\fP' option corrects this behavior.  When
  907. you do this, \fIxv\fP will now use the geometry size as a MAXIMUM window
  908. size.  It will, however, preserve the original aspect ratio of the
  909. picture.  For example, if you give a rectangular geometry of '320x240', 
  910. and you try to display a square picture of '256x256', the
  911. window opened will actually be '240x240', which is the largest square
  912. that still fits in the '320x240' rectangle that was specified. (resource 
  913. name: fixed)
  914. .IP \fB\-expand\fP 12
  915. Lets you specify an initial expansion or compression 
  916. factor for the picture.  It expects an integer value.  Values larger than 1
  917. multiply the picture's dimensions by the given factor.  (ie, an expand factor
  918. of '3' will make a 320x200 image display as 960x600).  Factors less than zero
  919. are treated as reciprocals.  (ie, an expand factor of '-4' makes the picture
  920. 1/4th its normal size.)  '0' is not a valid expansion factor.  (resource
  921. name: expand)
  922. .IP \fB\-aspect\fP 12
  923. Lets you set an initial aspect ratio, and also sets the
  924. value used by the 'Aspect' control.  The aspect ratio of nearly every X 
  925. display (and, in fact, any civilized graphics display) is 1:1.  What this 
  926. means is that pixels appear to be 'square'.  A 100 pixel wide by 100 pixel high
  927. box will appear on the screen as a square.  Unfortunately, this is not the
  928. case with some screens, and many digitizers.  The '\fB\-aspect\fP' 
  929. option lets you
  930. stretch the picture so that the picture appears correctly on your display.
  931. Unlike the other size-related options, this one doesn't care what the 
  932. size of the overall picture is.  
  933. It operates on a pixel-by-pixel basis, stretching each image pixel slightly,
  934. in either width or height, depending on the ratio.
  935. Aspect ratios greater than '1' make the picture
  936. wider than normal.  Aspect ratios less than 1 make the picture taller than
  937. normal.  (Useful aspect ratio:  A 512x480 image that was supposed to fill
  938. a standard 4x3 video screen should be displayed with an aspect ratio 
  939. of 5:4)  (Resource name:  aspect.  Type: string)
  940. .PP
  941. .SH COLOR ALLOCATION OPTIONS
  942. .IP \fB\-ncols\fP 12
  943. Sets the maximum number of colors that \fIxv\fP will
  944. use.  Normally, this is set to 'as many as it can get'.  (ie, 2^(depth of
  945. screen)) However, you can set this to smaller values for interesting effect.
  946. Most notably, if you set it to '0', it will display the picture by dithering
  947. with 'black' and 'white'.  (The actual colors used can be set by 
  948. the '\fB\-black\fP' and '\fB\-white\fP' options, 
  949. below.)  (Resource name: ncols.  Type: integer)
  950. .IP \fB\-nglobal\fP 12
  951. Adjusts the way the program behaves when it is unable to
  952. get all the colors it requested.  Normally, it will search the display's
  953. default colormap, and 'borrow' any colors it deems appropriate.  These
  954. borrowed colors are, however, NOT owned by \fIxv\fP, and as such, can changed
  955. without \fIxv\fP's permission, or knowledge.  If this happens, the displayed
  956. picture will change, in a less-than-desirable direction.  If
  957. you specify the '\fB\-nglobal\fP' option, \fIxv\fP will not 
  958. use 'global' colors.  It
  959. will only use colors that it successfully allocated, which makes it immune to
  960. any color changes.  (Resource name: nglobal.  Type boolean)
  961. .IP 
  962. It should be noted that 'use global colors' is the default because color
  963. changes aren't generally a problem if you are only using \fIxv\fP to display a
  964. picture for a short time.  Color changes only really become a problem
  965. if you use \fIxv\fP to display a picture that you will be keeping around for a
  966. while, while you go and do some other work (such as using \fIxv\fP to display
  967. a background).  In such cases you will want to specify '\fB\-nglobal\fP'.  
  968. Note: using the '\fB\-ncols\fP' or '\fB\-root\fP' options automatically 
  969. turn on '\fB\-nglobal\fP'.
  970. .IP \fB\-rw\fP 12
  971. Tells \fIxv\fP to use read/write color cells.  Normally,
  972. \fIxv\fP allocates colors read-only, which allows it to share colors with
  973. other programs.  If you use read/write color cells, no other program can use
  974. the colors that \fIxv\fP is using, and vice-versa.  The only reason you'd do 
  975. such a thing is that using read/write color cells allows 
  976. the 'Apply' function in the Gamma window to operate many 
  977. times faster.  (Resource name: rwColor.  Type: boolean)
  978. .IP \fB\-perfect\fP 12
  979. Makes \fIxv\fP try 'extra hard' to get all the colors it
  980. wants.  In particular, when '\fB\-perfect\fP' is specified, \fIxv\fP 
  981. will allocate and
  982. install its own colormap if (and only if) it was unable to allocate all the
  983. desired colors.  This option is not allowed in conjunction 
  984. with the '\fB\-root\fP'
  985. option.  (Resource name:  perfect.  Type boolean)
  986. .IP \fB\-ninst\fP 12
  987. Prevents \fIxv\fP from 'installing' its own colormap, when
  988. the '\fB\-perfect\fP' option is in effect.  Instead of installing 
  989. the colormap, it
  990. will merely 'ask the window manager, nicely' to take care of it.  This is the
  991. correct way to install a colormap (ie, ask the WM to do it), unfortunately, it
  992. doesn't actually seem to work in many window managers, so the default behavior
  993. is for \fIxv\fP to handle installation itself.  However, this has been seen to
  994. annoy one window manager (dxwm), so this option is provided if your WM doesn't
  995. like programs installing their own colormaps.  Note that this is ONLY relevant
  996. if A) '\fB\-perfect\fP' has been specified and B) \fIxv\fP ran out of 
  997. colors and
  998. generated its own colormap.  (Resource name: ninstall.  Type: boolean)
  999. .PP
  1000. .SH 24 BIT CONVERSION OPTIONS
  1001. The following options only come into play if you are using \fIxv\fP to display
  1002. 24-bit RGB data (PPM files, color PM files, and the output of \fIbggen\fP).
  1003. They have no effect whatsoever on how GIF pictures or 8-bit greyscale 
  1004. images are displayed.
  1005. .IP \fB\-slow24\fP 12
  1006. Specifies that the 'alternate' 24-bit to 8-bit conversion
  1007. algorithm is to be used by the program.  The default algorithm dithers the
  1008. picture using a fixed set of colors that roughly approximate all displayable
  1009. colors.  The '\fB\-slow24\fP' algorithm picks the 'best' colors on a 
  1010. per-image basis,
  1011. and dithers with those.  Advantages: The '\fB\-slow24\fP' 
  1012. algorithm often produces
  1013. better looking pictures.  Disadvantages: The '\fB\-slow24\fP' 
  1014. algorithm is about half
  1015. the speed of the default algorithm.  Since the colors are chosen on a
  1016. per-image basis, it can't be used to display multiple images, as each image
  1017. will almost certainly want a different set of 256 colors.  The default
  1018. algorithm, however, uses the same exact colors for all images, so it can
  1019. display many images simultaneously, without running out of colors.  Also, 
  1020. the '\fB\-slow24\fP' algorithm occasionally produces worse-looking 
  1021. pictures than the
  1022. default algorithm, particularly on displays with very few colors.  The default
  1023. algorithm produces nice, dependably 'okay' pictures.  (Resource name: slow24.
  1024. Type: boolean)
  1025. .IP \fB\-noqcheck\fP 12
  1026. Turns off a 'quick check' that is normally made.
  1027. Normally, before running either of the 24-bit to 8-bit conversion algorithms,
  1028. \fIxv\fP determines whether the picture to be displayed has more than 256
  1029. unique colors in it.  If the picture doesn't, it will treat the picture as an
  1030. 8-bit colormapped image (ie, GIF), and won't run either of the conversion
  1031. algorithms.  Advantages: The pictures will be displayed 'perfectly', whereas
  1032. if they went through either of the conversion algorithms, they'd be dithered.
  1033. Disadvantages: Often uses a lot of colors, which limits the ability to view
  1034. multiple images at once.  (See the '\fB\-slow24\fP' option above for 
  1035. further info about color sharing.)  (Resource name: noqcheck.  Type: boolean)
  1036. .PP
  1037. .SH ROOT WINDOW OPTIONS
  1038. \fIxv\fP has the ability to display images on the root window of an X display,
  1039. rather than opening its own window (the default behavior).  When using the
  1040. root window, the program is somewhat limited, because the program cannot
  1041. receive input events (key press and mouse clicks) from the root window.  As
  1042. a result, you cannot track pixel values, or crop, nor can you use keyboard 
  1043. commands while the mouse is in the root window.
  1044. .IP \fB\-root\fP 12
  1045. Directs \fIxv\fP to display images in the root window,
  1046. instead of opening its own window.  Images will be displayed in the upper left
  1047. corner of the screen, and will be repeated as many times as necessary to fill
  1048. the entire screen.  (Resource name: <none>)
  1049. .IP \fB\-tile\fP 12
  1050. Makes \fIxv\fP shrink images so that they fit on the screen
  1051. an integer number of times (in both directions).  The default behavior will
  1052. generally chop off the bottom and right sides of the images along the bottom
  1053. and right sides of the screen.  Disadvantage:  will slightly change the
  1054. aspect ratios of the images.  (Resource name:  tile.  Type: boolean)
  1055. .IP \fB\-center\fP 12
  1056. Forces \fIxv\fP to center the image in the root window.  If the image is 
  1057. smaller than the root window, the area around it will be determined by the
  1058. settings of \fB-rpat\fP, \fB-rfg\fP, and \fB-rbg\fP.  (See below.)  (Resource
  1059. name: centerPic.  Type: boolean)
  1060. .IP \fB\-rpat\fP 12
  1061. Specifies the pattern that will be used to fill the rest of the root window,
  1062. when \fB\-center\fP is in effect.  Currently, there are three different 
  1063. fill patterns.  '\fB\-rpat 0\fP' (the default) is just a solid background
  1064. color.  '\fB\-rpat 1\fP' adds radial lines to the solid 
  1065. background.  '\fB\-rpat 2\fP' is a brick pattern.  (Resource name: rootPattern.
  1066. Type: integer)
  1067. .IP \fB\-rfg\fP 12
  1068. Sets the 'foreground' color used in the various \fB-rpat\fP 
  1069. patterns.  (Resource name: rootForeground.  Type: string)
  1070. .IP \fB\-rbg\fP 12
  1071. Sets the 'background' color used in the various \fB-rpat\fP 
  1072. patterns.  (Resource name: rootBackground.  Type: string)
  1073. .IP \fB\-max\fP 12
  1074. Makes \fIxv\fP automatically stretch the image to the full
  1075. size of the screen.  This is mostly useful when you want \fIxv\fP to display a
  1076. background.  While you could just as well specify the dimensions of your
  1077. display (ie, '\fB\-geom\fP 1152x900' for example), the \fB\-max\fP option is
  1078. display-independent.  If you suddenly decide to start working on a 1280x1024
  1079. display (ferinstance) the same command will still work.  Note: If you 
  1080. specify '\fB\-max\fP' when you AREN'T using '\fB\-root\fP', 
  1081. the behavior is slightly 
  1082. different.  The image will be made as large as possible while still preserving
  1083. the normal aspect ratio.  (Resource name: <none>)
  1084. .IP \fB\-quit\fP 12
  1085. Makes \fIxv\fP display the (first) specified file and exit, 
  1086. without any user intervention.  Since images displayed on the root window 
  1087. remain there until explicitly cleared, this is very useful for having \fIxv\fP 
  1088. display background images on the root window in some sort of start-up script.
  1089. Needless to say, this is only useful if you are 
  1090. using '\fB\-root\fP'.  (Resource name:  <none>)
  1091. .IP \fB\-clear\fP 12
  1092. Clears the root window of any extraneous \fIxv\fP images.
  1093. While there are other ways of clearing the root window of an X display, such
  1094. as 'xsetroot', you must use the '\fB\-clear\fP' option to 
  1095. free up the other resources
  1096. allocated by \fIxv\fP, in particular, the colormap entries.  Note: it is not
  1097. necessary to do an 'xv -clear' before displaying another picture in the root
  1098. window.  \fIxv\fP will detect that there's an old \fIxv\fP image in the root
  1099. window and automatically clear it out (and free the associated colors).
  1100. (Resource name: <none>)
  1101. .PP
  1102. .SH WINDOW OPTIONS
  1103. \fIxv\fP currently consists of four main windows, plus one window for the
  1104. actual image.  Of those four, three of them (the CONTROL BOX, the INFO BOX,
  1105. and the GAMMA BOX) may be automatically mapped and positioned when the program
  1106. starts.
  1107. .IP \fB\-cmap\fP 12
  1108. Maps the CONTROL BOX.  (Resource name:  ctrlMap.  Type: boolean)
  1109. .IP \fB\-cgeom\fP 12
  1110. Sets the initial geometry of the CONTROL BOX.  Note:  only
  1111. the position information is used.  The CONTROL BOX is of fixed 
  1112. size.  (Resource name:  ctrlGeometry.  Type: string)
  1113. .IP \fB\-imap\fP 12
  1114. Maps the INFO BOX.  (Resource name:  infoMap.  Type: boolean)
  1115. .IP \fB\-igeom\fP 12
  1116. Sets the initial geometry of the INFO BOX.  Note:  only
  1117. the position information is used.  The INFO BOX is of fixed 
  1118. size.  (Resource name:  infoGeometry.  Type: string)
  1119. .IP \fB\-gmap\fP 12
  1120. Maps the GAMMA BOX.  (Resource name: gammaMap.  Type: boolean)
  1121. .IP \fB\-ggeom\fP 12
  1122. Sets the initial geometry of the GAMMA BOX.  Note:  only
  1123. the position information is used.  The GAMMA BOX is of fixed
  1124. size.  (Resource name:  gammaGeometry.  Type: string)
  1125. .PP
  1126. .SH MISCELLANEOUS OPTIONS
  1127. .IP \fB\-rv\fP 12
  1128. Reverses the colors of the image, so that white becomes
  1129. black and black becomes white.  This has 'interesting' effects on color 
  1130. images, however.  (For instance, red (255,0,0) becomes 
  1131. cyan (0,255,255))  (Resource name: reverseVideo.  Type: boolean)
  1132.  
  1133. .IP \fB\-mono\fP 12
  1134. Forces the image to be displayed as a grayscale.  This is
  1135. most useful when you are using certain grayscale X displays.  While \fIxv\fP
  1136. attempts to determine if it's running on a grayscale display, many X displays
  1137. \fIlie\fP, and claim to be able to do color.  (This is often because they 
  1138. have color
  1139. graphics boards hooked up to b/w monitors.  The computer, of course, has no
  1140. way of knowing what type of monitor is attached.)  On these displays, if you
  1141. don't specify '\fB\-mono\fP', what you will see is a grayscale 
  1142. representation of one
  1143. of the RGB outputs of the system.  (For example, you'll see the 'red' output
  1144. on our grayscale Sun 3/60s.)  The '\fB\-mono\fP' option corrects this behavior.
  1145. (Resource name: mono.  Type: boolean)
  1146. .IP \fB\-white\fP 12
  1147. Specifies the 'white' color used when the picture
  1148. is b/w stippled. (When '\fB\-ncols\fP 0' has been 
  1149. specified.)  (Resource name: white.  Type: string)
  1150. .IP \fB\-black\fP 12
  1151. Specifies the 'black' color used when the picture is
  1152. b/w stippled.  (When '\fB\-ncols\fP 0' has been specified.)  Try something
  1153. like 'xv -ncols 0 -bl red -wh yellow <filename>' for some interesting, 
  1154. late-'60s-style psychodelia effects.  (Resource name:  black.  Type: string)
  1155. .IP \fB\-GAMMA\fP 12
  1156. Sets up the default gamma-correction curve.
  1157. It can be used for contrast and/or brighness control.  The curve 
  1158. defines a transformation between input pixel intensity values (from the
  1159. picture) and output pixel intensity values (which get displayed).  The
  1160. curve is specified by four points in the range 0,0 <-> 255,255.  The points
  1161. must be in strict left-to-right order.  The first point is fixed at x=0.  The
  1162. last point is fixed at x=255.  The parameters to the '\fB\-GAMMA\fP' 
  1163. option are,
  1164. in order, the y-value of the first point, the x and y values of the second
  1165. point, the x and y values of the third point, and the y value of the last
  1166. point.  (These are the same numbers that appear above the gamma correction
  1167. curve in the GAMMA BOX (see below)).  (Resource name:  gamma. Type:  six
  1168. integers)
  1169. .IP
  1170. You can also specify default values for the 4 gamma 'presets' in the GAMMA
  1171. BOX.  The format is the same as above, and the resource names 
  1172. are 'gamma1', 'gamma2', 'gamma3', and 'gamma4'.
  1173. .IP \fB\-autogamma\fP 12
  1174. Tells \fIxv\fP to apply the 'default' gamma correction
  1175. (set by the '\fB\-GAMMA\fP' option or the 'gamma' resource) to the image
  1176. automatically, before the image is ever displayed.  (Resource
  1177. name: autoGamma.  Type: boolean)
  1178. .IP \fB\-fish\fP 12
  1179. Turns on some animated fish that are displayed whenever
  1180. \fIxv\fP is loading or resizing an image.  Note: This option may cause 'X
  1181. Protocal Errors' on slower X displays.  Use at your own risk.  (Resource name:
  1182. fish.  Type: boolean)
  1183. .IP \fB\-wait\fP 12
  1184. Turns on a 'slide-show' feature.  Normally, if you specify
  1185. multiple input files, \fIxv\fP will display the first one, and wait for you to
  1186. give the 'Next' command (or whatever).  The '\fB\-wait\fP' 
  1187. option makes \fIxv\fP wait
  1188. the specified number of seconds, and then go on to the next picture, without
  1189. any user intervention.  The program still accepts commands, so it's possible
  1190. to 'abort' the current picture without waiting the full specified time by
  1191. using the 'Next' command.  (Resource name: <none>)
  1192. .PP
  1193. .IP \fB\-bfc\fP 12
  1194. Toggles the 'color freeing behavior'.  If you experience X Protocol Errors 
  1195. when applying gamma corrections, or when loading multiple images, try 
  1196. using this option.  Normally, this option turns on some workarounds for
  1197. broken X servers, but if \fIxv\fP was built with the workarounds ON by
  1198. default, this option will turn them OFF.  (Resource name:  
  1199. brokeFreeCols.  Type: boolean)
  1200.  
  1201. .SH SHORTCUTS
  1202. Commands and their keyboard equivalents:
  1203. .in +0.5i
  1204. .ta 3in
  1205. .nf
  1206. Next Picture:    <SPACE>, <RETURN>
  1207. .br
  1208. Previous Picture:    <BS>, <DEL>
  1209. .br
  1210. Quit XV:    'q'
  1211. .br
  1212. Open/Close Control Box:    'h', '?', Right Mouse Button
  1213. .br
  1214. Open/Close Info Box:    'i'
  1215. .br
  1216. Open/Close Gamma Box:    'g'
  1217. .br
  1218. Open Save Box:    's'
  1219. .br
  1220. Aspect:    'a'
  1221. .br
  1222. Turn Right:    't'
  1223. .br
  1224. Turn Left:    'T'
  1225. .br
  1226. 4x3:    '4'
  1227. .br
  1228. Crop:    'c'
  1229. .br
  1230. Uncrop:    'u'
  1231. .br
  1232. AutoCrop:    'A'
  1233. .br
  1234. Normal:    'n'
  1235. .br
  1236. Max Size:    'm'
  1237. .br
  1238. Maxpect:    'M'
  1239. .br
  1240. Shrink 10%:    ','
  1241. .br
  1242. Grow 10%:    '.'
  1243. .br
  1244. Half Size:    '<'
  1245. .br
  1246. Double Size:    '>'
  1247. .br
  1248. Apply Gamma:    'p'
  1249. .ta
  1250. .in -0.5i
  1251. .fi
  1252. .PP
  1253. .SH LIMITATIONS
  1254. \fIxv\fP will NOT work on displays that aren't 1-, 4-, 6-, 8-, 24-, or 32-bits
  1255. deep.  Luckily, that should still cover nearly every display out there.  It
  1256. may not work on certain 6- or 24-bit displays.
  1257. .PP
  1258. It also only displays the first image in GIF files that have multiple 
  1259. images in them.
  1260. .PP
  1261. As for PM pictures, this program only displays 1-plane PM_I pictures, or
  1262. 1-, 3-, or 4-plane PM_C pictures.
  1263. .PP
  1264. .SH PM FORMAT
  1265. The PM format is a file format that we use at the GRASP Lab for our image-
  1266. processing work.  If you aren't at Penn, you are unlikely to ever run into 
  1267. a PM-format file, so don't worry about it.  Please ignore all references to PM.
  1268. .PP BUGS
  1269. The 4-, 6-, 24-, and 32-bit code has not been extensively 
  1270. tested.  (A 4-bit MicroVax GPX system, a 6-bit HP 9000/320, and a 
  1271. 24-bit HP 9000/350, respectively.  The 32-bit code hasn't actually been 
  1272. tested at all.)  
  1273. You won't be able to do '\fB\-ncols\fP 0' on a 6-, 24-, or 32-bit display, 
  1274. not that you should want to.
  1275. .SH AUTHOR
  1276. John Bradley  -  bradley@cis.upenn.edu
  1277. .PP
  1278. GIF reading code based on gif2ras.c, by Patrick J. Naughton 
  1279. (naughton@wind.sun.com)
  1280. .PP
  1281. GIF writing code essentially unchanged from code written 
  1282. by Michael Maudlin (mlm@cs.cmu.edu).
  1283.  
  1284. \BARFOO\
  1285. else
  1286.   echo "will not over write ./docs/xv.man"
  1287. fi
  1288. echo "Finished archive 2 of 10"
  1289. exit
  1290.  
  1291. dan
  1292. ----------------------------------------------------
  1293. O'Reilly && Associates   argv@sun.com / argv@ora.com
  1294. Opinions expressed reflect those of the author only.
  1295. --
  1296. dan
  1297. ----------------------------------------------------
  1298. O'Reilly && Associates   argv@sun.com / argv@ora.com
  1299. Opinions expressed reflect those of the author only.
  1300.