%N gidriv %F $MIR/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_science_miriad/miriad/work/miriad-4.3.8/borrow/pgplot/drivers/gidriv.f
%D PGPLOT GIF drivers
%B
      SUBROUTINE GIDRIV (IFUNC, RBUF, NBUF, CHR, LCHR, MODE)
      INTEGER IFUNC, NBUF, LCHR, MODE
      REAL    RBUF(*)
      CHARACTER*(*) CHR
*
* PGPLOT driver for Graphics Interchange Format (GIF) files.
*
************************************************************************
*                           CAUTION                                    *
*                                                                      *
* The GIF specification incorporates the Lempel-Zev-Welch (LZW)        *
* compression technology which is the subject of a patent awarded to   *
* Unisys. Use of this technology, and in particular creation of GIF    *
* format files using this PGPLOT device driver, may require a license  *
* from Unisys.                                                         *
************************************************************************
*
* Supported device: GIF87a file format
*
* Device type codes: /GIF or /VGIF
*
* Default device name: pgplot.gif.
*
* If you have more than one image to plot (i.e. use PGPAGE) with this
* device, subsequent pages will be named: pgplot2.gif, pgplot3.gif,
* etc, disrespective of the device name you specified.
* You can however bypass this by specifying a device name including a
* number sign (#), which will henceforth be replaced by the pagenumber.
* Example: page#.gif will produce files page1.gif, page2.gif, ...,
* page234.gif, etc.
*
* Default view surface dimensions are:
* - GIF  : 850 x 680 pixels (translates to 10.0 x  8.0 inch).
* - VGIF : 680 x 850 pixels (translates to  8.0 x 10.0 inch).
* with an assumed scale of 85 pixels/inch.
* Default width and height can be overridden by specifying environment
* variables
* PGPLOT_GIF_WIDTH  (default 850)
* PGPLOT_GIF_HEIGHT (default 680)
*
* Color capability:
* Indices 0 to 255 are supported. Each of these indices can be assigned
* one color. Default colors for indices 0 to 15 are implemented.
*
* Obtaining hardcopy: Use a GIF viewer or converter.
*=
*  1-Aug-1994 - Created by Remko Scharroo
*  9-Aug-1994 - New scheme for line plotting
* 16-Aug-1994 - Provide multi-image plotting.
*  8-Sep-1994 - Add opcode 29 [TJP].
*  5-Nov-1994 - Adjust size of bitmap if necessary [TJP].
* 18-Jan-1995 - Attempt to prevent integer overflow on systems where
*               BYTE is signed [TJP].
* 28-Dec-1995 - prevent concurrent access [TJP].
* 29-Apr-1996 - use GRCTOI to decode environment variables [TJP].
*  2-Sep-1997 - correct a byte overflow problem
*-----------------------------------------------------------------------
      CHARACTER*(*) LTYPE, PTYPE, DEFNAM
      INTEGER DWD, DHT, BX, BY
      PARAMETER (LTYPE=
     1'GIF   (Graphics Interchange Format file, landscape orientation)',
     2 PTYPE=
     3'VGIF  (Graphics Interchange Format file, portrait orientation)')
      PARAMETER (DEFNAM='pgplot.gif')
      PARAMETER (DWD=850, DHT=680)

      REAL XRES, YRES
      PARAMETER (XRES=85., YRES=XRES)

      INTEGER UNIT, IC, NPICT, MAXIDX, STATE
      INTEGER CTABLE(3,0:255), CDEFLT(3,0:15)
      INTEGER IER, I, L, LL, IX0, IY0, IX1, IY1, USERW, USERH, JUNK
      INTEGER GRGMEM, GRFMEM, GROFIL, GRCFIL, GRCTOI
      CHARACTER*80 MSG, INSTR, FILENM

 Note: for 64-bit operating systems, change the following 
 declaration to INTEGER*8:

      INTEGER*4 PIXMAP, WORK

      SAVE UNIT, IC, CTABLE, NPICT, MAXIDX, BX, BY, PIXMAP, FILENM
      SAVE CDEFLT, STATE
      DATA CDEFLT /000,000,000, 255,255,255, 255,000,000, 000,255,000,
     1             000,000,255, 000,255,255, 255,000,255, 255,255,000,
     2             255,128,000, 128,255,000, 000,255,128, 000,128,255,
     3             128,000,255, 255,000,128, 085,085,085, 170,170,170/
      DATA STATE /0/
