1 diff -uNr Makefile Makefile
2 --- Makefile Mon Jan 23 21:20:54 1995
3 +++ Makefile Tue Feb 20 17:48:33 2001
7 ### Installation locations
8 -BINDIR = /usr/local/bin
9 -MANDIR = /usr/local/man/man1
11 +MANDIR = /usr/man/man1
13 -LIBDIR = /usr/local/lib
19 ### if, for whatever reason, you're unable to get the JPEG library to compile
20 ### on your machine, *COMMENT OUT* the following lines
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
35 +### if, for whatever reason, you're unable to get the PNG library to compile
36 +### on your machine, *COMMENT OUT* the following lines
43 +### if, for whatever reason, you're unable to get the PNG library to compile
44 +### on your machine, *COMMENT OUT* the following lines
50 ### if, for whatever reason, you're unable to get the TIFF library to compile
51 ### on your machine, *COMMENT OUT* the following lines
55 -TIFFINC = -I$(TIFFDIR)
56 -TIFFLIB = $(TIFFDIR)/libtiff.a
58 - ( cd $(TIFFDIR) ; make CC='$(CC)' )
68 -CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
69 +CFLAGS = $(CCOPTS) $(JPEG) $(TIFF) $(PDS) \
70 $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
72 + $(DXWM) $(MCHN) $(PNG)
74 -LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
75 +LIBS = -lX11 -L/usr/X11/lib $(JPEGLIB) $(TIFFLIB) $(PNGLIB) $(ZLIBLIB) -lm
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 \
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 \
84 + xvxwd.o xvfits.o xvpng.o
86 MISC = README INSTALL CHANGELOG IDEAS
92 -all: $(JPEGLIB) $(TIFFLIB) xv bggen vdcomp xcmap xvpictoppm
93 +all: xv bggen vdcomp xcmap xvpictoppm
96 -xv: $(OBJS) $(JPEGLIB) $(TIFFLIB)
98 $(CC) -o xv $(CFLAGS) $(OBJS) $(LIBS)
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
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
117 +### if, for whatever reason, you're unable to get the PNG library to compile
118 +### on your machine, *COMMENT OUT* the following lines
121 +PNGDIR = /usr/local/src/libpng
122 +PNGINC = -I$(PNGDIR)
123 +PNGLIB = -L$(PNGDIR) -lpng
127 +### if, for whatever reason, you're unable to get the PNG library to compile
128 +### on your machine, *COMMENT OUT* the following lines
130 +ZLIBDIR = /usr/local/src/zlib
131 +ZLIBINC = -I$(ZLIBDIR)
132 +ZLIBLIB = -L$(ZLIBDIR) -lz
136 ### if, for whatever reason, you're unable to get the TIFF library to compile
137 ### on your machine, *COMMENT OUT* the following lines
141 CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
142 $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
144 + $(DXWM) $(MCHN) $(PNG) $(PNGINC) $(ZLIBINC)
146 -LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
147 +LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) $(PNGLIB) $(ZLIBLIB) -lm
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 \
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 \
156 + xvxwd.o xvfits.o xvpng.o
158 MISC = README INSTALL CHANGELOG IDEAS
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
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
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,
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
205 * definition appropriately. (use 'which gunzip' to find if you have gunzip,
206 * and where it lives)
213 # define GUNZIP "UNCOMPRESS"
215 -# define GUNZIP "/usr/local/bin/gunzip -q"
216 +# define GUNZIP "/bin/gunzip -q"
221 * should not need to be changed
224 -/* #define GS_PATH "/usr/local/bin/gs" */
225 -/* #define GS_LIB "." */
226 -/* #define GS_DEV "ppmraw" */
227 +#define GS_PATH "/usr/bin/gs"
229 +#define GS_DEV "ppmraw"
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
237 nxcells = nycells = 8;
238 else if (dispcells>4)
239 nxcells = nycells = 4;
241 + else if (dispcells>2)
242 nxcells = nycells = 2;
249 /**************** Create/Open X Resources ***************/
250 if ((mfinfo = XLoadQueryFont(theDisp,FONT))==NULL) {
251 @@ -267,18 +272,25 @@
254 i=XParseGeometry(geom,&x,&y,&w,&h);
255 - if (i&WidthValue) WIDE = (int) w;
256 - if (i&HeightValue) HIGH = (int) h;
258 - if (i&XValue || i&YValue) hints.flags = USPosition;
259 - else hints.flags = PPosition;
261 - hints.flags |= USSize;
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);
270 + hints.flags |= USSize;
275 + hints.flags |= USSize;
278 + if (i&XValue || i&YValue)
281 + x = XDisplayWidth(theDisp,theScreen)-WIDE-abs(x);
283 + y = XDisplayHeight(theDisp,theScreen)-HIGH-abs(y);
284 + hints.flags |= USPosition;
287 hints.x=x; hints.y=y;
288 hints.width = WIDE; hints.height = HIGH;
290 --- xv.c Thu Jan 19 19:08:43 1995
291 +++ xv.c Tue Feb 20 17:04:44 2001
293 tiffW = (Window) NULL; tiffUp = 0;
297 + pngW = (Window) NULL; pngUp = 0;
300 imap = ctrlmap = gmap = browmap = cmtmap = 0;
302 ch_offx = ch_offy = p_offx = p_offy = 0;
304 XSetTransientForHint(theDisp, tiffW, dirW);
309 + XSetTransientForHint(theDisp, pngW, dirW);
314 @@ -2611,6 +2619,11 @@
315 (magicno[0]=='I' && magicno[1]=='I')) rv = RFT_TIFF;
319 + else if (magicno[0]==0x89 && magicno[1]=='P' &&
320 + magicno[2]=='N' && magicno[3]=='G') rv = RFT_PNG;
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 @@
329 case RFT_TIFF: rv = LoadTIFF (fname, pinfo); break;
333 + case RFT_PNG: rv = LoadPNG (fname, pinfo); break;
338 --- ./xv.h Mon Jan 23 21:22:23 1995
339 +++ ./xv.h Tue Feb 20 17:10:11 2001
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)"
350 * uncomment the following, and modify for your site, but only if you've
353 extern int errno; /* SHOULD be in errno.h, but often isn't */
355 - extern char *sys_errlist[]; /* this too... */
356 +// extern char *sys_errlist[]; /* this too... */
371 @@ -458,24 +462,31 @@
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 */
423 /* definitions for page up/down, arrow up/down list control */
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 @@
444 +/* stuff used for 'png' box */
446 +WHERE int pngUp; /* is pngW mapped, or what? */
453 @@ -1465,12 +1485,12 @@
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 *));
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));
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));
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
489 #include "bits/br_xpm"
490 #include "bits/br_xwd"
491 #include "bits/br_fits"
492 +#include "bits/br_png"
494 #include "bits/br_trash"
495 #include "bits/fcurs"
500 -#define BF_MAX 28 /* # of built-in icons */
502 +#define BF_MAX 29 /* # of built-in icons */
504 #define ISLOADABLE(ftyp) (ftyp!=BF_DIR && ftyp!=BF_CHR && ftyp!=BF_BLK && \
505 ftyp!=BF_SOCK && ftyp!=BF_FIFO)
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);
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;
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;
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
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 *));
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)
557 -int x,y,w,h,minv,maxv,curv,page;
559 +double minv,maxv,curv,inc,page;
560 unsigned long fg,bg,hi,lo;
565 if (!dp->win) FatalError("can't create dial window");
567 - DSetRange(dp, minv, maxv, curv, page);
568 + DSetRange(dp, minv, maxv, curv, inc, page);
569 XSelectInput(theDisp, dp->win, ExposureMask | ButtonPressMask);
573 /***************************************************/
574 -void DSetRange(dp, minv, maxv, curv, page)
576 -int minv, maxv, curv, page;
577 +void DSetRange(dp, minv, maxv, curv, inc, page)
579 +double minv, maxv, curv, inc, page;
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);
589 /***************************************************/
590 void DSetVal(dp, curv)
596 RANGE(curv, dp->min, dp->max); /* make sure curv is in-range */
599 XSetForeground(theDisp, theGC, dp->bg);
603 + dp->val = (double)((int)(curv / dp->inc + (curv > 0 ? 0.5 : -0.5))) * dp->inc;
605 /* draw new arrow and string */
606 XSetForeground(theDisp, theGC, dp->fg);
611 - int rx,ry, x,y, ipos, pos, lit, i, origval;
612 + int rx, ry, x, y, ipos, pos, lit;
618 if (ipos != INDIAL) {
619 drawButt(dp, ipos, 1);
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;
628 if (dp->drawobj != NULL) (dp->drawobj)();
633 - i = computeDialVal(dp, mx, my);
636 + v = computeDialVal(dp, mx, my);
638 if (dp->drawobj != NULL) (dp->drawobj)();
641 @@ -246,11 +249,11 @@
642 if (!(mask & Button1Mask)) break; /* button released */
644 if (ipos == INDIAL) {
646 - i = computeDialVal(dp, x, y);
649 - if (j != dp->val) {
651 + v = computeDialVal(dp, x, y);
654 + if (w != dp->val) {
655 /* track whatever dial controls */
656 if (dp->drawobj != NULL) (dp->drawobj)();
658 @@ -266,11 +269,11 @@
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);
665 case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page);
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);
670 case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page);
672 @@ -320,19 +323,20 @@
673 static void drawArrow(dp)
676 - int i, rad, cx, cy;
681 rad = dp->rad; cx = dp->cx; cy = dp->cy;
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)
706 + int tot, i, x1, x2;
707 char foo[60], foo1[60];
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);
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 */
723 + if (dp->min < 0.0 && dp->max > 0.0) sprintf(foo,"%+g", dp->val);
724 + else sprintf(foo,"%g", dp->val);
730 + if (dp->val == (double)((int)dp->val))
733 + for (j = strlen(foo); j < tot; j++)
737 if (dp->units) strcat(foo,dp->units);
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," ");
745 @@ -411,12 +429,13 @@
748 /***************************************************/
749 -static int computeDialVal(dp, x, y)
750 +static double computeDialVal(dp, x, y)
760 /* compute dx, dy (distance from cx, cy). Note: +dy is *up* */
761 dx = x - dp->cx; dy = dp->cy - y;
763 if (angle > 270.0) angle -= 360.0;
764 if (angle < -90.0) angle += 360.0;
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;
769 + /* round value to be an even multiple of dp->inc */
770 + val = (double)((int)(val / dp->inc + 0.5)) * dp->inc;
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
786 "PBM/PGM/PPM (ascii)",
787 @@ -1115,6 +1118,15 @@
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' */
803 @@ -1168,7 +1180,8 @@
806 rv = WriteXPM (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
807 - fullname, picComments);
808 + fullname, picComments);
811 rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
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) ||
821 (strcmp(lowsuf,"jpg" )==0) ||
822 (strcmp(lowsuf,"jpeg")==0) ||
823 (strcmp(lowsuf,"jfif")==0) ||
826 (strcmp(lowsuf,"tif" )==0) ||
827 - (strcmp(lowsuf,"tiff")==0)) {
828 + (strcmp(lowsuf,"tiff")==0) ||
831 + (strcmp(lowsuf,"png" )==0) ||
833 + (strcmp(lowsuf,"xpm" )==0)) {
835 /* found one. set lowsuf = to the new suffix, and tack on to filename */
837 @@ -1422,6 +1442,10 @@
840 case F_TIFF: strcpy(lowsuf,"tif"); break;
844 + case F_PNG: strcpy(lowsuf,"png"); break;
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
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;
858 static int mainWKludge=0; /* force first mainW expose after a mainW config
859 to redraw all of mainW */
861 if (TIFFCheckEvent(event)) break; /* event has been processed */
865 + if (PNGCheckEvent (event)) break; /* event has been processed */
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 */
872 else if (client_event->window == tiffW) TIFFDialog(0);
876 + else if (client_event->window == pngW) PNGDialog(0);
879 else if (client_event->window == mainW) Quit(0);
884 if (wasTiffUp) { TIFFDialog(wasTiffUp); wasTiffUp=0; }
888 + if (wasPngUp) { PNGDialog(wasJpegUp); wasPngUp=0; }
895 if (tiffUp) { wasTiffUp = tiffUp; TIFFDialog(0); }
899 + if (pngUp) { wasPngUp = pngUp; PNGDialog(0); }
904 @@ -1147,6 +1163,10 @@
905 if (TIFFCheckEvent(event)) break;
909 + if (PNGCheckEvent (event)) break;
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;
920 + if (PNGCheckEvent (event)) break;
923 if (GamCheckEvent (event)) break;
924 if (BrowseCheckEvent (event, &retval, &done)) break;
925 if (TextCheckEvent (event, &retval, &done)) break;
926 @@ -2370,6 +2394,10 @@
929 if (tiffUp) TIFFDialog(0); /* close tiff window */
933 + if (pngUp) PNGDialog(0); /* close png window */
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);
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);
954 rhDial.drawobj = gsDial.drawobj = bvDial.drawobj = dragEditColor;
957 srcHD.drawobj = dstHD.drawobj = whtHD.drawobj = dragHueDial;
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", "%");
963 hueRB = RBCreate(NULL, hsvF, 7, 153, "1",
966 if (whtHD.enabCB.val && whtHD.satval) hsvnonlinear++;
968 - if (satDial.val != 0) hsvnonlinear++;
969 + if (satDial.val != 0.0) hsvnonlinear++;
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);
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);
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]);
994 @@ -1310,16 +1310,15 @@
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;
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;
1015 @@ -1561,9 +1560,9 @@
1016 gsDial.title = "Green";
1017 bvDial.title = "Blue";
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);
1026 XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial);
1027 XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial);
1028 @@ -1581,9 +1580,9 @@
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);
1039 XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial);
1040 XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial);
1041 @@ -1891,7 +1890,7 @@
1044 /* apply satDial value to s */
1045 - s = s + ((double) satDial.val) / 100.0;
1046 + s = s + satDial.val / 100.0;
1050 @@ -2007,7 +2006,7 @@
1052 gs->hueRBnum = RBWhich(hueRB);
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 @@
1063 - if (gs->satval != satDial.val) {
1064 - DSetVal(&satDial,gs->satval);
1065 + if (gs->satval != (int)satDial.val) {
1066 + DSetVal(&satDial,(double)gs->satval);
1070 @@ -3200,7 +3199,7 @@
1072 if (whtHD.enabCB.val && whtHD.satval) hsvmod++;
1074 - if (satDial.val != 0) hsvmod++;
1075 + if (satDial.val != 0.0) hsvmod++;
1077 /* check intensity graf */
1078 for (i=0; i<256; i++) {
1079 @@ -3284,7 +3283,7 @@
1082 /* apply satDial value to s */
1083 - s = s + satDial.val;
1084 + s = s + (int)satDial.val;
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
1095 -#include "jpeglib.h"
1096 -#include "jerror.h"
1097 +#include <jpeglib.h>
1098 +#include <jerror.h>
1100 #define CREATOR_STR "CREATOR: "
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));
1120 XSelectInput(theDisp, jpegW, ExposureMask | ButtonPressMask | KeyPressMask);
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", "%");
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", "%");
1130 BTCreate(&jbut[J_BOK], jpegW, JWIDE-180-1, JHIGH-10-BUTTH-1, 80, BUTTH,
1134 /**************************************************/
1135 -METHODDEF void xv_error_exit(cinfo)
1136 +METHODDEF (void) xv_error_exit(cinfo)
1143 /**************************************************/
1144 -METHODDEF void xv_error_output(cinfo)
1145 +METHODDEF (void) xv_error_output(cinfo)
1152 /**************************************************/
1153 -METHODDEF void xv_prog_meter(cinfo)
1154 +METHODDEF (void) xv_prog_meter(cinfo)
1157 struct jpeg_progress_mgr *prog;
1161 /**************************************************/
1162 -METHODDEF boolean xv_process_comment(cinfo)
1163 +METHODDEF (boolean) xv_process_comment(cinfo)
1164 j_decompress_ptr cinfo;
1166 int length, hasnull;
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;
1177 jpeg_start_compress(&cinfo, TRUE);
1179 /*** COMMENT HANDLING ***/
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);
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);
1195 + if (pngW) XDestroyWindow(theDisp, pngW);
1198 /* if NOT using stdcmap for images, free stdcmap */
1199 if (colorMapMode != CM_STDCMAP) {
1201 @@ -715,6 +719,10 @@
1204 if (tiffW) XDefineCursor(theDisp, tiffW, otherc);
1208 + if (pngW) XDefineCursor(theDisp, pngW, otherc);
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
1217 + * xvpng.c - load and write routines for 'PNG' format pictures
1219 + * callable functions
1223 + * PNGCheckEvent(xev)
1224 + * PNGSaveParams(fname, col)
1225 + * LoadPNG(fname, pinfo)
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
1245 +/*** Stuff for PNG Dialog box ***/
1249 +#define DISPLAY_GAMMA 2.20 /* Default display gamma */
1250 +/* Default zlib compression level
1251 +#define COMPRESSION Z_BEST_COMPRESSION
1253 +#define COMPRESSION 6
1257 +#define PFX PWIDE-93
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));
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));
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;
1285 +static DIAL cDial, gDial;
1286 +static BUTT pbut[P_NBUTTS];
1287 +static CBUTT interCB;
1288 +static CBUTT FdefCB, FnoneCB, FsubCB, FupCB, FavgCB, FPaethCB;
1290 +/**************************************************************************/
1291 +/* PNG SAVE DIALOG ROUTINES ***********************************************/
1292 +/**************************************************************************/
1295 +/*******************************************/
1298 + pngW = CreateWindow("xv png", "XVPNG", NULL,
1299 + PWIDE, PHIGH, infofg, infobg, 0);
1300 + if (!pngW) FatalError("can't create PNG window!");
1302 + XSelectInput(theDisp, pngW, ExposureMask | ButtonPressMask | KeyPressMask);
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);
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);
1311 + CBCreate(&interCB, pngW, DWIDE+30, DHIGH+3*LINEHIGH+2, "interlace",
1312 + infofg, infobg, hicol, locol);
1314 + CBCreate(&FdefCB, pngW, PFX, PFY, "Default",
1315 + infofg, infobg, hicol, locol);
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);
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);
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);
1341 + XMapSubwindows(theDisp, pngW);
1345 +/*******************************************/
1346 +void PNGDialog(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,
1354 + else XUnmapWindow(theDisp, pngW);
1359 +/*******************************************/
1360 +int PNGCheckEvent(xev)
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' */
1369 + if (!pngUp) return 0;
1371 + if (xev->type == Expose) {
1373 + XExposeEvent *e = (XExposeEvent *) xev;
1374 + x = e->x; y = e->y; w = e->width; h = e->height;
1376 + /* throw away excess expose events for 'dumb' windows */
1377 + if (e->count > 0 && (e->window == cDial.win)) {}
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);
1385 + else if (xev->type == ButtonPress) {
1386 + XButtonEvent *e = (XButtonEvent *) xev;
1388 + x = e->x; y = e->y;
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);
1397 + } /* button press */
1399 + else if (xev->type == KeyPress) {
1400 + XKeyEvent *e = (XKeyEvent *) xev;
1401 + char buf[128]; KeySym ks;
1404 + stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL);
1405 + buf[stlen] = '\0';
1407 + RemapKeyCheck(ks, buf, &stlen);
1409 + if (e->window == pngW) {
1411 + if (buf[0] == '\r' || buf[0] == '\n') { /* enter */
1412 + FakeButtonPress(&pbut[P_BOK]);
1414 + else if (buf[0] == '\033') { /* ESC */
1415 + FakeButtonPress(&pbut[P_BCANC]);
1423 + if (rv==0 && (xev->type == ButtonPress || xev->type == KeyPress)) {
1424 + XBell(theDisp, 50);
1425 + rv = 1; /* eat it */
1432 +/*******************************************/
1433 +void PNGSaveParams(fname, col)
1442 +/*******************************************/
1443 +static void drawPD(x, y, w, h)
1446 + char *title = "Save PNG file...";
1449 + char *ctitle2 = "Useful range";
1450 + char *ctitle3 = "is 2 - 7.";
1451 + char *ctitle4 = "Uncompressed = 0";
1453 + char *ftitle = "Row Filters:";
1460 + xr.x = x; xr.y = y; xr.width = w; xr.height = h;
1461 + XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted);
1463 + XSetForeground(theDisp, theGC, infofg);
1464 + XSetBackground(theDisp, theGC, infobg);
1466 + for (i=0; i<P_NBUTTS; i++) BTRedraw(&pbut[i]);
1468 + DrawString(pngW, 15, 6+ASCENT, title);
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);
1476 + sprintf(gtitle, "Default = %g", DISPLAY_GAMMA);
1477 + DrawString(pngW, DWIDE+30, 6+DHIGH+gDial.y+ASCENT, gtitle);
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);
1486 + CBRedraw(&FnoneCB);
1488 + CBRedraw(&FsubCB);
1489 + CBRedraw(&FavgCB);
1490 + CBRedraw(&FPaethCB);
1492 + CBRedraw(&interCB);
1494 + XSetClipMask(theDisp, theGC, None);
1498 +/*******************************************/
1499 +static void clickPD(x,y)
1507 + for (i=0; i<P_NBUTTS; i++) {
1509 + if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
1512 + if (i<P_NBUTTS) { /* found one */
1513 + if (BTTrack(bp)) doCmd(i);
1516 + /* check CBUTTs */
1518 + else if (CBClick(&FdefCB,x,y)) {
1519 + int oldval = FdefCB.val;
1523 + if (oldval != FdefCB.val)
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);
1531 + CBRedraw(&FnoneCB);
1533 + CBRedraw(&FsubCB);
1534 + CBRedraw(&FavgCB);
1535 + CBRedraw(&FPaethCB);
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);
1547 +/*******************************************/
1548 +static void doCmd(cmd)
1558 + fullname = GetDirFullName();
1559 + if (!ISPIPE(fullname[0])) {
1560 + XVCreatedFile(fullname);
1561 + StickInCtrlList(0);
1566 + case P_BCANC: PNGDialog(0); break;
1573 +/*******************************************/
1574 +static void writePNG()
1577 + int w, h, nc, rv, ptype, pfree;
1578 + byte *inpix, *rmap, *gmap, *bmap;
1580 + fp = OpenOutFile(filename);
1583 + fbasename = BaseName(filename);
1586 + inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
1588 + rv = WritePNG(fp, inpix, ptype, w, h, rmap, gmap, bmap, nc);
1592 + if (CloseOutFile(fp, filename, rv) == 0) DirBox(0);
1594 + if (pfree) free(inpix);
1598 +/*******************************************/
1599 +int WritePNG(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols)
1603 + byte *rmap, *gmap, *bmap;
1606 + png_struct *png_ptr;
1607 + png_info *info_ptr;
1608 + png_color palette[256];
1611 + int i, filter, linesize = 0, pass;
1612 + byte *p, *png_line;
1613 + char software[256];
1614 + char *savecmnt = NULL;
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");
1621 + if ((info_ptr = png_create_info_struct(png_ptr)) == NULL)
1623 + png_destroy_write_struct(&png_ptr, &info_ptr);
1624 + FatalError("malloc failure in WritePNG");
1627 + if (setjmp(png_ptr->jmpbuf)) {
1628 + png_destroy_write_struct(&png_ptr, &info_ptr);
1632 + png_init_io(png_ptr, fp);
1634 + png_set_compression_level(png_ptr, (int)cDial.val);
1636 + /* Don't bother filtering if we aren't compressing the image */
1639 + if ((int)cDial.val == 0)
1640 + png_set_filter(png_ptr, 0, PNG_FILTER_NONE);
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;
1650 + png_set_filter(png_ptr, 0, filter);
1653 + info_ptr->width = w;
1654 + info_ptr->height = h;
1656 + info_ptr->interlace_type = interCB.val ? 1 : 0;
1658 + if (colorType == F_FULLCOLOR || colorType == F_REDUCED) {
1659 + if(ptype == PIC24) {
1661 + info_ptr->color_type = PNG_COLOR_TYPE_RGB;
1662 + info_ptr->bit_depth = 8;
1665 + info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
1667 + info_ptr->bit_depth = 1;
1670 + info_ptr->bit_depth = 2;
1673 + info_ptr->bit_depth = 4;
1675 + info_ptr->bit_depth = 8;
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];
1682 + info_ptr->num_palette = numcols;
1683 + info_ptr->palette = palette;
1684 + info_ptr->valid |= PNG_INFO_PLTE;
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()");
1694 + info_ptr->bit_depth = 1;
1695 + if(MONO(rmap[0], gmap[0], bmap[0]) > MONO(rmap[1], gmap[1], bmap[1])) {
1706 + if(ptype == PIC24) {
1708 + info_ptr->bit_depth = 8;
1715 + for(i = 0; i < numcols; i++)
1716 + remap[i] = MONO(rmap[i], gmap[i], bmap[i]);
1718 + for(; i < 256; i++)
1721 + info_ptr->bit_depth = 8;
1723 + /* Note that this fails most of the time because of gamma */
1724 + /* try to adjust to 4 bit prescision grayscale */
1728 + for(i = 0; i < numcols; i++) {
1729 + if((remap[i] & 0x0f) * 0x11 != remap[i]) {
1736 + for(i = 0; i < numcols; i++) {
1739 + info_ptr->bit_depth = 4;
1741 + /* try to adjust to 2 bit prescision grayscale */
1743 + for(i = 0; i < numcols; i++) {
1744 + if((remap[i] & 0x03) * 0x05 != remap[i]) {
1752 + for(i = 0; i < numcols; i++) {
1755 + info_ptr->bit_depth = 2;
1757 + /* try to adjust to 1 bit prescision grayscale */
1759 + for(i = 0; i < numcols; i++) {
1760 + if((remap[i] & 0x01) * 0x03 != remap[i]) {
1768 + for(i = 0; i < numcols; i++) {
1771 + info_ptr->bit_depth = 1;
1778 + png_error(png_ptr, "Unknown colorstyle in WritePNG");
1780 + if ((text = (png_textp)malloc(sizeof(png_text)))) {
1781 + sprintf(software, "XV %s", REVDATE);
1783 + text->compression = -1;
1784 + text->key = "Software";
1785 + text->text = software;
1786 + text->text_length = strlen(text->text);
1788 + info_ptr->max_text = 1;
1789 + info_ptr->num_text = 1;
1790 + info_ptr->text = text;
1793 + Display_Gamma = gDial.val; /* Save the current gamma for loading */
1795 + info_ptr->gamma = 1.0/gDial.val;
1796 + info_ptr->valid |= PNG_INFO_gAMA;
1798 + png_write_info(png_ptr, info_ptr);
1800 + if(info_ptr->bit_depth < 8)
1801 + png_set_packing(png_ptr);
1803 + pass=png_set_interlace_handling(png_ptr);
1805 + if((png_line = malloc(linesize)) == NULL)
1806 + png_error(png_ptr, "cannot allocate temp image line");
1808 + for(i = 0; i < pass; i++) {
1811 + for(j = 0; j < h; j++) {
1813 + if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
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]) :
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();
1830 + if (picComments && strlen(picComments) &&
1831 + (savecmnt = (char *)malloc((strlen(picComments) + 1)*sizeof(char)))) {
1833 + char *comment, *key;
1835 + strcpy(savecmnt, picComments);
1838 + info_ptr->num_text = 0;
1840 + comment = strchr(key, ':');
1843 + /* Allocate a larger structure for comments if necessary */
1844 + if (info_ptr->num_text >= info_ptr->max_text)
1847 + realloc(text, (info_ptr->num_text + 2)*sizeof(png_text))) == NULL)
1854 + tp = &text[info_ptr->num_text];
1855 + info_ptr->max_text += 2;
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';
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');
1869 + key++; /* skip \n */
1870 + comment = strchr(key, ':');
1872 + /* We have another keyword and/or comment to write out */
1875 + tp->text = comment;
1877 + /* We have to find the end of this comment, and the next keyword
1878 + if there is one */
1880 + key = comment = strchr(comment, ':');
1881 + } while (key && key[1] != ':');
1883 + /* It looks like another keyword, go backward to the beginning */
1885 + while(key > tp->text && *key != '\n')
1888 + if (key > tp->text && comment - key <= 80) {
1894 + tp->text_length = strlen(tp->text);
1896 + /* We don't have another keyword, so remove the last newline */
1897 + if (!key && tp->text[tp->text_length - 1] == '\n')
1899 + tp->text[tp->text_length] = '\0';
1900 + tp->text_length--;
1903 + tp->compression = tp->text_length > 640 ? 0 : -1;
1904 + info_ptr->num_text++;
1908 + /* It is just a generic comment */
1910 + tp->key = "Comment";
1912 + tp->text_length = strlen(tp->text);
1913 + tp->compression = tp->text_length > 750 ? 0 : -1;
1914 + info_ptr->num_text++;
1917 + } while (key && *key);
1921 + info_ptr->num_text = 0;
1924 + info_ptr->text = text;
1926 + png_convert_from_time_t(&(info_ptr->mod_time), time(NULL));
1927 + info_ptr->valid |= PNG_INFO_tIME;
1929 + png_write_end(png_ptr, info_ptr);
1930 + png_destroy_write_struct(&png_ptr, &info_ptr);
1943 +/*******************************************/
1944 +int LoadPNG(fname, pinfo)
1947 +/*******************************************/
1949 + /* returns '1' on success */
1952 + png_struct *png_ptr;
1953 + png_info *info_ptr;
1954 + png_color_16 my_background;
1959 + size_t commentsize;
1961 + fbasename = BaseName(fname);
1963 + pinfo->pic = (byte *) NULL;
1964 + pinfo->comment = (char *) NULL;
1968 + /* open the file */
1969 + fp = xv_fopen(fname,"r");
1972 + SetISTR(ISTR_WARNING,"%s: can't open file", fname);
1976 + /* find the size of the file */
1978 + filesize = ftell(fp);
1981 + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
1982 + png_xv_error, png_xv_warning);
1985 + FatalError("malloc failure in LoadPNG");
1988 + info_ptr = png_create_info_struct(png_ptr);
1992 + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
1993 + FatalError("malloc failure in LoadPNG");
1996 + if(setjmp(png_ptr->jmpbuf)) {
1998 + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
1999 + if(!read_anything) {
2002 + pinfo->pic = NULL;
2004 + if(pinfo->comment) {
2005 + free(pinfo->comment);
2006 + pinfo->comment = NULL;
2009 + return read_anything;
2012 + png_init_io(png_ptr, fp);
2013 + png_read_info(png_ptr, info_ptr);
2015 + pinfo->w = pinfo->normw = info_ptr->width;
2016 + pinfo->h = pinfo->normh = info_ptr->height;
2018 + pinfo->frmType = F_PNG;
2020 + sprintf(pinfo->fullInfo, "PNG, %d bit ",
2021 + info_ptr->bit_depth * info_ptr->channels);
2023 + switch(info_ptr->color_type) {
2024 + case PNG_COLOR_TYPE_PALETTE:
2025 + strcat(pinfo->fullInfo, "palette color");
2028 + case PNG_COLOR_TYPE_GRAY:
2029 + strcat(pinfo->fullInfo, "grayscale");
2032 + case PNG_COLOR_TYPE_GRAY_ALPHA:
2033 + strcat(pinfo->fullInfo, "grayscale+alpha");
2036 + case PNG_COLOR_TYPE_RGB:
2037 + strcat(pinfo->fullInfo, "truecolor");
2040 + case PNG_COLOR_TYPE_RGB_ALPHA:
2041 + strcat(pinfo->fullInfo, "truecolor+alpha");
2045 + sprintf(pinfo->fullInfo + strlen(pinfo->fullInfo),
2046 + ", %sinterlaced. (%d bytes)",
2047 + info_ptr->interlace_type ? "" : "non-", filesize);
2049 + sprintf(pinfo->shrtInfo, "%dx%d PNG", info_ptr->width, info_ptr->height);
2051 + if (info_ptr->bit_depth < 8)
2052 + png_set_packing(png_ptr);
2054 + if (info_ptr->valid & PNG_INFO_gAMA)
2055 + png_set_gamma(png_ptr, Display_Gamma, info_ptr->gamma);
2057 + png_set_gamma(png_ptr, Display_Gamma, 0.45);
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);
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);
2069 + if (info_ptr->bit_depth == 16)
2070 + png_set_strip_16(png_ptr);
2072 + if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
2073 + info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
2075 + if (info_ptr->bit_depth == 1)
2076 + pinfo->colType = F_BWDITHER;
2078 + pinfo->colType = F_GREYSCALE;
2079 + png_set_expand(png_ptr);
2082 + pass=png_set_interlace_handling(png_ptr);
2084 + png_read_update_info(png_ptr, info_ptr);
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;
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;
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;
2107 + pinfo->pic = calloc((size_t)(linesize*pinfo->h), (size_t)1);
2110 + png_error(png_ptr, "can't allocate space for PNG image");
2113 + png_start_read_image(png_ptr);
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();
2125 + png_read_end(png_ptr, info_ptr);
2127 + if(info_ptr->num_text > 0) {
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;
2134 + if((pinfo->comment = malloc(commentsize)) == NULL) {
2135 + png_warning(png_ptr,"can't allocate comment string");
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");
2148 + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
2156 +/*******************************************/
2158 +png_xv_error(png_ptr, message)
2159 + png_struct *png_ptr;
2162 + SetISTR(ISTR_WARNING,"%s: libpng error: %s", fbasename, message);
2164 + longjmp(png_ptr->jmpbuf, 1);
2168 +/*******************************************/
2170 +png_xv_warning(png_ptr, message)
2171 + png_struct *png_ptr;
2177 + SetISTR(ISTR_WARNING,"%s: libpng warning: %s", fbasename, message);
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 @@
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);
2196 DCreate(&padODial, popW, 16+1+75+75+9, puhigh-16-100-1,75,100,
2198 + 0.0, 100.0, 100.0, 1.0, 10.0,
2199 infofg, infobg, hicol, locol, "Opaque", NULL);
2201 MBCreate(&padMthdMB, popW, 100-2+44, 10, 140, 19, NULL,
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);
2212 DSetActive(&padWDial, (padMode!=PAD_LOAD)); /* DSetRange activates dial */
2213 DSetActive(&padHDial, (padMode!=PAD_LOAD));
2215 changedGSBuf(); /* careful! popW doesn't exist yet! */
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;
2225 else { oldW = pWIDE; oldH = pHIGH; oldO = 100; }
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);
2239 XUnmapWindow(theDisp, padWDial.win);
2241 /* load up return values */
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;
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);
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
2268 CBCreate(&encapsCB, psW, 240, 7, "preview", infofg, infobg, hicol, locol);
2269 CBCreate(&pscompCB, psW, 331, 7, "compress", infofg, infobg, hicol, locol);
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 @@
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;
2286 - DSetVal(&xsDial, i);
2287 - DSetVal(&ysDial, i);
2288 + DSetVal(&xsDial, v);
2289 + DSetVal(&ysDial, v);
2294 if (scx < scy) { sz_iny = h * scx; }
2295 else { sz_inx = w * scy; }
2297 - DSetVal(&xsDial, (int) ((100 * (sz_inx * PIX2INCH) / w) + .5));
2298 + DSetVal(&xsDial, 100 * (sz_inx * PIX2INCH) / w);
2299 DSetVal(&ysDial, xsDial.val);
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
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 */
2313 static byte *loadPalette PARM((TIFF *, uint32, uint32, int, int, PICINFO *));
2318 - sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
2319 + sprintf(pinfo->shrtInfo, "%lux%lu TIFF.",w,h);
2321 pic8 = (byte *) malloc((size_t) w*h);
2322 if (!pic8) FatalError("loadPalette() - couldn't malloc 'pic8'");
2327 - sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
2328 + sprintf(pinfo->shrtInfo, "%lux%lu TIFF.",w,h);
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;
2336 -typedef void (*tileContigRoutine) PARM((byte*, u_char*, RGBvalue*,
2337 +typedef void (*xvtileContigRoutine) PARM((byte*, u_char*, RGBvalue*,
2338 uint32, uint32, int, int));
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));
2346 static void putcontig8bitYCbCrtile PARM((byte *, u_char *, RGBvalue *,
2347 uint32, uint32, int, int));
2349 -static tileContigRoutine pickTileContigCase PARM((RGBvalue *));
2350 -static tileSeparateRoutine pickTileSeparateCase PARM((RGBvalue *));
2351 +static xvtileContigRoutine pickTileContigCase PARM((RGBvalue *));
2352 +static xvtileSeparateRoutine pickTileSeparateCase PARM((RGBvalue *));
2355 /*******************************************/
2358 int fromskew, toskew;
2360 - tileContigRoutine put;
2361 + xvtileContigRoutine put;
2363 put = pickTileContigCase(Map);
2364 if (put == 0) return (0);
2367 int fromskew, toskew;
2369 - tileSeparateRoutine put;
2370 + xvtileSeparateRoutine put;
2372 put = pickTileSeparateCase(Map);
2373 if (put == 0) return (0);
2376 uint32 row, y, nrow;
2378 - tileContigRoutine put;
2379 + xvtileContigRoutine put;
2380 uint32 rowsperstrip;
2385 uint32 row, y, nrow;
2387 - tileSeparateRoutine put;
2388 + xvtileSeparateRoutine put;
2389 uint32 rowsperstrip;
2392 @@ -1065,7 +1065,7 @@
2393 int fromskew, toskew;
2396 - UNROLL8(w,0, *cp++ = PALmap[*pp++][0]);
2397 + UNROLL8(w,, *cp++ = PALmap[*pp++][0]);
2401 @@ -1262,7 +1262,7 @@
2410 @@ -1335,7 +1335,7 @@
2419 @@ -1489,16 +1489,16 @@
2421 * Select the appropriate conversion routine for packed data.
2423 -static tileContigRoutine pickTileContigCase(Map)
2424 +static xvtileContigRoutine pickTileContigCase(Map)
2427 - tileContigRoutine put = 0;
2428 + xvtileContigRoutine put = 0;
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;
2440 @@ -1540,16 +1540,16 @@
2441 * NB: we assume that unpacked single channel data is directed
2442 * to the "packed routines.
2444 -static tileSeparateRoutine pickTileSeparateCase(Map)
2445 +static xvtileSeparateRoutine pickTileSeparateCase(Map)
2448 - tileSeparateRoutine put = 0;
2449 + xvtileSeparateRoutine put = 0;
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;
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
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 */
2472 #define ALLOW_JPEG 0 /* set to '1' to allow 'JPEG' choice in dialog box */