add Added Files:
[hdw-repos/packages.git] / demian / xv / 00-xv.patch
1 diff -uNr Makefile Makefile
2 --- Makefile    Mon Jan 23 21:20:54 1995
3 +++ Makefile    Tue Feb 20 17:48:33 2001
4 @@ -28,10 +28,10 @@
5  
6  
7  ### Installation locations
8 -BINDIR = /usr/local/bin
9 -MANDIR = /usr/local/man/man1
10 +BINDIR = /usr/bin
11 +MANDIR = /usr/man/man1
12  MANSUF = 1
13 -LIBDIR = /usr/local/lib
14 +LIBDIR = /usr/lib
15  
16  
17  buildit: all
18 @@ -45,26 +45,31 @@
19  ### if, for whatever reason, you're unable to get the JPEG library to compile
20  ### on your machine, *COMMENT OUT* the following lines
21  ###
22 -JPEG    = -DDOJPEG
23 -JPEGDIR = jpeg
24 -JPEGINC = -I$(JPEGDIR)
25 -JPEGLIB = $(JPEGDIR)/libjpeg.a
26 -$(JPEGDIR)/jconfig.h:
27 -       cd $(JPEGDIR) ; ./configure CC='$(CC)'
28 -$(JPEGLIB):  $(JPEGDIR)/jconfig.h
29 -       cd $(JPEGDIR) ; make
30 +JPEG    = -DDOJPEG
31 +JPEGLIB = -ljpeg
32 +
33 +
34 +###
35 +### if, for whatever reason, you're unable to get the PNG library to compile
36 +### on your machine, *COMMENT OUT* the following lines
37 +###
38 +PNG    = -DDOPNG
39 +PNGLIB = -lpng
40 +
41 +
42 +###
43 +### if, for whatever reason, you're unable to get the PNG library to compile
44 +### on your machine, *COMMENT OUT* the following lines
45 +###
46 +ZLIBLIB = -lz
47  
48  
49  ###
50  ### if, for whatever reason, you're unable to get the TIFF library to compile
51  ### on your machine, *COMMENT OUT* the following lines
52  ###
53 -TIFF    = -DDOTIFF
54 -TIFFDIR = tiff
55 -TIFFINC = -I$(TIFFDIR)
56 -TIFFLIB = $(TIFFDIR)/libtiff.a
57 -$(TIFFLIB):
58 -       ( cd $(TIFFDIR) ; make CC='$(CC)' )
59 +TIFF    = -DDOTIFF
60 +TIFFLIB = -ltiff
61  
62  
63  ###
64 @@ -184,11 +189,11 @@
65  
66  
67  
68 -CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
69 +CFLAGS = $(CCOPTS) $(JPEG) $(TIFF) $(PDS) \
70         $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
71 -       $(DXWM) $(MCHN)
72 +       $(DXWM) $(MCHN) $(PNG)
73  
74 -LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
75 +LIBS = -lX11 -L/usr/X11/lib $(JPEGLIB) $(TIFFLIB) $(PNGLIB) $(ZLIBLIB) -lm
76  
77  OBJS =         xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \
78         xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \
79 @@ -196,7 +201,7 @@
80         xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \
81         xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \
82         xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \
83 -       xvxwd.o xvfits.o
84 +       xvxwd.o xvfits.o xvpng.o
85  
86  MISC = README INSTALL CHANGELOG IDEAS
87  
88 @@ -206,10 +211,10 @@
89  
90  
91  
92 -all: $(JPEGLIB) $(TIFFLIB) xv bggen vdcomp xcmap xvpictoppm
93 +all: xv bggen vdcomp xcmap xvpictoppm
94  
95  
96 -xv: $(OBJS) $(JPEGLIB) $(TIFFLIB)
97 +xv: $(OBJS)
98         $(CC) -o xv $(CFLAGS) $(OBJS) $(LIBS)
99  
100  bggen: bggen.c
101 @@ -267,7 +272,7 @@
102  xvbrowse.o:    bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds 
103  xvbrowse.o:    bits/br_ps bits/br_iff bits/br_targa bits/br_xpm
104  xvbrowse.o:    bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm
105 -xvbrowse.o:     bits/br_xwd
106 +xvbrowse.o:     bits/br_xwd bits/br_png
107  
108  xvbutt.o:      bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top
109  xvbutt.o:      bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body
110 diff -uNr Makefile.std Makefile.std
111 --- Makefile.std        Tue Jan 24 02:06:26 1995
112 +++ Makefile.std        Tue Feb 20 17:04:44 2001
113 @@ -56,6 +56,25 @@
114  
115  
116  ###
117 +### if, for whatever reason, you're unable to get the PNG library to compile
118 +### on your machine, *COMMENT OUT* the following lines
119 +###
120 +PNG    = -DDOPNG
121 +PNGDIR = /usr/local/src/libpng
122 +PNGINC = -I$(PNGDIR)
123 +PNGLIB = -L$(PNGDIR) -lpng
124 +
125 +
126 +###
127 +### if, for whatever reason, you're unable to get the PNG library to compile
128 +### on your machine, *COMMENT OUT* the following lines
129 +###
130 +ZLIBDIR = /usr/local/src/zlib
131 +ZLIBINC = -I$(ZLIBDIR)
132 +ZLIBLIB = -L$(ZLIBDIR) -lz
133 +
134 +
135 +###
136  ### if, for whatever reason, you're unable to get the TIFF library to compile
137  ### on your machine, *COMMENT OUT* the following lines
138  ###
139 @@ -186,9 +205,9 @@
140  
141  CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
142         $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
143 -       $(DXWM) $(MCHN)
144 +       $(DXWM) $(MCHN) $(PNG) $(PNGINC) $(ZLIBINC)
145  
146 -LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
147 +LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) $(PNGLIB) $(ZLIBLIB) -lm
148  
149  OBJS =         xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \
150         xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \
151 @@ -196,7 +215,7 @@
152         xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \
153         xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \
154         xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \
155 -       xvxwd.o xvfits.o
156 +       xvxwd.o xvfits.o xvpng.o
157  
158  MISC = README INSTALL CHANGELOG IDEAS
159  
160 @@ -267,7 +286,7 @@
161  xvbrowse.o:    bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds 
162  xvbrowse.o:    bits/br_ps bits/br_iff bits/br_targa bits/br_xpm
163  xvbrowse.o:    bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm
164 -xvbrowse.o:     bits/br_xwd
165 +xvbrowse.o:     bits/br_xwd bits/br_png
166  
167  xvbutt.o:      bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top
168  xvbutt.o:      bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body
169 diff -uNr bits/br_png bits/br_png
170 --- bits/br_png Thu Jan  1 01:00:00 1970
171 +++ bits/br_png Thu Jun 13 23:32:08 1996
172 @@ -0,0 +1,28 @@
173 +#define br_png_width 48
174 +#define br_png_height 48
175 +static unsigned char br_png_bits[] = {
176 +  0xe0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x03, 0x00,
177 +  0x20, 0x00, 0x00, 0x00, 0x05, 0x00, 0x20, 0x00, 0x00, 0x00, 0x09, 0x00,
178 +  0x20, 0x00, 0x00, 0x00, 0x11, 0x00, 0x20, 0x00, 0x00, 0x00, 0x21, 0x00,
179 +  0x20, 0x00, 0x00, 0x00, 0x41, 0x00, 0x20, 0x00, 0x00, 0x00, 0x81, 0x00,
180 +  0x20, 0x00, 0x00, 0x00, 0x01, 0x01, 0x20, 0x00, 0x00, 0x00, 0xff, 0x03,
181 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
182 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
183 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
184 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
185 +  0x20, 0xf8, 0x19, 0xc3, 0x07, 0x02, 0x20, 0x18, 0x3b, 0x63, 0x0c, 0x02,
186 +  0x20, 0x18, 0x3b, 0x33, 0x00, 0x02, 0x20, 0x18, 0x5b, 0x33, 0x00, 0x02,
187 +  0x20, 0xf8, 0x59, 0x33, 0x0f, 0x02, 0x20, 0x18, 0x98, 0x33, 0x0c, 0x02,
188 +  0x20, 0x18, 0x98, 0x33, 0x0c, 0x02, 0x20, 0x18, 0x18, 0x63, 0x0c, 0x02,
189 +  0x20, 0x18, 0x18, 0xc3, 0x0b, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
190 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
191 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
192 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
193 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
194 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
195 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
196 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
197 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
198 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
199 +  0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03,
200 +  };
201 diff -uNr config.h config.h
202 --- config.h    Thu Jan  5 19:49:21 1995
203 +++ config.h    Tue Feb 20 17:07:25 2001
204 @@ -13,13 +13,13 @@
205   * definition appropriately. (use 'which gunzip' to find if you have gunzip, 
206   * and where it lives)
207   */
208 -#undef USE_GUNZIP
209 +#define USE_GUNZIP
210  
211  #ifdef USE_GUNZIP
212  #  ifdef VMS
213  #    define GUNZIP "UNCOMPRESS"
214  #  else
215 -#    define GUNZIP "/usr/local/bin/gunzip -q"
216 +#    define GUNZIP "/bin/gunzip -q"
217  #  endif
218  #endif
219  
220 @@ -88,9 +88,9 @@
221   * should not need to be changed
222   */
223  
224 -/* #define GS_PATH "/usr/local/bin/gs" */
225 -/* #define GS_LIB  "."                 */
226 -/* #define GS_DEV  "ppmraw"            */
227 +#define GS_PATH "/usr/bin/gs"
228 +#define GS_LIB  "."
229 +#define GS_DEV  "ppmraw"
230  
231  
232  /***************************************************************************
233 diff -uNr xcmap.c xcmap.c
234 --- xcmap.c     Tue Jan  3 22:14:52 1995
235 +++ xcmap.c     Tue Feb 20 17:04:13 2001
236 @@ -140,8 +140,13 @@
237      nxcells = nycells = 8;
238    else if (dispcells>4)
239      nxcells = nycells = 4;
240 -  else
241 +  else if (dispcells>2)
242      nxcells = nycells = 2;
243 +  else
244 +  {
245 +    nxcells = 2;
246 +    nycells = 1;
247 +  }
248    
249    /**************** Create/Open X Resources ***************/
250    if ((mfinfo = XLoadQueryFont(theDisp,FONT))==NULL) {
251 @@ -267,18 +272,25 @@
252    
253    x=y=w=h=1;
254    i=XParseGeometry(geom,&x,&y,&w,&h);
255 -  if (i&WidthValue)  WIDE = (int) w;
256 -  if (i&HeightValue) HIGH = (int) h;
257 -  
258 -  if (i&XValue || i&YValue) hints.flags = USPosition;  
259 -  else hints.flags = PPosition;
260 -  
261 -  hints.flags |= USSize;
262 -  
263 -  if (i&XValue && i&XNegative) 
264 -    x = XDisplayWidth(theDisp,theScreen)-WIDE-abs(x);
265 -  if (i&YValue && i&YNegative) 
266 -    y = XDisplayHeight(theDisp,theScreen)-HIGH-abs(y);
267 +  if (i&WidthValue)
268 +  {
269 +    WIDE = (int) w;
270 +    hints.flags |= USSize;
271 +  }
272 +  if (i&HeightValue)
273 +  {
274 +    HIGH = (int) h;
275 +    hints.flags |= USSize;
276 +  }
277 +  
278 +  if (i&XValue || i&YValue)
279 +  {
280 +    if (i&XNegative) 
281 +      x = XDisplayWidth(theDisp,theScreen)-WIDE-abs(x);
282 +    if (i&YNegative) 
283 +      y = XDisplayHeight(theDisp,theScreen)-HIGH-abs(y);
284 +    hints.flags |= USPosition;  
285 +  }
286    
287    hints.x=x;             hints.y=y;
288    hints.width  = WIDE;   hints.height = HIGH;
289 diff -uNr xv.c xv.c
290 --- xv.c        Thu Jan 19 19:08:43 1995
291 +++ xv.c        Tue Feb 20 17:04:44 2001
292 @@ -277,6 +277,10 @@
293    tiffW = (Window) NULL;  tiffUp = 0;
294  #endif
295  
296 +#ifdef HAVE_PNG
297 +  pngW = (Window) NULL;  pngUp = 0;
298 +#endif
299 +
300    imap = ctrlmap = gmap = browmap = cmtmap = 0;
301  
302    ch_offx = ch_offy = p_offx = p_offy = 0;
303 @@ -782,6 +786,10 @@
304    XSetTransientForHint(theDisp, tiffW, dirW);
305  #endif
306    
307 +#ifdef HAVE_PNG
308 +  CreatePNGW();
309 +  XSetTransientForHint(theDisp, pngW, dirW);
310 +#endif
311    
312    LoadFishCursors();
313    SetCursors(-1);
314 @@ -2611,6 +2619,11 @@
315            (magicno[0]=='I' && magicno[1]=='I'))        rv = RFT_TIFF;
316  #endif
317  
318 +#ifdef HAVE_PNG
319 +  else if (magicno[0]==0x89 && magicno[1]=='P' &&
320 +           magicno[2]=='N'  && magicno[3]=='G')                  rv = RFT_PNG;
321 +#endif
322 +
323  #ifdef HAVE_PDS
324    else if (strncmp((char *) magicno,  "NJPL1I00", (size_t) 8)==0 ||
325            strncmp((char *) magicno+2,"NJPL1I",   (size_t) 6)==0 ||
326 @@ -2669,6 +2682,10 @@
327  
328  #ifdef HAVE_TIFF
329    case RFT_TIFF:    rv = LoadTIFF  (fname, pinfo);           break;
330 +#endif
331 +
332 +#ifdef HAVE_PNG
333 +  case RFT_PNG:     rv = LoadPNG   (fname, pinfo);         break;
334  #endif
335  
336  #ifdef HAVE_PDS
337 diff -uNr xv.h xv.h
338 --- ./xv.h      Mon Jan 23 21:22:23 1995
339 +++ ./xv.h      Tue Feb 20 17:10:11 2001
340 @@ -8,8 +8,8 @@
341  #include "config.h"
342  
343  
344 -#define REVDATE   "Version 3.10a  Rev: 12/29/94"
345 -#define VERSTR    "3.10a"
346 +#define REVDATE   "Version 3.10a  Rev: 12/29/94 (PNG patch 1.2)"
347 +#define VERSTR    "3.10a(PNG)"
348  
349  /*
350   * uncomment the following, and modify for your site, but only if you've
351 @@ -116,7 +116,7 @@
352  #  include <errno.h>
353     extern int   errno;             /* SHOULD be in errno.h, but often isn't */
354  #  ifndef __NetBSD__
355 -     extern char *sys_errlist[];     /* this too... */
356 +//     extern char *sys_errlist[];     /* this too... */
357  #  endif
358  #endif
359  
360 @@ -327,6 +327,10 @@
361  #define HAVE_TIFF
362  #endif
363  
364 +#ifdef DOPNG
365 +#define HAVE_PNG
366 +#endif
367 +
368  #ifdef DOPDS
369  #define HAVE_PDS
370  #endif
371 @@ -458,24 +462,31 @@
372  #define F_TIFINC  0
373  #endif
374  
375 +#ifdef HAVE_PNG
376 +#define F_PNGINC  1
377 +#else
378 +#define F_PNGINC  0
379 +#endif
380 +
381  
382  #define F_GIF         0
383  #define F_JPEG      ( 0 + F_JPGINC)
384  #define F_TIFF      ( 0 + F_JPGINC + F_TIFINC)
385 -#define F_PS        ( 1 + F_JPGINC + F_TIFINC)
386 -#define F_PBMRAW    ( 2 + F_JPGINC + F_TIFINC)
387 -#define F_PBMASCII  ( 3 + F_JPGINC + F_TIFINC)
388 -#define F_XBM       ( 4 + F_JPGINC + F_TIFINC)
389 -#define F_XPM       ( 5 + F_JPGINC + F_TIFINC)
390 -#define F_BMP       ( 6 + F_JPGINC + F_TIFINC)
391 -#define F_SUNRAS    ( 7 + F_JPGINC + F_TIFINC)
392 -#define F_IRIS      ( 8 + F_JPGINC + F_TIFINC)
393 -#define F_TARGA     ( 9 + F_JPGINC + F_TIFINC)
394 -#define F_FITS      (10 + F_JPGINC + F_TIFINC)
395 -#define F_PM        (11 + F_JPGINC + F_TIFINC)
396 -#define F_DELIM1    (12 + F_JPGINC + F_TIFINC)     /* ----- */
397 -#define F_FILELIST  (13 + F_JPGINC + F_TIFINC)
398 -#define F_MAXFMTS   (14 + F_JPGINC + F_TIFINC)     /* 15, normally */
399 +#define F_PNG       ( 0 + F_JPGINC + F_TIFINC + F_PNGINC)
400 +#define F_PS        ( 1 + F_JPGINC + F_TIFINC + F_PNGINC)
401 +#define F_PBMRAW    ( 2 + F_JPGINC + F_TIFINC + F_PNGINC)
402 +#define F_PBMASCII  ( 3 + F_JPGINC + F_TIFINC + F_PNGINC)
403 +#define F_XBM       ( 4 + F_JPGINC + F_TIFINC + F_PNGINC)
404 +#define F_XPM       ( 5 + F_JPGINC + F_TIFINC + F_PNGINC)
405 +#define F_BMP       ( 6 + F_JPGINC + F_TIFINC + F_PNGINC)
406 +#define F_SUNRAS    ( 7 + F_JPGINC + F_TIFINC + F_PNGINC)
407 +#define F_IRIS      ( 8 + F_JPGINC + F_TIFINC + F_PNGINC)
408 +#define F_TARGA     ( 9 + F_JPGINC + F_TIFINC + F_PNGINC)
409 +#define F_FITS      (10 + F_JPGINC + F_TIFINC + F_PNGINC)
410 +#define F_PM        (11 + F_JPGINC + F_TIFINC + F_PNGINC)
411 +#define F_DELIM1    (12 + F_JPGINC + F_TIFINC + F_PNGINC)   /* ----- */
412 +#define F_FILELIST  (13 + F_JPGINC + F_TIFINC + F_PNGINC)
413 +#define F_MAXFMTS   (14 + F_JPGINC + F_TIFINC + F_PNGINC)   /* 17, normally */
414  
415  
416  
417 @@ -505,6 +516,7 @@
418  #define RFT_XPM      17
419  #define RFT_XWD      18
420  #define RFT_FITS     19
421 +#define RFT_PNG      20
422  
423  /* definitions for page up/down, arrow up/down list control */
424  #define LS_PAGEUP   0
425 @@ -765,9 +777,10 @@
426  typedef struct { Window win;            /* window ID */
427                  int x,y,w,h;           /* window coords in parent */
428                  int active;            /* true if can do anything*/
429 -                int min,max;           /* min/max values 'pos' can take */
430 -                int val;               /* 'value' of dial */
431 -                int page;              /* amt val change on pageup/pagedown */
432 +                double min,max;        /* min/max values 'pos' can take */
433 +                double val;            /* 'value' of dial */
434 +                double inc;            /* amt val change on up/down */
435 +                double page;           /* amt val change on pageup/pagedown */
436                  char *title;           /* title for this guage */
437                  char *units;           /* string appended to value */
438                  u_long fg,bg,hi,lo;    /* colors */
439 @@ -1154,6 +1167,13 @@
440  #endif
441  
442  
443 +#ifdef HAVE_PNG
444 +/* stuff used for 'png' box */
445 +WHERE Window        pngW;
446 +WHERE int           pngUp;        /* is pngW mapped, or what? */
447 +#endif
448 +
449 +
450  #undef WHERE
451  
452  
453 @@ -1465,12 +1485,12 @@
454  
455  
456  /*************************** XVDIAL.C ***************************/
457 -void DCreate               PARM((DIAL *, Window, int, int, int, int, int, 
458 -                                int, int, int, u_long, u_long, u_long, 
459 -                                u_long, char *, char *));
460 +void DCreate               PARM((DIAL *, Window, int, int, int, int, double,
461 +                                 double, double, double, double, u_long,
462 +                                 u_long, u_long, u_long, char *, char *));
463  
464 -void DSetRange             PARM((DIAL *, int, int, int, int));
465 -void DSetVal               PARM((DIAL *, int));
466 +void DSetRange             PARM((DIAL *, double,double,double,double,double));
467 +void DSetVal               PARM((DIAL *, double));
468  void DSetActive            PARM((DIAL *, int));
469  void DRedraw               PARM((DIAL *));
470  int  DTrack                PARM((DIAL *, int, int));
471 @@ -1612,6 +1632,13 @@
472  void  TIFFDialog           PARM((int));
473  int   TIFFCheckEvent       PARM((XEvent *));
474  void  TIFFSaveParams       PARM((char *, int));
475 +
476 +/**************************** XVPNG.C ***************************/
477 +int  LoadPNG               PARM((char *, PICINFO *));
478 +void CreatePNGW            PARM((void));
479 +void PNGDialog             PARM((int));
480 +int  PNGCheckEvent         PARM((XEvent *));
481 +void PNGSaveParams         PARM((char *, int));
482  
483  /**************************** XVPDS.C ***************************/
484  int LoadPDS                PARM((char *, PICINFO *));
485 diff -uNr xvbrowse.c xvbrowse.c
486 --- ./xvbrowse.c        Thu Jan 19 18:49:17 1995
487 +++ ./xvbrowse.c        Tue Feb 20 17:04:44 2001
488 @@ -55,6 +55,7 @@
489  #include "bits/br_xpm"
490  #include "bits/br_xwd"
491  #include "bits/br_fits"
492 +#include "bits/br_png"
493  
494  #include "bits/br_trash"
495  #include "bits/fcurs"
496 @@ -94,7 +95,8 @@
497  #define BF_XPM      25
498  #define BF_XWD      26
499  #define BF_FITS     27
500 -#define BF_MAX      28    /* # of built-in icons */
501 +#define BF_PNG      28
502 +#define BF_MAX      29    /* # of built-in icons */
503  
504  #define ISLOADABLE(ftyp) (ftyp!=BF_DIR  && ftyp!=BF_CHR && ftyp!=BF_BLK && \
505                           ftyp!=BF_SOCK && ftyp!=BF_FIFO) 
506 @@ -524,6 +526,7 @@
507    bfIcons[BF_XPM] =MakePix1(br->win,br_xpm_bits, br_xpm_width, br_xpm_height);
508    bfIcons[BF_XWD] =MakePix1(br->win,br_xwd_bits, br_xwd_width, br_xwd_height);
509    bfIcons[BF_FITS]=MakePix1(br->win,br_fits_bits,br_fits_width,br_fits_height);
510 +  bfIcons[BF_PNG]=MakePix1(br->win,br_png_bits,br_png_width,br_png_height);
511  
512  
513    /* check that they all got built */
514 @@ -3020,6 +3023,7 @@
515      case RFT_XPM:      bf->ftype = BF_XPM;      break;
516      case RFT_XWD:      bf->ftype = BF_XWD;      break;
517      case RFT_FITS:     bf->ftype = BF_FITS;     break;
518 +    case RFT_PNG:      bf->ftype = BF_PNG;      break;
519      }
520    }
521  }
522 @@ -3567,6 +3571,7 @@
523    case RFT_XPM:      strcat(str,"XPM file");              break;
524    case RFT_XWD:      strcat(str,"XWD file");              break;
525    case RFT_FITS:     strcat(str,"FITS file");             break;
526 +  case RFT_PNG:      strcat(str,"PNG file");              break;
527    default:           strcat(str,"file of unknown type");  break;
528    }
529    
530 diff -uNr xvdial.c xvdial.c
531 --- ./xvdial.c  Tue Jan  3 22:20:31 1995
532 +++ ./xvdial.c  Tue Feb 20 17:04:44 2001
533 @@ -41,20 +41,21 @@
534  
535  
536  /* local functions */
537 -static int  whereInDial     PARM((DIAL *, int, int));
538 -static void drawArrow       PARM((DIAL *));
539 -static void drawValStr      PARM((DIAL *));
540 -static void drawButt        PARM((DIAL *, int, int));
541 -static int  computeDialVal  PARM((DIAL *, int, int));
542 -static void dimDial         PARM((DIAL *));
543 +static int    whereInDial     PARM((DIAL *, int, int));
544 +static void   drawArrow       PARM((DIAL *));
545 +static void   drawValStr      PARM((DIAL *));
546 +static void   drawButt        PARM((DIAL *, int, int));
547 +static double computeDialVal  PARM((DIAL *, int, int));
548 +static void   dimDial         PARM((DIAL *));
549  
550  
551  /***************************************************/
552 -void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, page, 
553 +void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, inc, page, 
554                   fg, bg, hi, lo, title, units)
555  DIAL         *dp;
556  Window        parent;
557 -int           x,y,w,h,minv,maxv,curv,page;
558 +int           x,y,w,h;
559 +double        minv,maxv,curv,inc,page;
560  unsigned long fg,bg,hi,lo;
561  char         *title, *units;
562  {
563 @@ -98,18 +99,18 @@
564                                 1,fg,bg);
565    if (!dp->win) FatalError("can't create dial window");
566  
567 -  DSetRange(dp, minv, maxv, curv, page);
568 +  DSetRange(dp, minv, maxv, curv, inc, page);
569    XSelectInput(theDisp, dp->win, ExposureMask | ButtonPressMask);
570  }
571  
572  
573  /***************************************************/
574 -void DSetRange(dp, minv, maxv, curv, page)
575 -DIAL *dp;
576 -int   minv, maxv, curv, page;
577 +void DSetRange(dp, minv, maxv, curv, inc, page)
578 +DIAL   *dp;
579 +double  minv, maxv, curv, inc, page;
580  {
581    if (maxv<minv) maxv=minv;
582 -  dp->min = minv;    dp->max = maxv;    dp->page = page;
583 +  dp->min = minv; dp->max = maxv; dp->inc = inc; dp->page = page;
584    dp->active =  (minv < maxv);
585  
586    DSetVal(dp, curv);
587 @@ -118,8 +119,8 @@
588  
589  /***************************************************/
590  void DSetVal(dp, curv)
591 -DIAL *dp;
592 -int   curv;
593 +DIAL  *dp;
594 +double curv;
595  {
596    RANGE(curv, dp->min, dp->max);   /* make sure curv is in-range */
597  
598 @@ -129,7 +130,7 @@
599    XSetForeground(theDisp, theGC, dp->bg); 
600    drawArrow(dp);
601  
602 -  dp->val = curv;
603 +  dp->val = (double)((int)(curv / dp->inc + (curv > 0 ? 0.5 : -0.5))) * dp->inc;
604  
605    /* draw new arrow and string */
606    XSetForeground(theDisp, theGC, dp->fg);
607 @@ -202,7 +203,8 @@
608  int mx,my;
609  {
610    Window       rW,cW;
611 -  int          rx,ry, x,y, ipos, pos, lit, i, origval;
612 +  int          rx, ry, x, y, ipos, pos, lit;
613 +  double       origval;
614    unsigned int mask;
615  
616    lit = 0;
617 @@ -224,9 +226,9 @@
618    if (ipos != INDIAL) {
619      drawButt(dp, ipos, 1);
620      switch (ipos) {
621 -    case INCW1:  if (dp->val < dp->max) DSetVal(dp, dp->val+1); break;
622 +    case INCW1:  if (dp->val < dp->max) DSetVal(dp, dp->val+dp->inc);  break;
623      case INCW2:  if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page); break;
624 -    case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-1); break;
625 +    case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->inc);  break;
626      case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page); break;
627      }
628      if (dp->drawobj != NULL) (dp->drawobj)();  
629 @@ -235,8 +237,9 @@
630    }
631  
632    else { 
633 -    i = computeDialVal(dp, mx, my);
634 -    DSetVal(dp, i);
635 +    double v;
636 +    v = computeDialVal(dp, mx, my);
637 +    DSetVal(dp, v);
638      if (dp->drawobj != NULL) (dp->drawobj)();  
639    }
640  
641 @@ -246,11 +249,11 @@
642      if (!(mask & Button1Mask)) break;    /* button released */
643  
644      if (ipos == INDIAL) {
645 -      int j;
646 -      i = computeDialVal(dp, x, y);
647 -      j = dp->val;
648 -      DSetVal(dp, i);
649 -      if (j != dp->val) {
650 +      double v, w;
651 +      v = computeDialVal(dp, x, y);
652 +      w = dp->val;
653 +      DSetVal(dp, v);
654 +      if (w != dp->val) {
655         /* track whatever dial controls */
656         if (dp->drawobj != NULL) (dp->drawobj)();  
657        }
658 @@ -266,11 +269,11 @@
659  
660        if (lit) {
661         switch (ipos) {
662 -       case INCW1:  if (dp->val < dp->max) DSetVal(dp, dp->val+1); 
663 +       case INCW1:  if (dp->val < dp->max) DSetVal(dp, dp->val+dp->inc); 
664                      break;
665         case INCW2:  if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page);
666                       break;
667 -       case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-1);
668 +       case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->inc);
669                       break;
670         case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page);
671                       break;
672 @@ -320,19 +323,20 @@
673  static void drawArrow(dp)
674  DIAL *dp;
675  {
676 -  int i, rad, cx, cy;
677 +  int rad, cx, cy;
678 +  double v;
679    XPoint arrow[4];
680  
681    rad = dp->rad;  cx = dp->cx;  cy = dp->cy;
682  
683    /* map pos (range minv..maxv) into degrees (range 240..-60) */
684 -  i = 240 + (-300 * (dp->val - dp->min)) / (dp->max - dp->min);
685 -  arrow[0].x = cx + (int) ((double) rad * .80 * cos(i * DEG2RAD));
686 -  arrow[0].y = cy - (int) ((double) rad * .80 * sin(i * DEG2RAD));
687 -  arrow[1].x = cx + (int) ((double) rad * .33 * cos((i+160) * DEG2RAD));
688 -  arrow[1].y = cy - (int) ((double) rad * .33 * sin((i+160) * DEG2RAD));
689 -  arrow[2].x = cx + (int) ((double) rad * .33 * cos((i-160) * DEG2RAD));
690 -  arrow[2].y = cy - (int) ((double) rad * .33 * sin((i-160) * DEG2RAD));
691 +  v = 240 + (-300 * (dp->val - dp->min)) / (dp->max - dp->min);
692 +  arrow[0].x = cx + (int) ((double) rad * .80 * cos(v * DEG2RAD));
693 +  arrow[0].y = cy - (int) ((double) rad * .80 * sin(v * DEG2RAD));
694 +  arrow[1].x = cx + (int) ((double) rad * .33 * cos((v+160) * DEG2RAD));
695 +  arrow[1].y = cy - (int) ((double) rad * .33 * sin((v+160) * DEG2RAD));
696 +  arrow[2].x = cx + (int) ((double) rad * .33 * cos((v-160) * DEG2RAD));
697 +  arrow[2].y = cy - (int) ((double) rad * .33 * sin((v-160) * DEG2RAD));
698    arrow[3].x = arrow[0].x;
699    arrow[3].y = arrow[0].y;
700    XDrawLines(theDisp, dp->win, theGC, arrow, 4, CoordModeOrigin);
701 @@ -343,23 +347,37 @@
702  static void drawValStr(dp)
703  DIAL *dp;
704  {
705 -  int  i, x1, x2;
706 +  int  tot, i, x1, x2;
707    char foo[60], foo1[60];
708  
709    /* compute longest string necessary so we can right-align this thing */
710 -  sprintf(foo,"%d",dp->min);    x1 = strlen(foo);
711 -  sprintf(foo,"%d",dp->max);    x2 = strlen(foo);
712 +  sprintf(foo,"%d",(int)dp->min);    x1 = strlen(foo);
713 +  sprintf(foo,"%d",(int)dp->max);    x2 = strlen(foo);
714    if (dp->min < 0 && dp->max > 0) x2++;   /* put '+' at beginning */
715    i = x1;  if (x2>x1) i = x2;
716    if (dp->units) i += strlen(dp->units);
717  
718 -  if (dp->min < 0 && dp->max > 0) sprintf(foo,"%+d", dp->val);
719 -  else sprintf(foo,"%d", dp->val);
720 +  sprintf(foo,"%g",dp->inc);   /* space for decimal values */
721 +  tot = i + strlen(foo) - 1;   /* Take away the 0 from the beginning */
722 +
723 +  if (dp->min < 0.0 && dp->max > 0.0) sprintf(foo,"%+g", dp->val);
724 +  else sprintf(foo,"%g", dp->val);
725 +
726 +  if (dp->inc < 1.0)
727 +  {
728 +    int j;
729 +
730 +    if (dp->val == (double)((int)dp->val))
731 +      strcat(foo,".");
732 +
733 +    for (j = strlen(foo); j < tot; j++)
734 +      strcat(foo,"0");
735 +  }
736  
737    if (dp->units) strcat(foo,dp->units);
738    foo1[0] = '\0';
739    if (strlen(foo) < (size_t) i) {
740 -    for (i = i - strlen(foo); i>0; i--) strcat(foo1," ");
741 +    for (i-=strlen(foo);i>0;i--) strcat(foo1," ");
742    }
743    strcat(foo1, foo);
744  
745 @@ -411,12 +429,13 @@
746  
747  
748  /***************************************************/
749 -static int computeDialVal(dp, x, y)
750 +static double computeDialVal(dp, x, y)
751  DIAL *dp;
752  int x, y;
753  {
754 -  int dx, dy, val;
755 -  double angle;
756 +  int dx, dy;
757
758 +  double angle, val;
759  
760    /* compute dx, dy (distance from cx, cy).  Note: +dy is *up* */
761    dx = x - dp->cx;  dy = dp->cy - y;
762 @@ -436,8 +455,10 @@
763    if (angle > 270.0) angle -= 360.0;
764    if (angle < -90.0) angle += 360.0;
765  
766 -  val = (int) ((dp->max - dp->min) * (240.0 - angle) / 300.0) + dp->min;
767 +  val = ((dp->max - dp->min) * (240.0 - angle) / 300.0) + dp->min;
768  
769 +  /* round value to be an even multiple of dp->inc */
770 +  val = (double)((int)(val / dp->inc + 0.5)) * dp->inc;
771    return val;
772  }
773  
774 diff -uNr xvdir.c xvdir.c
775 --- ./xvdir.c   Tue Jan  3 22:21:39 1995
776 +++ ./xvdir.c   Tue Feb 20 17:04:44 2001
777 @@ -62,6 +62,9 @@
778  #ifdef HAVE_TIFF
779                                "TIFF",
780  #endif
781 +#ifdef HAVE_PNG
782 +                              "PNG",
783 +#endif
784                                "PostScript",
785                                "PBM/PGM/PPM (raw)",
786                                "PBM/PGM/PPM (ascii)",
787 @@ -1115,6 +1118,15 @@
788    }
789  #endif
790  
791 +#ifdef HAVE_PNG
792 +  else if (fmt == F_PNG) {   /* PNG */
793 +    PNGSaveParams(fullname, col);
794 +    PNGDialog(1);                   /* open PNG Dialog box */
795 +    dbut[S_BOK].lit = 0;  BTRedraw(&dbut[S_BOK]);
796 +    return 0;                      /* always 'succeeds' */
797 +  }
798 +#endif
799 +
800  
801  
802  
803 @@ -1168,7 +1180,8 @@
804      
805    case F_XPM:
806      rv = WriteXPM   (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, 
807 -                    fullname, picComments);    
808 +                    fullname, picComments);
809 +    break;
810    case F_FITS:
811      rv = WriteFITS  (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, 
812                      picComments);    
813 @@ -1380,14 +1393,21 @@
814        (strcmp(lowsuf,"eps" )==0) ||
815        (strcmp(lowsuf,"rgb" )==0) ||
816        (strcmp(lowsuf,"tga" )==0) ||
817 -      (strcmp(lowsuf,"xpm" )==0) ||
818        (strcmp(lowsuf,"fits")==0) ||
819        (strcmp(lowsuf,"fts" )==0) ||
820 +#ifdef HAVE_JPEG
821        (strcmp(lowsuf,"jpg" )==0) ||
822        (strcmp(lowsuf,"jpeg")==0) ||
823        (strcmp(lowsuf,"jfif")==0) ||
824 +#endif
825 +#ifdef HAVE_TIFF
826        (strcmp(lowsuf,"tif" )==0) ||
827 -      (strcmp(lowsuf,"tiff")==0)) {
828 +      (strcmp(lowsuf,"tiff")==0) ||
829 +#endif
830 +#ifdef HAVE_PNG
831 +      (strcmp(lowsuf,"png" )==0) ||
832 +#endif
833 +      (strcmp(lowsuf,"xpm" )==0)) {
834  
835      /* found one.  set lowsuf = to the new suffix, and tack on to filename */
836  
837 @@ -1422,6 +1442,10 @@
838  
839  #ifdef HAVE_TIFF
840      case F_TIFF:     strcpy(lowsuf,"tif");  break;
841 +#endif
842 +
843 +#ifdef HAVE_PNG
844 +    case F_PNG:      strcpy(lowsuf,"png");  break;
845  #endif
846      }
847  
848 diff -uNr xvevent.c xvevent.c
849 --- ./xvevent.c Tue Jan 24 00:20:24 1995
850 +++ ./xvevent.c Tue Feb 20 17:04:44 2001
851 @@ -154,7 +154,7 @@
852       int    *donep;
853  {
854    static int wasInfoUp=0, wasCtrlUp=0, wasDirUp=0, wasGamUp=0, wasPsUp=0;
855 -  static int wasJpegUp=0, wasTiffUp=0;
856 +  static int wasJpegUp=0, wasTiffUp=0, wasPngUp=0;
857  
858    static int mainWKludge=0;  /* force first mainW expose after a mainW config
859                                 to redraw all of mainW */
860 @@ -233,6 +233,10 @@
861      if (TIFFCheckEvent(event)) break;   /* event has been processed */
862  #endif
863  
864 +#ifdef HAVE_PNG
865 +    if (PNGCheckEvent (event)) break;   /* event has been processed */
866 +#endif
867 +
868      if (GamCheckEvent (event)) break;   /* event has been processed */
869      if (BrowseCheckEvent (event, &retval, &done)) break;   /* event eaten */
870      if (TextCheckEvent   (event, &retval, &done)) break;   /* event eaten */
871 @@ -359,6 +363,10 @@
872        else if (client_event->window == tiffW) TIFFDialog(0);
873  #endif
874  
875 +#ifdef HAVE_PNG
876 +      else if (client_event->window == pngW)  PNGDialog(0);
877 +#endif
878 +
879        else if (client_event->window == mainW) Quit(0);
880      }
881    }
882 @@ -538,6 +546,10 @@
883  #ifdef HAVE_TIFF
884         if (wasTiffUp) { TIFFDialog(wasTiffUp);  wasTiffUp=0; }
885  #endif
886 +
887 +#ifdef HAVE_PNG
888 +       if (wasPngUp)  { PNGDialog(wasJpegUp);   wasPngUp=0; }
889 +#endif
890        }
891      }
892    }
893 @@ -576,6 +588,10 @@
894  #ifdef HAVE_TIFF
895           if (tiffUp) { wasTiffUp = tiffUp;  TIFFDialog(0); }
896  #endif
897 +
898 +#ifdef HAVE_PNG
899 +         if (pngUp)  { wasPngUp  = pngUp;   PNGDialog(0); }
900 +#endif
901         }
902        }
903      }
904 @@ -1147,6 +1163,10 @@
905      if (TIFFCheckEvent(event)) break;
906  #endif
907      
908 +#ifdef HAVE_PNG
909 +    if (PNGCheckEvent (event)) break;
910 +#endif
911 +    
912      if (GamCheckEvent (event)) break;
913      if (BrowseCheckEvent (event, &retval, &done)) break;
914      if (TextCheckEvent   (event, &retval, &done)) break;
915 @@ -1366,6 +1386,10 @@
916      if (TIFFCheckEvent(event)) break;
917  #endif
918  
919 +#ifdef HAVE_PNG
920 +    if (PNGCheckEvent (event)) break;
921 +#endif
922 +
923      if (GamCheckEvent (event)) break;
924      if (BrowseCheckEvent (event, &retval, &done)) break;
925      if (TextCheckEvent   (event, &retval, &done)) break;
926 @@ -2370,6 +2394,10 @@
927  
928  #ifdef HAVE_TIFF
929    if (tiffUp) TIFFDialog(0);  /* close tiff window */
930 +#endif
931 +
932 +#ifdef HAVE_PNG
933 +  if (pngUp) PNGDialog(0);    /* close png window */
934  #endif
935  
936    ClosePopUp();
937 diff -uNr xvgam.c xvgam.c
938 --- ./xvgam.c   Fri Jan 13 20:51:14 1995
939 +++ ./xvgam.c   Tue Feb 20 17:04:44 2001
940 @@ -265,11 +265,11 @@
941    BTCreate(&gbut[G_BRNDCOL], cmapF,  5 + 66 + 67 + 2, 189, 66, BUTTH, 
942            "Random", infofg, infobg, hicol, locol);
943  
944 -  DCreate(&rhDial, cmapF, 5, 215, 66, 100,   0,360,180, 5, 
945 +  DCreate(&rhDial, cmapF, 5, 215, 66, 100,   0.0, 360.0, 180.0, 1.0, 5.0, 
946           infofg, infobg, hicol, locol, "Hue", NULL);
947 -  DCreate(&gsDial, cmapF, 72, 215, 66, 100,  0,360,180, 5, 
948 +  DCreate(&gsDial, cmapF, 72, 215, 66, 100,  0.0, 360.0, 180.0, 1.0, 5.0, 
949           infofg, infobg, hicol, locol, "Sat.", NULL);
950 -  DCreate(&bvDial, cmapF, 139, 215, 66, 100,   0,360,180, 5, 
951 +  DCreate(&bvDial, cmapF, 139, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0, 
952           infofg, infobg, hicol, locol, "Value", NULL);
953  
954    rhDial.drawobj = gsDial.drawobj = bvDial.drawobj = dragEditColor;
955 @@ -359,7 +359,7 @@
956  
957    srcHD.drawobj = dstHD.drawobj = whtHD.drawobj = dragHueDial;
958  
959 -  DCreate(&satDial, hsvF, 100, 199, 100, 121, -100, 100, 0, 5, 
960 +  DCreate(&satDial, hsvF, 100, 199, 100, 121, -100.0, 100.0, 0.0, 1.0, 5.0, 
961            infofg, infobg,hicol,locol, "Saturation", "%");
962  
963    hueRB = RBCreate(NULL, hsvF,  7, 153, "1", 
964 @@ -722,7 +722,7 @@
965  
966    if (whtHD.enabCB.val && whtHD.satval) hsvnonlinear++;
967  
968 -  if (satDial.val != 0) hsvnonlinear++;
969 +  if (satDial.val != 0.0) hsvnonlinear++;
970  
971    /* check intensity graf */
972    for (i=0; i<256 && intGraf.func[i]==i; i++);
973 @@ -1291,14 +1291,14 @@
974      rgb2hsv(rcmap[editColor], gcmap[editColor], bcmap[editColor], &h, &s, &v);
975      if (h<0) h = 0;
976  
977 -    DSetVal(&rhDial, (int) h);
978 -    DSetVal(&gsDial, (int) (s*100));
979 -    DSetVal(&bvDial, (int) (v*100));
980 +    DSetVal(&rhDial, h);
981 +    DSetVal(&gsDial, s*100);
982 +    DSetVal(&bvDial, v*100);
983    }
984    else {
985 -    DSetVal(&rhDial, rcmap[editColor]);
986 -    DSetVal(&gsDial, gcmap[editColor]);
987 -    DSetVal(&bvDial, bcmap[editColor]);
988 +    DSetVal(&rhDial, (double)rcmap[editColor]);
989 +    DSetVal(&gsDial, (double)gcmap[editColor]);
990 +    DSetVal(&bvDial, (double)bcmap[editColor]);
991    }
992  }
993    
994 @@ -1310,16 +1310,15 @@
995  
996    if (hsvmode) {
997      int rv, gv, bv;
998 -    hsv2rgb((double) rhDial.val, ((double) gsDial.val) / 100.0, 
999 -           ((double) bvDial.val) / 100.0, &rv, &gv, &bv);
1000 +    hsv2rgb(rhDial.val, gsDial.val / 100.0, bvDial.val / 100.0, &rv, &gv, &bv);
1001      rcmap[editColor] = rv;
1002      gcmap[editColor] = gv;
1003      bcmap[editColor] = bv;
1004    }
1005    else {
1006 -    rcmap[editColor] = rhDial.val;
1007 -    gcmap[editColor] = gsDial.val;
1008 -    bcmap[editColor] = bvDial.val;
1009 +    rcmap[editColor] = (int)rhDial.val;
1010 +    gcmap[editColor] = (int)gsDial.val;
1011 +    bcmap[editColor] = (int)bvDial.val;
1012    }
1013  }
1014  
1015 @@ -1561,9 +1560,9 @@
1016      gsDial.title = "Green";
1017      bvDial.title = "Blue";
1018                    
1019 -    DSetRange(&rhDial, 0, 255, rcmap[editColor], 16);
1020 -    DSetRange(&gsDial, 0, 255, gcmap[editColor], 16);
1021 -    DSetRange(&bvDial, 0, 255, bcmap[editColor], 16);
1022 +    DSetRange(&rhDial, 0.0, 255.0, (double)rcmap[editColor], 1.0, 16.0);
1023 +    DSetRange(&gsDial, 0.0, 255.0, (double)gcmap[editColor], 1.0, 16.0);
1024 +    DSetRange(&bvDial, 0.0, 255.0, (double)bcmap[editColor], 1.0, 16.0);
1025  
1026      XClearWindow(theDisp, rhDial.win);    DRedraw(&rhDial);
1027      XClearWindow(theDisp, gsDial.win);    DRedraw(&gsDial);
1028 @@ -1581,9 +1580,9 @@
1029             &h, &s, &v);
1030  
1031      if (h<0.0) h = 0.0;
1032 -    DSetRange(&rhDial, 0, 360, (int) h, 5);
1033 -    DSetRange(&gsDial, 0, 100, (int) (s*100), 5);
1034 -    DSetRange(&bvDial, 0, 100, (int) (v*100), 5);
1035 +    DSetRange(&rhDial, 0.0, 360.0,     h, 1.0, 5.0);
1036 +    DSetRange(&gsDial, 0.0, 100.0, s*100, 1.0, 5.0);
1037 +    DSetRange(&bvDial, 0.0, 100.0, v*100, 1.0, 5.0);
1038  
1039      XClearWindow(theDisp, rhDial.win);    DRedraw(&rhDial);
1040      XClearWindow(theDisp, gsDial.win);    DRedraw(&gsDial);
1041 @@ -1891,7 +1890,7 @@
1042      }
1043  
1044      /* apply satDial value to s */
1045 -    s = s + ((double) satDial.val) / 100.0;
1046 +    s = s + satDial.val / 100.0;
1047      if (s<0.0) s = 0.0;
1048      if (s>1.0) s = 1.0;
1049  
1050 @@ -2007,7 +2006,7 @@
1051  
1052    gs->hueRBnum = RBWhich(hueRB);
1053  
1054 -  gs->satval = satDial.val;
1055 +  gs->satval = (int)satDial.val;
1056    GetGrafState(&intGraf,&gs->istate);
1057    GetGrafState(&rGraf,  &gs->rstate);
1058    GetGrafState(&gGraf,  &gs->gstate);
1059 @@ -2064,8 +2063,8 @@
1060      changed++;
1061    }
1062      
1063 -  if (gs->satval != satDial.val) {
1064 -    DSetVal(&satDial,gs->satval);
1065 +  if (gs->satval != (int)satDial.val) {
1066 +    DSetVal(&satDial,(double)gs->satval);
1067      changed++;
1068    }
1069  
1070 @@ -3200,7 +3199,7 @@
1071  
1072    if (whtHD.enabCB.val && whtHD.satval) hsvmod++;
1073  
1074 -  if (satDial.val != 0) hsvmod++;
1075 +  if (satDial.val != 0.0) hsvmod++;
1076  
1077    /* check intensity graf */
1078    for (i=0; i<256; i++) {
1079 @@ -3284,7 +3283,7 @@
1080        }
1081  
1082        /* apply satDial value to s */
1083 -      s = s + satDial.val;
1084 +      s = s + (int)satDial.val;
1085        if (s<  0) s =   0;
1086        if (s>100) s = 100;
1087  
1088 diff -uNr xvjpeg.c xvjpeg.c
1089 --- ./xvjpeg.c  Thu Jan  5 09:17:13 1995
1090 +++ ./xvjpeg.c  Tue Feb 20 17:49:14 2001
1091 @@ -12,8 +12,8 @@
1092  
1093  #include <setjmp.h>
1094  
1095 -#include "jpeglib.h"
1096 -#include "jerror.h"
1097 +#include <jpeglib.h>
1098 +#include <jerror.h>
1099  
1100  #define CREATOR_STR "CREATOR: "
1101  
1102 @@ -51,11 +51,11 @@
1103  static    void         clickJD            PARM((int, int));
1104  static    void         doCmd              PARM((int));
1105  static    void         writeJPEG          PARM((void));
1106 -METHODDEF void         xv_error_exit      PARM((j_common_ptr));
1107 -METHODDEF void         xv_error_output    PARM((j_common_ptr));
1108 -METHODDEF void         xv_prog_meter      PARM((j_common_ptr));
1109 +METHODDEF(void)        xv_error_exit      PARM((j_common_ptr));
1110 +METHODDEF(void)        xv_error_output    PARM((j_common_ptr));
1111 +METHODDEF(void)        xv_prog_meter      PARM((j_common_ptr));
1112  static    unsigned int j_getc             PARM((j_decompress_ptr));
1113 -METHODDEF boolean      xv_process_comment PARM((j_decompress_ptr));
1114 +METHODDEF(boolean)     xv_process_comment PARM((j_decompress_ptr));
1115  static    int          writeJFIF          PARM((FILE *, byte *, int,int,int));
1116  
1117  
1118 @@ -87,10 +87,10 @@
1119    
1120    XSelectInput(theDisp, jpegW, ExposureMask | ButtonPressMask | KeyPressMask);
1121    
1122 -  DCreate(&qDial, jpegW, 10, 10, 80, 100, 1, 100, 75, 5, 
1123 +  DCreate(&qDial, jpegW, 10, 10, 80, 100, 1.0, 100.0, 75.0, 1.0, 5.0, 
1124           infofg, infobg, hicol, locol, "Quality", "%");
1125    
1126 -  DCreate(&smDial, jpegW, 120, 10, 80, 100, 0, 100, 0, 5, 
1127 +  DCreate(&smDial, jpegW, 120, 10, 80, 100, 0.0, 100.0, 0.0, 1.0, 5.0, 
1128           infofg, infobg, hicol, locol, "Smoothing", "%");
1129    
1130    BTCreate(&jbut[J_BOK], jpegW, JWIDE-180-1, JHIGH-10-BUTTH-1, 80, BUTTH, 
1131 @@ -400,7 +400,7 @@
1132  
1133  
1134  /**************************************************/
1135 -METHODDEF void xv_error_exit(cinfo) 
1136 +METHODDEF (void) xv_error_exit(cinfo) 
1137       j_common_ptr cinfo;
1138  {
1139    my_error_ptr myerr;
1140 @@ -412,7 +412,7 @@
1141  
1142  
1143  /**************************************************/
1144 -METHODDEF void xv_error_output(cinfo) 
1145 +METHODDEF (void) xv_error_output(cinfo) 
1146       j_common_ptr cinfo;
1147  {
1148    my_error_ptr myerr;
1149 @@ -426,7 +426,7 @@
1150  
1151  
1152  /**************************************************/
1153 -METHODDEF void xv_prog_meter(cinfo)
1154 +METHODDEF (void) xv_prog_meter(cinfo)
1155       j_common_ptr cinfo;
1156  {
1157    struct jpeg_progress_mgr *prog;
1158 @@ -671,7 +671,7 @@
1159  
1160  
1161  /**************************************************/
1162 -METHODDEF boolean xv_process_comment(cinfo)
1163 +METHODDEF (boolean) xv_process_comment(cinfo)
1164       j_decompress_ptr cinfo;
1165  {
1166    int          length, hasnull;
1167 @@ -759,8 +759,8 @@
1168  
1169  
1170    jpeg_set_defaults(&cinfo);
1171 -  jpeg_set_quality(&cinfo, qDial.val, TRUE);
1172 -  cinfo.smoothing_factor = smDial.val;
1173 +  jpeg_set_quality(&cinfo, (int)qDial.val, TRUE);
1174 +  cinfo.smoothing_factor = (int)smDial.val;
1175  
1176  
1177    jpeg_start_compress(&cinfo, TRUE);
1178 @@ -769,7 +769,7 @@
1179    /*** COMMENT HANDLING ***/
1180  
1181    sprintf(xvcmt, "%sXV %s  Quality = %d, Smoothing = %d\n",
1182 -         CREATOR_STR, REVDATE, qDial.val, smDial.val);
1183 +         CREATOR_STR, REVDATE, (int)qDial.val, (int)smDial.val);
1184    
1185    if (picComments) {   /* append XV comment */
1186      char *sp, *sp1;  int done;
1187 diff -uNr xvmisc.c xvmisc.c
1188 --- ./xvmisc.c  Sat Jan 14 00:41:34 1995
1189 +++ ./xvmisc.c  Tue Feb 20 17:04:44 2001
1190 @@ -520,6 +520,10 @@
1191      if (tiffW) XDestroyWindow(theDisp, tiffW);
1192  #endif
1193  
1194 +#ifdef HAVE_PNG
1195 +    if (pngW)  XDestroyWindow(theDisp, pngW);
1196 +#endif
1197 +
1198      /* if NOT using stdcmap for images, free stdcmap */
1199      if (colorMapMode != CM_STDCMAP) { 
1200        int j;
1201 @@ -715,6 +719,10 @@
1202    
1203  #ifdef HAVE_TIFF
1204    if (tiffW) XDefineCursor(theDisp, tiffW, otherc);
1205 +#endif
1206 +
1207 +#ifdef HAVE_PNG
1208 +  if (pngW)  XDefineCursor(theDisp, pngW, otherc);
1209  #endif
1210  }
1211  
1212 diff -uNr xvpng.c xvpng.c
1213 --- ./xvpng.c   Thu Jan  1 01:00:00 1970
1214 +++ ./xvpng.c   Tue Feb 20 17:49:44 2001
1215 @@ -0,0 +1,965 @@
1216 +/*
1217 + * xvpng.c - load and write routines for 'PNG' format pictures
1218 + *
1219 + * callable functions
1220 + *
1221 + *    CreatePNGW()
1222 + *    PNGDialog(vis)
1223 + *    PNGCheckEvent(xev)
1224 + *    PNGSaveParams(fname, col)
1225 + *    LoadPNG(fname, pinfo)
1226 + */
1227 +
1228 +/*#include "copyright.h"*/
1229 +/* (c) 1995 by Alexander Lehmann <lehmann@mathematik.th-darmstadt.de>
1230 + *   this file is a suplement to xv and is supplied under the same copying
1231 + *   conditions (except the shareware part)
1232 + * Modified by Andreas Dilger <adilger@enel.ucalgary.ca> to fix
1233 + *   error handling for bad PNGs, add dialogs for interlacing and
1234 + *   compression selection, and upgrade to libpng-0.89
1235 + * The copyright will be passed on to JB at some future point if he
1236 + * so desires.
1237 + */
1238 +
1239 +#include "xv.h"
1240 +
1241 +#ifdef HAVE_PNG
1242 +
1243 +#include <png.h>
1244 +
1245 +/*** Stuff for PNG Dialog box ***/
1246 +#define PWIDE 318
1247 +#define PHIGH 215
1248 +
1249 +#define DISPLAY_GAMMA 2.20  /* Default display gamma */
1250 +/* Default zlib compression level
1251 +#define COMPRESSION   Z_BEST_COMPRESSION
1252 +*/
1253 +#define COMPRESSION   6
1254 +
1255 +#define DWIDE     86
1256 +#define DHIGH    104
1257 +#define PFX PWIDE-93
1258 +#define PFY       44
1259 +#define PFH       20
1260 +
1261 +#define P_BOK    0
1262 +#define P_BCANC  1
1263 +#define P_NBUTTS 2
1264 +
1265 +#define BUTTH    24
1266 +
1267 +/*** local functions ***/
1268 +static    void drawPD         PARM((int, int, int, int));
1269 +static    void clickPD        PARM((int, int));
1270 +static    void doCmd          PARM((int));
1271 +static    void writePNG       PARM((void));
1272 +static    int  WritePNG       PARM((FILE *, byte *, int, int, int,
1273 +                                    byte *, byte *, byte *, int));
1274 +
1275 +static    void png_xv_error   PARM((png_struct *png_ptr, char *message));
1276 +static    void png_xv_warning PARM((png_struct *png_ptr, char *message));
1277 +
1278 +/*** local variables ***/
1279 +static char *filename;
1280 +static char *fbasename;
1281 +static int   colorType;
1282 +static int   read_anything;
1283 +static double Display_Gamma = DISPLAY_GAMMA;
1284 +
1285 +static DIAL  cDial, gDial;
1286 +static BUTT  pbut[P_NBUTTS];
1287 +static CBUTT interCB;
1288 +static CBUTT FdefCB, FnoneCB, FsubCB, FupCB, FavgCB, FPaethCB;
1289 +
1290 +/**************************************************************************/
1291 +/* PNG SAVE DIALOG ROUTINES ***********************************************/
1292 +/**************************************************************************/
1293 +
1294 +
1295 +/*******************************************/
1296 +void CreatePNGW()
1297 +{
1298 +  pngW = CreateWindow("xv png", "XVPNG", NULL,
1299 +                      PWIDE, PHIGH, infofg, infobg, 0);
1300 +  if (!pngW) FatalError("can't create PNG window!");
1301 +
1302 +  XSelectInput(theDisp, pngW, ExposureMask | ButtonPressMask | KeyPressMask);
1303 +
1304 +  DCreate(&cDial, pngW,  12, 25, DWIDE, DHIGH, (double)Z_NO_COMPRESSION,
1305 +          (double)Z_BEST_COMPRESSION, COMPRESSION, 1.0, 2.0,
1306 +          infofg, infobg, hicol, locol, "Compression", NULL);
1307 +
1308 +  DCreate(&gDial, pngW, DWIDE+27, 25, DWIDE, DHIGH, 1.0, 3.5,DISPLAY_GAMMA,0.01,0.2,
1309 +          infofg, infobg, hicol, locol, "Disp. Gamma", NULL);
1310 +
1311 +  CBCreate(&interCB, pngW,  DWIDE+30, DHIGH+3*LINEHIGH+2, "interlace",
1312 +           infofg, infobg, hicol, locol);
1313 +
1314 +  CBCreate(&FdefCB,   pngW, PFX, PFY, "Default",
1315 +           infofg, infobg, hicol, locol);
1316 +  FdefCB.val = 1;
1317 +
1318 +  CBCreate(&FnoneCB,  pngW, PFX, FdefCB.y + PFH + 4, "none",
1319 +           infofg, infobg, hicol, locol);
1320 +  CBCreate(&FsubCB,   pngW, PFX, FnoneCB.y + PFH, "sub",
1321 +           infofg, infobg, hicol, locol);
1322 +  CBCreate(&FupCB,    pngW, PFX, FsubCB.y  + PFH, "up",
1323 +           infofg, infobg, hicol, locol);
1324 +  CBCreate(&FavgCB,   pngW, PFX, FupCB.y   + PFH, "average",
1325 +           infofg, infobg, hicol, locol);
1326 +  CBCreate(&FPaethCB, pngW, PFX, FavgCB.y  + PFH, "Paeth",
1327 +           infofg, infobg, hicol, locol);
1328 +
1329 +  FnoneCB.val = FsubCB.val = FupCB.val = FavgCB.val = FPaethCB.val = 1;
1330 +  CBSetActive(&FnoneCB, !FdefCB.val);
1331 +  CBSetActive(&FsubCB, !FdefCB.val);
1332 +  CBSetActive(&FupCB, !FdefCB.val);
1333 +  CBSetActive(&FavgCB, !FdefCB.val);
1334 +  CBSetActive(&FPaethCB, !FdefCB.val);
1335 +
1336 +  BTCreate(&pbut[P_BOK], pngW, PWIDE-180-1, PHIGH-10-BUTTH-1, 80, BUTTH,
1337 +          "Ok", infofg, infobg, hicol, locol);
1338 +  BTCreate(&pbut[P_BCANC], pngW, PWIDE-90-1, PHIGH-10-BUTTH-1, 80, BUTTH,
1339 +          "Cancel", infofg, infobg, hicol, locol);
1340 +
1341 +  XMapSubwindows(theDisp, pngW);          
1342 +}
1343 +
1344 +
1345 +/*******************************************/
1346 +void PNGDialog(vis)
1347 +     int vis;
1348 +{
1349 +  if (vis) {
1350 +    CenterMapWindow(pngW, pbut[P_BOK].x + (int) pbut[P_BOK].w/2,
1351 +                          pbut[P_BOK].y + (int) pbut[P_BOK].h/2,
1352 +                    PWIDE, PHIGH);
1353 +  }
1354 +  else XUnmapWindow(theDisp, pngW);
1355 +  pngUp = vis;
1356 +}
1357 +
1358 +
1359 +/*******************************************/
1360 +int PNGCheckEvent(xev)
1361 +     XEvent *xev;
1362 +{
1363 +  /* check event to see if it's for one of our subwindows.  If it is,
1364 +     deal accordingly, and return '1'.  Otherwise, return '0' */
1365 +
1366 +  int rv;
1367 +  rv = 1;
1368 +
1369 +  if (!pngUp) return 0;
1370 +
1371 +  if (xev->type == Expose) {
1372 +    int x,y,w,h;
1373 +    XExposeEvent *e = (XExposeEvent *) xev;
1374 +    x = e->x; y = e->y; w = e->width; h = e->height;
1375 +
1376 +    /* throw away excess expose events for 'dumb' windows */
1377 +    if (e->count > 0 && (e->window == cDial.win)) {}
1378 +
1379 +    else if (e->window == pngW)        drawPD(x, y, w, h);
1380 +    else if (e->window == cDial.win)   DRedraw(&cDial);
1381 +    else if (e->window == gDial.win)   DRedraw(&gDial);
1382 +    else rv = 0;
1383 +  }
1384 +
1385 +  else if (xev->type == ButtonPress) {
1386 +    XButtonEvent *e = (XButtonEvent *) xev;
1387 +    int x,y;
1388 +    x = e->x;  y = e->y;
1389 +    
1390 +    if (e->button == Button1) {
1391 +      if      (e->window == pngW)       clickPD(x,y);
1392 +      else if (e->window == cDial.win)  DTrack(&cDial,x,y);
1393 +      else if (e->window == gDial.win)  DTrack(&gDial,x,y);
1394 +      else rv = 0;
1395 +    }  /* button1 */
1396 +    else rv = 0;
1397 +  }  /* button press */
1398 +
1399 +  else if (xev->type == KeyPress) {
1400 +    XKeyEvent *e = (XKeyEvent *) xev;
1401 +    char buf[128];  KeySym ks;
1402 +    int stlen;
1403 +    
1404 +    stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL);
1405 +    buf[stlen] = '\0';
1406 +    
1407 +    RemapKeyCheck(ks, buf, &stlen);
1408 +    
1409 +    if (e->window == pngW) {
1410 +      if (stlen) {
1411 +        if (buf[0] == '\r' || buf[0] == '\n') { /* enter */
1412 +          FakeButtonPress(&pbut[P_BOK]);
1413 +        }
1414 +        else if (buf[0] == '\033') {            /* ESC */
1415 +          FakeButtonPress(&pbut[P_BCANC]);
1416 +        }
1417 +      }
1418 +    }
1419 +    else rv = 0;
1420 +  }
1421 +  else rv = 0;
1422 +
1423 +  if (rv==0 && (xev->type == ButtonPress || xev->type == KeyPress)) {
1424 +    XBell(theDisp, 50);
1425 +    rv = 1;   /* eat it */
1426 +  }
1427 +
1428 +  return rv;
1429 +}
1430 +
1431 +
1432 +/*******************************************/
1433 +void PNGSaveParams(fname, col)
1434 +     char *fname;
1435 +     int col;
1436 +{
1437 +  filename = fname;
1438 +  colorType = col;
1439 +}
1440 +
1441 +
1442 +/*******************************************/
1443 +static void drawPD(x, y, w, h)
1444 +     int x, y, w, h;
1445 +{
1446 +  char *title   = "Save PNG file...";
1447 +
1448 +  char ctitle1[20];
1449 +  char *ctitle2 = "Useful range";
1450 +  char *ctitle3 = "is 2 - 7.";
1451 +  char *ctitle4 = "Uncompressed = 0";
1452 +
1453 +  char *ftitle  = "Row Filters:";
1454 +
1455 +  char gtitle[20];
1456 +
1457 +  int i;
1458 +  XRectangle xr;
1459 +  
1460 +  xr.x = x;  xr.y = y;  xr.width = w;  xr.height = h;
1461 +  XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted);
1462 +
1463 +  XSetForeground(theDisp, theGC, infofg);
1464 +  XSetBackground(theDisp, theGC, infobg);
1465 +
1466 +  for (i=0; i<P_NBUTTS; i++) BTRedraw(&pbut[i]);
1467 +
1468 +  DrawString(pngW,       15,  6+ASCENT,                          title);
1469 +
1470 +  sprintf(ctitle1, "Default = %d", COMPRESSION);
1471 +  DrawString(pngW,       18,  6+DHIGH+cDial.y+ASCENT,            ctitle1);
1472 +  DrawString(pngW,       17,  6+DHIGH+cDial.y+ASCENT+LINEHIGH,   ctitle2);
1473 +  DrawString(pngW,       17,  6+DHIGH+cDial.y+ASCENT+2*LINEHIGH, ctitle3);
1474 +  DrawString(pngW,       17,  6+DHIGH+cDial.y+ASCENT+3*LINEHIGH, ctitle4);
1475 +
1476 +  sprintf(gtitle, "Default = %g", DISPLAY_GAMMA);
1477 +  DrawString(pngW, DWIDE+30,  6+DHIGH+gDial.y+ASCENT,            gtitle);
1478 +
1479 +  ULineString(pngW, FdefCB.x, FdefCB.y-3-DESCENT, ftitle);
1480 +  XDrawRectangle(theDisp, pngW, theGC, FdefCB.x-11, FdefCB.y-LINEHIGH-3,
1481 +                                       93, 8*LINEHIGH+15);
1482 +  CBRedraw(&FdefCB);
1483 +  XDrawLine(theDisp, pngW, theGC, FdefCB.x-11, FdefCB.y+LINEHIGH+4,
1484 +                                  FdefCB.x+82, FdefCB.y+LINEHIGH+4);
1485 +
1486 +  CBRedraw(&FnoneCB);
1487 +  CBRedraw(&FupCB);
1488 +  CBRedraw(&FsubCB);
1489 +  CBRedraw(&FavgCB);
1490 +  CBRedraw(&FPaethCB);
1491 +
1492 +  CBRedraw(&interCB);
1493 +
1494 +  XSetClipMask(theDisp, theGC, None);
1495 +}
1496 +
1497 +
1498 +/*******************************************/
1499 +static void clickPD(x,y)
1500 +     int x,y;
1501 +{
1502 +  int i;
1503 +  BUTT *bp;
1504 +
1505 +  /* check BUTTs */
1506 +  
1507 +  for (i=0; i<P_NBUTTS; i++) {
1508 +    bp = &pbut[i];
1509 +    if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
1510 +  }
1511 +  
1512 +  if (i<P_NBUTTS) {  /* found one */
1513 +    if (BTTrack(bp)) doCmd(i);
1514 +  }
1515 +
1516 +  /* check CBUTTs */
1517 +
1518 +  else if (CBClick(&FdefCB,x,y)) {
1519 +    int oldval = FdefCB.val;
1520 +
1521 +    CBTrack(&FdefCB);
1522 +
1523 +    if (oldval != FdefCB.val)
1524 +    {
1525 +      CBSetActive(&FnoneCB, !FdefCB.val);
1526 +      CBSetActive(&FsubCB, !FdefCB.val);
1527 +      CBSetActive(&FupCB, !FdefCB.val);
1528 +      CBSetActive(&FavgCB, !FdefCB.val);
1529 +      CBSetActive(&FPaethCB, !FdefCB.val);
1530 +
1531 +      CBRedraw(&FnoneCB);
1532 +      CBRedraw(&FupCB);
1533 +      CBRedraw(&FsubCB);
1534 +      CBRedraw(&FavgCB);
1535 +      CBRedraw(&FPaethCB);
1536 +    }
1537 +  }
1538 +  else if (CBClick(&FnoneCB,x,y))  CBTrack(&FnoneCB);
1539 +  else if (CBClick(&FsubCB,x,y))   CBTrack(&FsubCB);
1540 +  else if (CBClick(&FupCB,x,y))    CBTrack(&FupCB);
1541 +  else if (CBClick(&FavgCB,x,y))   CBTrack(&FavgCB);
1542 +  else if (CBClick(&FPaethCB,x,y)) CBTrack(&FPaethCB);
1543 +  else if (CBClick(&interCB,x,y))  CBTrack(&interCB);
1544 +}
1545 +
1546 +
1547 +/*******************************************/
1548 +static void doCmd(cmd)
1549 +     int cmd;
1550 +{
1551 +  switch (cmd) {
1552 +  case P_BOK: {
1553 +    char *fullname;
1554 +
1555 +    writePNG();
1556 +    PNGDialog(0);
1557 +    
1558 +    fullname = GetDirFullName();
1559 +    if (!ISPIPE(fullname[0])) {
1560 +      XVCreatedFile(fullname);
1561 +      StickInCtrlList(0);
1562 +    }
1563 +  }
1564 +    break;
1565 +
1566 +  case P_BCANC:  PNGDialog(0);  break;
1567 +
1568 +  default:        break;
1569 +  }
1570 +}
1571 +
1572 +
1573 +/*******************************************/
1574 +static void writePNG()
1575 +{
1576 +  FILE       *fp;
1577 +  int         w, h, nc, rv, ptype, pfree;
1578 +  byte       *inpix, *rmap, *gmap, *bmap;
1579 +
1580 +  fp = OpenOutFile(filename);
1581 +  if (!fp) return;
1582 +
1583 +  fbasename = BaseName(filename);
1584 +
1585 +  WaitCursor();
1586 +  inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
1587 +
1588 +  rv = WritePNG(fp, inpix, ptype, w, h, rmap, gmap, bmap, nc);
1589 +
1590 +  SetCursors(-1);
1591 +
1592 +  if (CloseOutFile(fp, filename, rv) == 0) DirBox(0);
1593 +
1594 +  if (pfree) free(inpix);
1595 +}
1596 +
1597 +
1598 +/*******************************************/
1599 +int WritePNG(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols)
1600 +     FILE *fp;
1601 +     byte *pic;
1602 +     int   ptype, w, h;
1603 +     byte *rmap, *gmap, *bmap;
1604 +     int   numcols;
1605 +{
1606 +  png_struct *png_ptr;
1607 +  png_info   *info_ptr;
1608 +  png_color   palette[256];
1609 +  png_textp   text;
1610 +  byte        remap[256];
1611 +  int         i, filter, linesize = 0, pass;
1612 +  byte       *p, *png_line;
1613 +  char        software[256];
1614 +  char       *savecmnt = NULL;
1615 +
1616 +  if ((png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
1617 +       png_xv_error, png_xv_warning)) == NULL) {
1618 +    FatalError("malloc failure in WritePNG");
1619 +  }
1620 +
1621 +  if ((info_ptr = png_create_info_struct(png_ptr)) == NULL)
1622 +  {
1623 +    png_destroy_write_struct(&png_ptr, &info_ptr);
1624 +    FatalError("malloc failure in WritePNG");
1625 +  }
1626 +
1627 +  if (setjmp(png_ptr->jmpbuf)) {
1628 +    png_destroy_write_struct(&png_ptr, &info_ptr);
1629 +    return -1;
1630 +  }
1631 +
1632 +  png_init_io(png_ptr, fp);
1633 +
1634 +  png_set_compression_level(png_ptr, (int)cDial.val);
1635 +
1636 +  /* Don't bother filtering if we aren't compressing the image */
1637 +  if (FdefCB.val)
1638 +  {
1639 +    if ((int)cDial.val == 0)
1640 +      png_set_filter(png_ptr, 0, PNG_FILTER_NONE);
1641 +  }
1642 +  else
1643 +  {
1644 +    filter  = FnoneCB.val  ? PNG_FILTER_NONE  : 0;
1645 +    filter |= FsubCB.val   ? PNG_FILTER_SUB   : 0;
1646 +    filter |= FupCB.val    ? PNG_FILTER_UP    : 0;
1647 +    filter |= FavgCB.val   ? PNG_FILTER_AVG   : 0;
1648 +    filter |= FPaethCB.val ? PNG_FILTER_PAETH : 0;
1649 +
1650 +    png_set_filter(png_ptr, 0, filter);
1651 +  }
1652 +
1653 +  info_ptr->width = w;
1654 +  info_ptr->height = h;
1655 +
1656 +  info_ptr->interlace_type = interCB.val ? 1 : 0;
1657 +
1658 +  if (colorType == F_FULLCOLOR || colorType == F_REDUCED) {
1659 +    if(ptype == PIC24) {
1660 +      linesize = 3*w;
1661 +      info_ptr->color_type = PNG_COLOR_TYPE_RGB;
1662 +      info_ptr->bit_depth = 8;
1663 +    } else {
1664 +      linesize = w;
1665 +      info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
1666 +      if(numcols <= 2)
1667 +        info_ptr->bit_depth = 1;
1668 +      else
1669 +      if(numcols <= 4)
1670 +        info_ptr->bit_depth = 2;
1671 +      else
1672 +      if(numcols <= 16)
1673 +        info_ptr->bit_depth = 4;
1674 +      else
1675 +        info_ptr->bit_depth = 8;
1676 +
1677 +      for(i = 0; i < numcols; i++) {
1678 +        palette[i].red   = rmap[i];
1679 +        palette[i].green = gmap[i];
1680 +        palette[i].blue  = bmap[i];
1681 +      }
1682 +      info_ptr->num_palette = numcols;
1683 +      info_ptr->palette = palette;
1684 +      info_ptr->valid |= PNG_INFO_PLTE;
1685 +    }
1686 +  }
1687 +
1688 +  else if(colorType == F_GREYSCALE || colorType == F_BWDITHER) {
1689 +    info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
1690 +    if(colorType == F_BWDITHER) {
1691 +      /* shouldn't happen */
1692 +      if (ptype == PIC24) FatalError("PIC24 and B/W Stipple in WritePNG()");
1693 +
1694 +      info_ptr->bit_depth = 1;
1695 +      if(MONO(rmap[0], gmap[0], bmap[0]) > MONO(rmap[1], gmap[1], bmap[1])) {
1696 +        remap[0] = 1;
1697 +        remap[1] = 0;
1698 +      }
1699 +      else {
1700 +        remap[0] = 0;
1701 +        remap[1] = 1;
1702 +      }
1703 +      linesize = w;
1704 +    }
1705 +    else {
1706 +      if(ptype == PIC24) {
1707 +        linesize = w*3;
1708 +        info_ptr->bit_depth = 8;
1709 +      }
1710 +      else {
1711 +        int low_presc;
1712 +
1713 +        linesize = w;
1714 +
1715 +        for(i = 0; i < numcols; i++)
1716 +          remap[i] = MONO(rmap[i], gmap[i], bmap[i]);
1717 +
1718 +        for(; i < 256; i++)
1719 +          remap[i]=0;
1720 +
1721 +        info_ptr->bit_depth = 8;
1722 +
1723 +        /* Note that this fails most of the time because of gamma */
1724 +        /* try to adjust to 4 bit prescision grayscale */
1725 +
1726 +        low_presc=1;
1727 +
1728 +        for(i = 0; i < numcols; i++) {
1729 +          if((remap[i] & 0x0f) * 0x11 != remap[i]) {
1730 +            low_presc = 0;
1731 +            break;
1732 +          }
1733 +        }
1734 +
1735 +        if(low_presc) {
1736 +          for(i = 0; i < numcols; i++) {
1737 +            remap[i] &= 0xf;
1738 +          }
1739 +          info_ptr->bit_depth = 4;
1740 +
1741 +          /* try to adjust to 2 bit prescision grayscale */
1742 +
1743 +          for(i = 0; i < numcols; i++) {
1744 +            if((remap[i] & 0x03) * 0x05 != remap[i]) {
1745 +              low_presc = 0;
1746 +              break;
1747 +            }
1748 +          }
1749 +        }
1750 +
1751 +        if(low_presc) {
1752 +          for(i = 0; i < numcols; i++) {
1753 +            remap[i] &= 3;
1754 +          }
1755 +          info_ptr->bit_depth = 2;
1756 +
1757 +          /* try to adjust to 1 bit prescision grayscale */
1758 +
1759 +          for(i = 0; i < numcols; i++) {
1760 +            if((remap[i] & 0x01) * 0x03 != remap[i]) {
1761 +              low_presc = 0;
1762 +              break;
1763 +            }
1764 +          }
1765 +        }
1766 +
1767 +        if(low_presc) {
1768 +          for(i = 0; i < numcols; i++) {
1769 +            remap[i] &= 1;
1770 +          }
1771 +          info_ptr->bit_depth = 1;
1772 +        }
1773 +      }
1774 +    }
1775 +  }
1776 +
1777 +  else
1778 +    png_error(png_ptr, "Unknown colorstyle in WritePNG");
1779 +
1780 +  if ((text = (png_textp)malloc(sizeof(png_text)))) {
1781 +    sprintf(software, "XV %s", REVDATE);
1782 +
1783 +    text->compression = -1;
1784 +    text->key = "Software";
1785 +    text->text = software;
1786 +    text->text_length = strlen(text->text);
1787 +
1788 +    info_ptr->max_text = 1;
1789 +    info_ptr->num_text = 1;
1790 +    info_ptr->text = text;
1791 +  }
1792 +
1793 +  Display_Gamma = gDial.val;  /* Save the current gamma for loading */
1794 +
1795 +  info_ptr->gamma = 1.0/gDial.val;
1796 +  info_ptr->valid |= PNG_INFO_gAMA;
1797 +
1798 +  png_write_info(png_ptr, info_ptr);
1799 +
1800 +  if(info_ptr->bit_depth < 8)
1801 +    png_set_packing(png_ptr);
1802 +
1803 +  pass=png_set_interlace_handling(png_ptr);
1804 +
1805 +  if((png_line = malloc(linesize)) == NULL)
1806 +    png_error(png_ptr, "cannot allocate temp image line");
1807 +
1808 +  for(i = 0; i < pass; i++) {
1809 +    int j;
1810 +    p = pic;
1811 +    for(j = 0; j < h; j++) {
1812 +  fflush(stdout);
1813 +      if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
1814 +        int k;
1815 +        for(k = 0; k < w; k++)
1816 +          png_line[k] = ptype==PIC24 ? MONO(p[k*3], p[k*3+1], p[k*3+2]) :
1817 +                                       remap[p[k]];
1818 +        png_write_row(png_ptr, png_line);
1819 +      } else  /* rbg or palette */
1820 +        png_write_row(png_ptr, p);
1821 +      if((j & 0x1f) == 0) WaitCursor();
1822 +      p += linesize;
1823 +    }
1824 +  }
1825 +
1826 +  free(png_line);
1827 +
1828 +  if (text)
1829 +  {
1830 +    if (picComments && strlen(picComments) &&
1831 +        (savecmnt = (char *)malloc((strlen(picComments) + 1)*sizeof(char)))) {
1832 +      png_textp tp;
1833 +      char *comment, *key;
1834 +
1835 +      strcpy(savecmnt, picComments);
1836 +      key = savecmnt;
1837 +      tp = text;
1838 +      info_ptr->num_text = 0;
1839 +
1840 +      comment = strchr(key, ':');
1841 +
1842 +      do  {
1843 +        /* Allocate a larger structure for comments if necessary */
1844 +        if (info_ptr->num_text >= info_ptr->max_text)
1845 +        {
1846 +          if ((tp =
1847 +              realloc(text, (info_ptr->num_text + 2)*sizeof(png_text))) == NULL)
1848 +          {
1849 +            break;
1850 +          }
1851 +          else
1852 +          {
1853 +            text = tp;
1854 +            tp = &text[info_ptr->num_text];
1855 +            info_ptr->max_text += 2;
1856 +          }
1857 +        }
1858 +
1859 +        /* See if it looks like a PNG keyword from LoadPNG */
1860 +        if(comment && comment[1] == ':' && comment - key <= 80) {
1861 +          *(comment++) = '\0';
1862 +          *(comment++) = '\0';
1863 +
1864 +          /* If the comment is the 'Software' chunk XV writes, we remove it,
1865 +             since we have already stored one */
1866 +          if (strcmp(key, "Software") == 0 && strncmp(comment, "XV", 2) == 0) {
1867 +            key = strchr(comment, '\n');
1868 +            if(key)
1869 +              key++; /* skip \n */
1870 +            comment = strchr(key, ':');
1871 +          }
1872 +          /* We have another keyword and/or comment to write out */
1873 +          else {
1874 +            tp->key = key;
1875 +            tp->text = comment;
1876 +
1877 +            /* We have to find the end of this comment, and the next keyword
1878 +               if there is one */
1879 +            do {
1880 +              key = comment = strchr(comment, ':');
1881 +            } while (key && key[1] != ':');
1882 +
1883 +            /* It looks like another keyword, go backward to the beginning */
1884 +            if (key) {
1885 +              while(key > tp->text && *key != '\n')
1886 +                key--;
1887 +
1888 +              if (key > tp->text && comment - key <= 80) {
1889 +                *key = '\0';
1890 +                key++;
1891 +              }
1892 +            }
1893 +
1894 +            tp->text_length = strlen(tp->text);
1895 +
1896 +            /* We don't have another keyword, so remove the last newline */
1897 +            if (!key && tp->text[tp->text_length - 1] == '\n')
1898 +            {
1899 +              tp->text[tp->text_length] = '\0';
1900 +              tp->text_length--;
1901 +            }
1902 +
1903 +            tp->compression = tp->text_length > 640 ? 0 : -1;
1904 +            info_ptr->num_text++;
1905 +            tp++;
1906 +          }
1907 +        }
1908 +        /* It is just a generic comment */
1909 +        else {
1910 +          tp->key = "Comment";
1911 +          tp->text = key;
1912 +          tp->text_length = strlen(tp->text);
1913 +          tp->compression = tp->text_length > 750 ? 0 : -1;
1914 +          info_ptr->num_text++;
1915 +          key = NULL;
1916 +        }
1917 +      } while (key && *key);
1918 +    }
1919 +    else
1920 +    {
1921 +      info_ptr->num_text = 0;
1922 +    }
1923 +  }
1924 +  info_ptr->text = text;
1925 +
1926 +  png_convert_from_time_t(&(info_ptr->mod_time), time(NULL));
1927 +  info_ptr->valid |= PNG_INFO_tIME;
1928 +
1929 +  png_write_end(png_ptr, info_ptr);
1930 +  png_destroy_write_struct(&png_ptr, &info_ptr);
1931 +
1932 +  if (text)
1933 +  {
1934 +    free(text);
1935 +    if (savecmnt)
1936 +      free(savecmnt);
1937 +  }
1938 +
1939 +  return 0;
1940 +}
1941 +
1942 +
1943 +/*******************************************/
1944 +int LoadPNG(fname, pinfo)
1945 +     char    *fname;
1946 +     PICINFO *pinfo;
1947 +/*******************************************/
1948 +{
1949 +  /* returns '1' on success */
1950 +
1951 +  FILE  *fp;
1952 +  png_struct *png_ptr;
1953 +  png_info *info_ptr;
1954 +  png_color_16 my_background;
1955 +  int i,j;
1956 +  int linesize;
1957 +  int filesize;
1958 +  int pass;
1959 +  size_t commentsize;
1960 +
1961 +  fbasename = BaseName(fname);
1962 +
1963 +  pinfo->pic     = (byte *) NULL;
1964 +  pinfo->comment = (char *) NULL;
1965 +
1966 +  read_anything=0;
1967 +
1968 +  /* open the file */
1969 +  fp = xv_fopen(fname,"r");
1970 +  if (!fp)
1971 +  {
1972 +    SetISTR(ISTR_WARNING,"%s:  can't open file", fname);
1973 +    return 0;
1974 +  }
1975 +
1976 +  /* find the size of the file */
1977 +  fseek(fp, 0L, 2);
1978 +  filesize = ftell(fp);
1979 +  fseek(fp, 0L, 0);
1980 +  
1981 +  png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
1982 +                                   png_xv_error, png_xv_warning);
1983 +  if(!png_ptr) {
1984 +    fclose(fp);
1985 +    FatalError("malloc failure in LoadPNG");
1986 +  }
1987 +
1988 +  info_ptr = png_create_info_struct(png_ptr);
1989 +
1990 +  if(!info_ptr) {
1991 +    fclose(fp);
1992 +    png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
1993 +    FatalError("malloc failure in LoadPNG");
1994 +  }
1995 +
1996 +  if(setjmp(png_ptr->jmpbuf)) {
1997 +    fclose(fp);
1998 +    png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
1999 +    if(!read_anything) {
2000 +      if(pinfo->pic) {
2001 +        free(pinfo->pic);
2002 +        pinfo->pic = NULL;
2003 +      }
2004 +      if(pinfo->comment) {
2005 +        free(pinfo->comment);
2006 +        pinfo->comment = NULL;
2007 +      }
2008 +    }
2009 +    return read_anything;
2010 +  }
2011 +
2012 +  png_init_io(png_ptr, fp);
2013 +  png_read_info(png_ptr, info_ptr);
2014 +
2015 +  pinfo->w = pinfo->normw = info_ptr->width;
2016 +  pinfo->h = pinfo->normh = info_ptr->height;
2017 +
2018 +  pinfo->frmType = F_PNG;
2019 +
2020 +  sprintf(pinfo->fullInfo, "PNG, %d bit ",
2021 +          info_ptr->bit_depth * info_ptr->channels);
2022 +
2023 +  switch(info_ptr->color_type) {
2024 +    case PNG_COLOR_TYPE_PALETTE:
2025 +      strcat(pinfo->fullInfo, "palette color");
2026 +      break;
2027 +
2028 +    case PNG_COLOR_TYPE_GRAY:
2029 +      strcat(pinfo->fullInfo, "grayscale");
2030 +      break;
2031 +
2032 +    case PNG_COLOR_TYPE_GRAY_ALPHA:
2033 +      strcat(pinfo->fullInfo, "grayscale+alpha");
2034 +      break;
2035 +
2036 +    case PNG_COLOR_TYPE_RGB:
2037 +      strcat(pinfo->fullInfo, "truecolor");
2038 +      break;
2039 +
2040 +    case PNG_COLOR_TYPE_RGB_ALPHA:
2041 +      strcat(pinfo->fullInfo, "truecolor+alpha");
2042 +      break;
2043 +  }
2044 +
2045 +  sprintf(pinfo->fullInfo + strlen(pinfo->fullInfo),
2046 +         ", %sinterlaced. (%d bytes)",
2047 +         info_ptr->interlace_type ? "" : "non-", filesize);
2048 +
2049 +  sprintf(pinfo->shrtInfo, "%dx%d PNG", info_ptr->width, info_ptr->height);
2050 +
2051 +  if (info_ptr->bit_depth < 8)
2052 +      png_set_packing(png_ptr);
2053 +
2054 +  if (info_ptr->valid & PNG_INFO_gAMA)
2055 +    png_set_gamma(png_ptr, Display_Gamma, info_ptr->gamma);
2056 +  else
2057 +    png_set_gamma(png_ptr, Display_Gamma, 0.45);
2058 +
2059 +  if (info_ptr->valid & PNG_INFO_bKGD)
2060 +    png_set_background(png_ptr, &info_ptr->background,
2061 +                       PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
2062 +  else {
2063 +    my_background.red = my_background.green = my_background.blue =
2064 +      my_background.gray = 0;
2065 +    png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN,
2066 +                       0, Display_Gamma);
2067 +  }
2068 +
2069 +  if (info_ptr->bit_depth == 16)
2070 +    png_set_strip_16(png_ptr);
2071 +
2072 +  if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
2073 +      info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
2074 +  {
2075 +    if (info_ptr->bit_depth == 1)
2076 +      pinfo->colType = F_BWDITHER;
2077 +    else
2078 +      pinfo->colType = F_GREYSCALE;
2079 +    png_set_expand(png_ptr);
2080 +  }
2081 +
2082 +  pass=png_set_interlace_handling(png_ptr);
2083 +
2084 +  png_read_update_info(png_ptr, info_ptr);
2085 +
2086 +  if(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
2087 +     info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
2088 +    linesize = pinfo->w * 3;
2089 +    pinfo->colType = F_FULLCOLOR;
2090 +    pinfo->type = PIC24;
2091 +  } else {
2092 +    linesize = pinfo->w;
2093 +    pinfo->type = PIC8;
2094 +    if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
2095 +       info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
2096 +      for(i = 0; i < 256; i++)
2097 +        pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
2098 +    } else {
2099 +      pinfo->colType = F_FULLCOLOR;
2100 +      for(i = 0; i < info_ptr->num_palette; i++) {
2101 +        pinfo->r[i] = info_ptr->palette[i].red;
2102 +        pinfo->g[i] = info_ptr->palette[i].green;
2103 +        pinfo->b[i] = info_ptr->palette[i].blue;
2104 +      }
2105 +    }
2106 +  }
2107 +  pinfo->pic = calloc((size_t)(linesize*pinfo->h), (size_t)1);
2108 +
2109 +  if(!pinfo->pic) {
2110 +    png_error(png_ptr, "can't allocate space for PNG image");
2111 +  }
2112 +
2113 +  png_start_read_image(png_ptr);
2114 +
2115 +  for(i = 0; i < pass; i++) {
2116 +    byte *p = pinfo->pic;
2117 +    for(j = 0; j < pinfo->h; j++) {
2118 +      png_read_row(png_ptr, p, NULL);
2119 +      read_anything = 1;
2120 +      if((j & 0x1f) == 0) WaitCursor();
2121 +      p += linesize;
2122 +    }
2123 +  }
2124 +
2125 +  png_read_end(png_ptr, info_ptr);
2126 +
2127 +  if(info_ptr->num_text > 0) {
2128 +    commentsize = 1;
2129 +
2130 +    for(i = 0; i < info_ptr->num_text; i++)
2131 +      commentsize += strlen(info_ptr->text[i].key) + 1 +
2132 +                     info_ptr->text[i].text_length + 2;
2133 +
2134 +    if((pinfo->comment = malloc(commentsize)) == NULL) {
2135 +      png_warning(png_ptr,"can't allocate comment string");
2136 +    }
2137 +    else {
2138 +      pinfo->comment[0] = '\0';
2139 +      for(i = 0; i < info_ptr->num_text; i++) {
2140 +        strcat(pinfo->comment, info_ptr->text[i].key);
2141 +        strcat(pinfo->comment, "::");
2142 +        strcat(pinfo->comment, info_ptr->text[i].text);
2143 +        strcat(pinfo->comment, "\n");
2144 +      }
2145 +    }
2146 +  }
2147 +
2148 +  png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
2149 +
2150 +  fclose(fp);
2151 +
2152 +  return 1;
2153 +}
2154 +
2155 +
2156 +/*******************************************/
2157 +static void
2158 +png_xv_error(png_ptr, message)
2159 +     png_struct *png_ptr;
2160 +     char *message;
2161 +{
2162 +  SetISTR(ISTR_WARNING,"%s:  libpng error: %s", fbasename, message);
2163 +
2164 +  longjmp(png_ptr->jmpbuf, 1);
2165 +}
2166 +
2167 +
2168 +/*******************************************/
2169 +static void
2170 +png_xv_warning(png_ptr, message)
2171 +     png_struct *png_ptr;
2172 +     char *message;
2173 +{
2174 +  if (!png_ptr)
2175 +    return;
2176 +
2177 +  SetISTR(ISTR_WARNING,"%s:  libpng warning: %s", fbasename, message);
2178 +}
2179 +
2180 +#endif
2181 diff -uNr xvpopup.c xvpopup.c
2182 --- ./xvpopup.c Thu Jan 19 19:09:31 1995
2183 +++ ./xvpopup.c Tue Feb 20 17:04:44 2001
2184 @@ -200,14 +200,14 @@
2185      
2186      if (!padHaveDooDads) {
2187        DCreate(&padWDial, popW, 16,      puhigh-16-100-1,75,100,
2188 -             1, 2048, pWIDE, 10,
2189 +             1.0, 2048.0, (double)pWIDE, 1.0, 10.0,
2190               infofg, infobg, hicol, locol, "Width", NULL);
2191        DCreate(&padHDial, popW, 16+1+75, puhigh-16-100-1,75,100,
2192 -             1, 2048, pHIGH, 10,
2193 +             1.0, 2048.0, (double)pHIGH, 1.0, 10.0,
2194               infofg, infobg, hicol, locol, "Height", NULL);
2195  
2196        DCreate(&padODial, popW, 16+1+75+75+9, puhigh-16-100-1,75,100,
2197 -             0, 100, 100, 10,
2198 +             0.0, 100.0, 100.0, 1.0, 10.0,
2199               infofg, infobg, hicol, locol, "Opaque", NULL);
2200  
2201        MBCreate(&padMthdMB, popW, 100-2+44, 10, 140, 19, NULL,
2202 @@ -258,9 +258,9 @@
2203    else if (poptyp == ISPAD) {
2204      BTSetActive(&bts[0], (int) strlen(gsBuf));
2205      i = pWIDE * 3;  RANGE(i,2048,9999);  
2206 -    DSetRange(&padWDial, 1, i, padWDial.val, 10);
2207 +    DSetRange(&padWDial, 1.0, (double)i, padWDial.val, 1.0, 10.0);
2208      i = pHIGH * 3;  RANGE(i,2048,9999);  
2209 -    DSetRange(&padHDial, 1, i, padHDial.val, 10);
2210 +    DSetRange(&padHDial, 1.0, (double)i, padHDial.val, 1.0, 10.0);
2211  
2212      DSetActive(&padWDial, (padMode!=PAD_LOAD));  /* DSetRange activates dial */
2213      DSetActive(&padHDial, (padMode!=PAD_LOAD));
2214 @@ -465,9 +465,9 @@
2215    changedGSBuf();      /* careful!  popW doesn't exist yet! */
2216  
2217    if (padHaveDooDads) { 
2218 -    oldW = padWDial.val;  
2219 -    oldH = padHDial.val;
2220 -    oldO = padODial.val;
2221 +    oldW = (int)padWDial.val;  
2222 +    oldH = (int)padHDial.val;
2223 +    oldO = (int)padODial.val;
2224    }
2225    else { oldW = pWIDE;  oldH = pHIGH;  oldO = 100; }
2226  
2227 @@ -486,9 +486,9 @@
2228    }
2229  
2230    if (rv == 1) {   /* cancelled:  restore normal values */
2231 -    DSetVal(&padWDial, oldW);
2232 -    DSetVal(&padHDial, oldH);
2233 -    DSetVal(&padODial, oldO);
2234 +    DSetVal(&padWDial, (double)oldW);
2235 +    DSetVal(&padHDial, (double)oldH);
2236 +    DSetVal(&padODial, (double)oldO);
2237    }
2238  
2239    XUnmapWindow(theDisp, padWDial.win);
2240 @@ -498,9 +498,9 @@
2241    /* load up return values */
2242    *pMode   = padMode;  
2243    *pStr    = padBuf;  
2244 -  *pWide   = padWDial.val;
2245 -  *pHigh   = padHDial.val;
2246 -  *pOpaque = padODial.val;
2247 +  *pWide   = (int)padWDial.val;
2248 +  *pHigh   = (int)padHDial.val;
2249 +  *pOpaque = (int)padODial.val;
2250    *pOmode  = padOMode;
2251  
2252    return rv;
2253 @@ -972,8 +972,8 @@
2254    else if (popUp == ISPAD) {
2255      if (PTINRECT(x, y, padDButt.x, padDButt.y, padDButt.w, padDButt.h)) {
2256        if (BTTrack(&padDButt)) {
2257 -       DSetVal(&padWDial, pWIDE);
2258 -       DSetVal(&padHDial, pHIGH);
2259 +       DSetVal(&padWDial, (double)pWIDE);
2260 +       DSetVal(&padHDial, (double)pHIGH);
2261        }
2262      }
2263  
2264 diff -uNr xvps.c xvps.c
2265 --- ./xvps.c    Thu Dec 22 23:34:42 1994
2266 +++ ./xvps.c    Tue Feb 20 17:04:44 2001
2267 @@ -139,9 +139,9 @@
2268    CBCreate(&encapsCB, psW, 240, 7, "preview", infofg, infobg, hicol, locol);
2269    CBCreate(&pscompCB, psW, 331, 7, "compress", infofg, infobg, hicol, locol);
2270  
2271 -  DCreate(&xsDial, psW, 240, 30, 80, 100, 10, 800, 100, 5, 
2272 +  DCreate(&xsDial, psW, 240, 30, 80, 100, 10.0, 800.0, 100.0, 0.5, 5.0, 
2273           infofg, infobg, hicol, locol, "Width", "%");
2274 -  DCreate(&ysDial, psW, 331, 30, 80, 100, 10, 800, 100, 5, 
2275 +  DCreate(&ysDial, psW, 331, 30, 80, 100, 10.0, 800.0, 100.0, 0.5, 5.0, 
2276           infofg, infobg, hicol, locol, "Height", "%");
2277    xsDial.drawobj = changedScale;
2278    ysDial.drawobj = changedScale;
2279 @@ -236,10 +236,10 @@
2280  
2281    if (rd_int("psres")) {             /* xv.psres:  default paper resolution */
2282      if (def_int >= 10 && def_int <= 720) {
2283 -      int i = (int) ((PIX2INCH * 100) / def_int);
2284 +      double v = (PIX2INCH * 100) / def_int;
2285  
2286 -      DSetVal(&xsDial, i);
2287 -      DSetVal(&ysDial, i);
2288 +      DSetVal(&xsDial, v);
2289 +      DSetVal(&ysDial, v);
2290      }
2291    }
2292  
2293 @@ -836,7 +836,7 @@
2294    if (scx < scy) { sz_iny = h * scx; }
2295              else { sz_inx = w * scy; }
2296  
2297 -  DSetVal(&xsDial, (int) ((100 * (sz_inx * PIX2INCH) / w) + .5));
2298 +  DSetVal(&xsDial, 100 * (sz_inx * PIX2INCH) / w);
2299    DSetVal(&ysDial, xsDial.val);
2300  
2301    sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0);  
2302 diff -uNr xvtiff.c xvtiff.c
2303 --- ./xvtiff.c  Fri Jan 13 20:53:34 1995
2304 +++ ./xvtiff.c  Tue Feb 20 17:50:02 2001
2305 @@ -12,7 +12,7 @@
2306  
2307  #ifdef HAVE_TIFF
2308  
2309 -#include "tiffio.h"     /* has to be after xv.h, as it needs varargs/stdarg */
2310 +#include <tiffio.h>     /* has to be after xv.h, as it needs varargs/stdarg */
2311  
2312  
2313  static byte *loadPalette PARM((TIFF *, uint32, uint32, int, int, PICINFO *));
2314 @@ -186,7 +186,7 @@
2315      break;
2316    }
2317  
2318 -  sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
2319 +  sprintf(pinfo->shrtInfo, "%lux%lu TIFF.",w,h);
2320  
2321    pic8 = (byte *) malloc((size_t) w*h);
2322    if (!pic8) FatalError("loadPalette() - couldn't malloc 'pic8'");
2323 @@ -214,7 +214,7 @@
2324            "???"),
2325           filesize);
2326  
2327 -  sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
2328 +  sprintf(pinfo->shrtInfo, "%lux%lu TIFF.",w,h);
2329  
2330    /* allocate 24-bit image */
2331    pic24 = (byte *) malloc((size_t) w*h*3);
2332 @@ -301,10 +301,10 @@
2333  static byte **BWmap;
2334  static byte **PALmap;
2335  
2336 -typedef void (*tileContigRoutine)   PARM((byte*, u_char*, RGBvalue*, 
2337 +typedef void (*xvtileContigRoutine)   PARM((byte*, u_char*, RGBvalue*, 
2338                                           uint32, uint32, int, int));
2339  
2340 -typedef void (*tileSeparateRoutine) PARM((byte*, u_char*, u_char*, u_char*, 
2341 +typedef void (*xvtileSeparateRoutine) PARM((byte*, u_char*, u_char*, u_char*, 
2342                                           RGBvalue*, uint32, uint32, int, int));
2343  
2344  
2345 @@ -366,8 +366,8 @@
2346  static void   putcontig8bitYCbCrtile  PARM((byte *, u_char *, RGBvalue *,
2347                                           uint32, uint32, int, int));
2348  
2349 -static tileContigRoutine   pickTileContigCase   PARM((RGBvalue *));
2350 -static tileSeparateRoutine pickTileSeparateCase PARM((RGBvalue *));
2351 +static xvtileContigRoutine   pickTileContigCase   PARM((RGBvalue *));
2352 +static xvtileSeparateRoutine pickTileSeparateCase PARM((RGBvalue *));
2353  
2354  
2355  /*******************************************/
2356 @@ -641,7 +641,7 @@
2357    u_char *buf;
2358    int fromskew, toskew;
2359    u_int nrow;
2360 -  tileContigRoutine put;
2361 +  xvtileContigRoutine put;
2362  
2363    put = pickTileContigCase(Map);
2364    if (put == 0) return (0);
2365 @@ -708,7 +708,7 @@
2366    int tilesize;
2367    int fromskew, toskew;
2368    u_int nrow;
2369 -  tileSeparateRoutine put;
2370 +  xvtileSeparateRoutine put;
2371    
2372    put = pickTileSeparateCase(Map);
2373    if (put == 0) return (0);
2374 @@ -779,7 +779,7 @@
2375  {
2376    uint32 row, y, nrow;
2377    u_char *buf;
2378 -  tileContigRoutine put;
2379 +  xvtileContigRoutine put;
2380    uint32 rowsperstrip;
2381    uint32 imagewidth;
2382    int scanline;
2383 @@ -832,7 +832,7 @@
2384    u_char *r, *g, *b;
2385    uint32 row, y, nrow;
2386    int scanline;
2387 -  tileSeparateRoutine put;
2388 +  xvtileSeparateRoutine put;
2389    uint32 rowsperstrip;
2390    uint32 imagewidth;
2391    u_int stripsize;
2392 @@ -1065,7 +1065,7 @@
2393       int fromskew, toskew;
2394  {
2395    while (h-- > 0) {
2396 -    UNROLL8(w,0, *cp++ = PALmap[*pp++][0]);
2397 +    UNROLL8(w,, *cp++ = PALmap[*pp++][0]);
2398      cp += toskew;
2399      pp += fromskew;
2400    }
2401 @@ -1262,7 +1262,7 @@
2402      }
2403    } else {
2404      while (h-- > 0) {
2405 -      UNROLL8(w,0,
2406 +      UNROLL8(w,,
2407               *cp++ = pp[0];
2408               *cp++ = pp[1];
2409               *cp++ = pp[2];
2410 @@ -1335,7 +1335,7 @@
2411      }
2412    } else {
2413      while (h-- > 0) {
2414 -      UNROLL8(w,0,
2415 +      UNROLL8(w,,
2416               *cp++ = *r++;
2417               *cp++ = *g++;
2418               *cp++ = *b++;
2419 @@ -1489,16 +1489,16 @@
2420  /*
2421   * Select the appropriate conversion routine for packed data.
2422   */
2423 -static tileContigRoutine pickTileContigCase(Map)
2424 +static xvtileContigRoutine pickTileContigCase(Map)
2425       RGBvalue* Map;
2426  {
2427 -  tileContigRoutine put = 0;
2428 +  xvtileContigRoutine put = 0;
2429    
2430    switch (photometric) {
2431    case PHOTOMETRIC_RGB:
2432      switch (bitspersample) {
2433 -    case 8:  put = (tileContigRoutine) putRGBcontig8bittile;   break;
2434 -    case 16: put = (tileContigRoutine) putRGBcontig16bittile;  break;
2435 +    case 8:  put = putRGBcontig8bittile;   break;
2436 +    case 16: put = (xvtileContigRoutine)putRGBcontig16bittile;  break;
2437      }
2438      break;
2439      
2440 @@ -1540,16 +1540,16 @@
2441   * NB: we assume that unpacked single channel data is directed
2442   *      to the "packed routines.
2443   */
2444 -static tileSeparateRoutine pickTileSeparateCase(Map)
2445 +static xvtileSeparateRoutine pickTileSeparateCase(Map)
2446       RGBvalue* Map;
2447  {
2448 -  tileSeparateRoutine put = 0;
2449 +  xvtileSeparateRoutine put = 0;
2450    
2451    switch (photometric) {
2452    case PHOTOMETRIC_RGB:
2453      switch (bitspersample) {
2454 -    case  8: put = (tileSeparateRoutine) putRGBseparate8bittile;  break;
2455 -    case 16: put = (tileSeparateRoutine) putRGBseparate16bittile; break;
2456 +    case  8: put = (xvtileSeparateRoutine) putRGBseparate8bittile;  break;
2457 +    case 16: put = (xvtileSeparateRoutine) putRGBseparate16bittile; break;
2458      }
2459      break;
2460    }
2461 diff -uNr xvtiffwr.c xvtiffwr.c
2462 --- ./xvtiffwr.c        Tue Jan  3 22:28:13 1995
2463 +++ ./xvtiffwr.c        Tue Feb 20 17:50:12 2001
2464 @@ -9,7 +9,7 @@
2465  
2466  #ifdef HAVE_TIFF
2467  
2468 -#include "tiffio.h"    /* has to be after xv.h, as it needs varargs/stdarg */
2469 +#include <tiffio.h>    /* has to be after xv.h, as it needs varargs/stdarg */
2470  
2471  
2472  #define ALLOW_JPEG 0  /* set to '1' to allow 'JPEG' choice in dialog box */