xv 3.10a rollup 2001-05-12 patch This file contains the information the xv 3.10a rollup 2001-05-12 patch. For the extra details, see: http://www.isthe.com/chongo/src/xv-patch/index.html http://www.isthe.com/chongo/src/xv-patch/README.rollup-2001-05-12-details =-= To apply the xv 3.10a rollup patch 2001-05-12 patch you must have libtiff, libjpeg, libpng and zlib on your system. If your system vendor did not supply them you may obtain them at: http://freshmeat.net/projects/libtiff/ http://freshmeat.net/projects/libjpeg/ http://freshmeat.net/projects/libpng/ http://freshmeat.net/projects/zlib/ To apply the xv 3.10a rollup patch 2001-05-12 patch, (assuming that you already have libtiff, libjpeg, libpng and zlib) first try: patch --dry-run -p0 < rollup-2001-05-12.patch If all looks well try: patch -p0 < rollup-2001-05-12.patch =-= You may find it easier to apply this patch to the original xv 3.10a src: ftp://ftp.cis.upenn.edu/pub/xv/xv-3.10a.tar.gz This patch came from: http://www.isthe.com/chongo/src/xv-patch/rollup-2001-05-12.patch =-= In addition to this rollup patch, Linux users need to apply the Makefile patch found at: http://www.isthe.com/chongo/src/xv-patch/Linux-Makefile.patch The above patch changes CC in the Makefile from just 'cc' to 'gcc -ansi'. =-= Disclaimers This patch is being distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This patch is in the public domain and is NOT copyrighted. That is, use this patch at your own risk. While I did roll up a number of patches from the xv v3.10a recommended and optional patch set, and while I resolved some of the patch conflicts, and while I added some help for Linux, I did NOT write most of the patch. I do NOT maintain xv. Please do NOT send me xv bug reports. Send xv bug reports (and fixes) to the xv tech EMail address: http://www.trilon.com/xv/index.html#email I did NOT write xv. You are welcome to ``Share and Enjoy'' xv and send $25 to John Bradley. :-) chongo (http://www.isthe.com/chongo/index.html) /\oo/\ =-= Here is the xv 3.10a rollup patch 2001-05-12 ============================================ diff -c Makefile.init Makefile *** Makefile.init Mon Jan 23 12:20:54 1995 --- Makefile Sat May 12 15:40:42 2001 *************** *** 46,58 **** ### on your machine, *COMMENT OUT* the following lines ### JPEG = -DDOJPEG ! JPEGDIR = jpeg ! JPEGINC = -I$(JPEGDIR) ! JPEGLIB = $(JPEGDIR)/libjpeg.a ! $(JPEGDIR)/jconfig.h: ! cd $(JPEGDIR) ; ./configure CC='$(CC)' ! $(JPEGLIB): $(JPEGDIR)/jconfig.h ! cd $(JPEGDIR) ; make ### --- 46,78 ---- ### on your machine, *COMMENT OUT* the following lines ### JPEG = -DDOJPEG ! ###JPEGDIR = jpeg ! ###JPEGINC = -I$(JPEGDIR) ! ###JPEGLIB = $(JPEGDIR)/libjpeg.a ! JPEGLIB = -ljpeg ! ###$(JPEGDIR)/jconfig.h: ! ### cd $(JPEGDIR) ; ./configure CC='$(CC)' ! ###$(JPEGLIB): $(JPEGDIR)/jconfig.h ! ### cd $(JPEGDIR) ; make ! ! ! ### ! ### if, for whatever reason, you're unable to get the PNG library to compile ! ### on your machine, *COMMENT OUT* the following lines ! ### ! PNG = -DDOPNG ! PNGDIR = /usr/local/src/libpng ! PNGINC = -I$(PNGDIR) ! PNGLIB = -L$(PNGDIR) -lpng ! ! ! ### ! ### if, for whatever reason, you're unable to get the PNG library to compile ! ### on your machine, *COMMENT OUT* the following lines ! ### ! ZLIBDIR = /usr/local/src/zlib ! ZLIBINC = -I$(ZLIBDIR) ! ZLIBLIB = -L$(ZLIBDIR) -lz ### *************** *** 60,70 **** ### on your machine, *COMMENT OUT* the following lines ### TIFF = -DDOTIFF ! TIFFDIR = tiff ! TIFFINC = -I$(TIFFDIR) ! TIFFLIB = $(TIFFDIR)/libtiff.a ! $(TIFFLIB): ! ( cd $(TIFFDIR) ; make CC='$(CC)' ) ### --- 80,91 ---- ### on your machine, *COMMENT OUT* the following lines ### TIFF = -DDOTIFF ! ###TIFFDIR = tiff ! ###TIFFINC = -I$(TIFFDIR) ! ###TIFFLIB = $(TIFFDIR)/libtiff.a ! TIFFLIB = -ltiff ! ###$(TIFFLIB): ! ### ( cd $(TIFFDIR) ; make CC='$(CC)' ) ### *************** *** 102,108 **** ### for LINUX, uncomment the following line ! #MCHN = -DLINUX # For SCO 1.1 (UNIX 3.2v2) machines, uncomment the following: --- 123,130 ---- ### for LINUX, uncomment the following line ! MCHN = -L/usr/X11R6/lib ! # For SCO 1.1 (UNIX 3.2v2) machines, uncomment the following: *************** *** 186,194 **** CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \ $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \ ! $(DXWM) $(MCHN) ! LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm OBJS = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \ xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \ --- 208,216 ---- CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \ $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \ ! $(DXWM) $(MCHN) $(PNG) $(PNGINC) $(ZLIBINC) ! LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) $(PNGLIB) $(ZLIBLIB) -lm OBJS = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \ xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \ *************** *** 196,202 **** xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \ xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \ xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \ ! xvxwd.o xvfits.o MISC = README INSTALL CHANGELOG IDEAS --- 218,224 ---- xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \ xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \ xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \ ! xvxwd.o xvfits.o xvpng.o MISC = README INSTALL CHANGELOG IDEAS *************** *** 267,273 **** xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds xvbrowse.o: bits/br_ps bits/br_iff bits/br_targa bits/br_xpm xvbrowse.o: bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm ! xvbrowse.o: bits/br_xwd xvbutt.o: bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top xvbutt.o: bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body --- 289,295 ---- xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds xvbrowse.o: bits/br_ps bits/br_iff bits/br_targa bits/br_xpm xvbrowse.o: bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm ! xvbrowse.o: bits/br_xwd bits/br_png xvbutt.o: bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top xvbutt.o: bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body diff -c Makefile.std.init Makefile.std *** Makefile.std.init Mon Jan 23 17:06:26 1995 --- Makefile.std Sat May 12 15:41:43 2001 *************** *** 46,58 **** ### on your machine, *COMMENT OUT* the following lines ### JPEG = -DDOJPEG ! JPEGDIR = jpeg ! JPEGINC = -I$(JPEGDIR) ! JPEGLIB = $(JPEGDIR)/libjpeg.a ! $(JPEGDIR)/jconfig.h: ! cd $(JPEGDIR) ; ./configure CC='$(CC)' ! $(JPEGLIB): $(JPEGDIR)/jconfig.h ! cd $(JPEGDIR) ; make ### --- 46,78 ---- ### on your machine, *COMMENT OUT* the following lines ### JPEG = -DDOJPEG ! ###JPEGDIR = jpeg ! ###JPEGINC = -I$(JPEGDIR) ! ###JPEGLIB = $(JPEGDIR)/libjpeg.a ! JPEGLIB = -ljpeg ! ###$(JPEGDIR)/jconfig.h: ! ### cd $(JPEGDIR) ; ./configure CC='$(CC)' ! ###$(JPEGLIB): $(JPEGDIR)/jconfig.h ! ### cd $(JPEGDIR) ; make ! ! ! ### ! ### if, for whatever reason, you're unable to get the PNG library to compile ! ### on your machine, *COMMENT OUT* the following lines ! ### ! PNG = -DDOPNG ! PNGDIR = /usr/local/src/libpng ! PNGINC = -I$(PNGDIR) ! PNGLIB = -L$(PNGDIR) -lpng ! ! ! ### ! ### if, for whatever reason, you're unable to get the PNG library to compile ! ### on your machine, *COMMENT OUT* the following lines ! ### ! ZLIBDIR = /usr/local/src/zlib ! ZLIBINC = -I$(ZLIBDIR) ! ZLIBLIB = -L$(ZLIBDIR) -lz ### *************** *** 60,70 **** ### on your machine, *COMMENT OUT* the following lines ### TIFF = -DDOTIFF ! TIFFDIR = tiff ! TIFFINC = -I$(TIFFDIR) ! TIFFLIB = $(TIFFDIR)/libtiff.a ! $(TIFFLIB): ! ( cd $(TIFFDIR) ; make CC='$(CC)' ) ### --- 80,91 ---- ### on your machine, *COMMENT OUT* the following lines ### TIFF = -DDOTIFF ! ###TIFFDIR = tiff ! ###TIFFINC = -I$(TIFFDIR) ! ###TIFFLIB = $(TIFFDIR)/libtiff.a ! TIFFLIB = -ltiff ! ###$(TIFFLIB): ! ### ( cd $(TIFFDIR) ; make CC='$(CC)' ) ### *************** *** 186,194 **** CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \ $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \ ! $(DXWM) $(MCHN) ! LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm OBJS = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \ xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \ --- 207,215 ---- CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \ $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \ ! $(DXWM) $(MCHN) $(PNG) $(PNGINC) $(ZLIBINC) ! LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) $(PNGLIB) $(ZLIBLIB) -lm OBJS = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \ xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \ *************** *** 196,202 **** xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \ xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \ xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \ ! xvxwd.o xvfits.o MISC = README INSTALL CHANGELOG IDEAS --- 217,223 ---- xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \ xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \ xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \ ! xvxwd.o xvfits.o xvpng.o MISC = README INSTALL CHANGELOG IDEAS *************** *** 267,273 **** xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds xvbrowse.o: bits/br_ps bits/br_iff bits/br_targa bits/br_xpm xvbrowse.o: bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm ! xvbrowse.o: bits/br_xwd xvbutt.o: bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top xvbutt.o: bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body --- 288,294 ---- xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds xvbrowse.o: bits/br_ps bits/br_iff bits/br_targa bits/br_xpm xvbrowse.o: bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm ! xvbrowse.o: bits/br_xwd bits/br_png xvbutt.o: bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top xvbutt.o: bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body diff -c /dev/null bits/br_png *** /dev/null Thu Aug 24 02:00:32 2000 --- bits/br_png Sat May 12 15:37:23 2001 *************** *** 0 **** --- 1,28 ---- + #define br_png_width 48 + #define br_png_height 48 + static unsigned char br_png_bits[] = { + 0xe0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x03, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x05, 0x00, 0x20, 0x00, 0x00, 0x00, 0x09, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x11, 0x00, 0x20, 0x00, 0x00, 0x00, 0x21, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x41, 0x00, 0x20, 0x00, 0x00, 0x00, 0x81, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x01, 0x01, 0x20, 0x00, 0x00, 0x00, 0xff, 0x03, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0xf8, 0x19, 0xc3, 0x07, 0x02, 0x20, 0x18, 0x3b, 0x63, 0x0c, 0x02, + 0x20, 0x18, 0x3b, 0x33, 0x00, 0x02, 0x20, 0x18, 0x5b, 0x33, 0x00, 0x02, + 0x20, 0xf8, 0x59, 0x33, 0x0f, 0x02, 0x20, 0x18, 0x98, 0x33, 0x0c, 0x02, + 0x20, 0x18, 0x98, 0x33, 0x0c, 0x02, 0x20, 0x18, 0x18, 0x63, 0x0c, 0x02, + 0x20, 0x18, 0x18, 0xc3, 0x0b, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03, + }; diff -c config.h.init config.h *** config.h.init Thu Jan 5 10:49:21 1995 --- config.h Sat May 12 15:37:23 2001 *************** *** 13,25 **** * definition appropriately. (use 'which gunzip' to find if you have gunzip, * and where it lives) */ ! #undef USE_GUNZIP #ifdef USE_GUNZIP # ifdef VMS # define GUNZIP "UNCOMPRESS" # else ! # define GUNZIP "/usr/local/bin/gunzip -q" # endif #endif --- 13,25 ---- * definition appropriately. (use 'which gunzip' to find if you have gunzip, * and where it lives) */ ! #define USE_GUNZIP #ifdef USE_GUNZIP # ifdef VMS # define GUNZIP "UNCOMPRESS" # else ! # define GUNZIP "/bin/gunzip -q" # endif #endif *************** *** 35,41 **** * as it tries to be clever on systems where uncompress lives in an unusual * location. */ ! #define UNCOMPRESS "/usr/ucb/uncompress" #if defined(hpux) || defined(SVR4) || defined(__386BSD__) # undef UNCOMPRESS --- 35,41 ---- * as it tries to be clever on systems where uncompress lives in an unusual * location. */ ! #define UNCOMPRESS "/usr/bin/uncompress" #if defined(hpux) || defined(SVR4) || defined(__386BSD__) # undef UNCOMPRESS *************** *** 88,94 **** * should not need to be changed */ ! /* #define GS_PATH "/usr/local/bin/gs" */ /* #define GS_LIB "." */ /* #define GS_DEV "ppmraw" */ --- 88,94 ---- * should not need to be changed */ ! #define GS_PATH "/usr/bin/gs" /* #define GS_LIB "." */ /* #define GS_DEV "ppmraw" */ diff -c vdcomp.c.init vdcomp.c *** vdcomp.c.init Thu Dec 22 14:34:47 1994 --- vdcomp.c Sat May 12 15:37:23 2001 *************** *** 124,129 **** --- 124,131 ---- #define TRUE 1 #define FALSE 0 + #define NAMELEN 1024 /* inname and outname sizes */ + /* pc i/o defines */ #define O_BINARY 0x8000 /* file mode is binary */ *************** *** 176,182 **** int infile; FILE *outfile; ! char inname[1024],outname[1024]; int output_format; int record_bytes, max_lines; int line_samples, fits_pad; --- 178,184 ---- int infile; FILE *outfile; ! char inname[NAMELEN+1],outname[NAMELEN+1]; int output_format; int record_bytes, max_lines; int line_samples, fits_pad; *************** *** 222,229 **** exit(1); } else { ! strcpy(inname,argv[1]); ! if (argc >= 3) strcpy(outname,argv[2]); if (argc == 3) output_format = 1; if (argc == 4) sscanf(argv[3],"%d",&output_format); } --- 224,235 ---- exit(1); } else { ! strncpy(inname, argv[1], NAMELEN); ! inname[NAMELEN] = '\0'; ! if (argc >= 3) { ! strncpy(outname, argv[2], NAMELEN); ! outname[NAMELEN] = '\0'; ! } if (argc == 3) output_format = 1; if (argc == 4) sscanf(argv[3],"%d",&output_format); } *************** *** 432,438 **** if (inname[0] == ' ') { printf("\nEnter name of file to be decompressed: "); ! gets (inname); } if (host == 1 | host == 2) { --- 438,444 ---- if (inname[0] == ' ') { printf("\nEnter name of file to be decompressed: "); ! fgets(inname, NAMELEN, stdin); } if (host == 1 | host == 2) { *************** *** 474,486 **** printf("\n 3. VICAR format."); printf("\n 4. Unlabelled binary array.\n"); printf("\n Enter format number:"); ! gets(inname); output_format = atoi(inname); } while (output_format < 1 || output_format > 4); if (outname[0] == ' ') { printf("\nEnter name of uncompressed output file: "); ! gets (outname); } return(host); --- 480,492 ---- printf("\n 3. VICAR format."); printf("\n 4. Unlabelled binary array.\n"); printf("\n Enter format number:"); ! fgets(inname, NAMELEN, stdin); output_format = atoi(inname); } while (output_format < 1 || output_format > 4); if (outname[0] == ' ') { printf("\nEnter name of uncompressed output file: "); ! fgets(outname, NAMELEN, stdin); } return(host); diff -c xv.c.init xv.c *** xv.c.init Thu Jan 19 10:08:43 1995 --- xv.c Sat May 12 15:37:23 2001 *************** *** 277,282 **** --- 277,286 ---- tiffW = (Window) NULL; tiffUp = 0; #endif + #ifdef HAVE_PNG + pngW = (Window) NULL; pngUp = 0; + #endif + imap = ctrlmap = gmap = browmap = cmtmap = 0; ch_offx = ch_offy = p_offx = p_offy = 0; *************** *** 309,315 **** theScreen = DefaultScreen(theDisp); theCmap = DefaultColormap(theDisp, theScreen); ! rootW = RootWindow(theDisp,theScreen); theGC = DefaultGC(theDisp,theScreen); theVisual = DefaultVisual(theDisp,theScreen); ncells = DisplayCells(theDisp, theScreen); --- 313,323 ---- theScreen = DefaultScreen(theDisp); theCmap = DefaultColormap(theDisp, theScreen); ! if (spec_window) { ! rootW = spec_window; ! } else { ! rootW = RootWindow(theDisp,theScreen); ! } theGC = DefaultGC(theDisp,theScreen); theVisual = DefaultVisual(theDisp,theScreen); ncells = DisplayCells(theDisp, theScreen); *************** *** 326,362 **** */ - /* if we *haven't* had a non-default visual specified, see if we have a TrueColor or DirectColor visual of 24 or 32 bits, and if so, use that as the default visual (prefer TrueColor) */ if (!visualstr && !useroot) { XVisualInfo *vinfo, rvinfo; int best, numvis; long flags; ! best = -1; rvinfo.class = TrueColor; rvinfo.screen = theScreen; ! flags = VisualClassMask | VisualScreenMask; vinfo = XGetVisualInfo(theDisp, flags, &rvinfo, &numvis); ! if (vinfo) { /* look for a TrueColor, 24-bit or more (pref 24) */ ! for (i=0, best = -1; i24 && best<0) best = i; } } ! if (best == -1) { /* look for a DirectColor, 24-bit or more (pref 24) */ rvinfo.class = DirectColor; if (vinfo) XFree((char *) vinfo); vinfo = XGetVisualInfo(theDisp, flags, &rvinfo, &numvis); if (vinfo) { ! for (i=0, best = -1; i24 && best<0) best = i; } } } --- 334,384 ---- */ /* if we *haven't* had a non-default visual specified, see if we have a TrueColor or DirectColor visual of 24 or 32 bits, and if so, use that as the default visual (prefer TrueColor) */ if (!visualstr && !useroot) { + VisualID defvid; XVisualInfo *vinfo, rvinfo; int best, numvis; long flags; ! best = -1; rvinfo.class = TrueColor; rvinfo.screen = theScreen; ! flags = VisualClassMask | VisualScreenMask; ! defvid = XVisualIDFromVisual(DefaultVisual(theDisp, ! DefaultScreen(theDisp))); vinfo = XGetVisualInfo(theDisp, flags, &rvinfo, &numvis); ! if (vinfo) { ! /* Check list, use 'default', first 24-bit, or first >24-bit */ ! for (i=0; i= 24)) best=i; ! } ! for (i=0; i24-bit ? */ ! if (vinfo[i].depth >= 24) best = i; } } ! if (best == -1) { /* look for a DirectColor, 24-bit or more (pref 24) */ rvinfo.class = DirectColor; if (vinfo) XFree((char *) vinfo); + vinfo = XGetVisualInfo(theDisp, flags, &rvinfo, &numvis); if (vinfo) { ! for (i=0; i= 24)) best=i; ! } ! for (i=0; i24-bit ? */ ! if (vinfo[i].depth >= 24) best = i; } } } *************** *** 364,371 **** if (best>=0 && best=0 && best0 && data) XFree(data); + if (spec_window) { + i = XGetWindowProperty(theDisp, spec_window, resAtom, 0L, + (long) ((nleft+4+3)/4), + False, XA_STRING, &actType, &actFormat, + &nitems, &nleft, (unsigned char **) &data); + } else { i = XGetWindowProperty(theDisp, RootWindow(theDisp, 0), resAtom, 0L, (long) ((nleft+4+3)/4), False, XA_STRING, &actType, &actFormat, &nitems, &nleft, (unsigned char **) &data); + } if (i==Success && actType==XA_STRING && actFormat==8 && data) { def_resource = XrmGetStringDatabase((char *) data); XFree(data); diff -c xv.h.init xv.h *** xv.h.init Mon Jan 23 12:22:23 1995 --- xv.h Sat May 12 15:37:23 2001 *************** *** 8,15 **** #include "config.h" ! #define REVDATE "Version 3.10a Rev: 12/29/94" ! #define VERSTR "3.10a" /* * uncomment the following, and modify for your site, but only if you've --- 8,15 ---- #include "config.h" ! #define REVDATE "Version 3.10a Rev: 12/29/94 (PNG patch 1.2)" ! #define VERSTR "3.10a(PNG)" /* * uncomment the following, and modify for your site, but only if you've *************** *** 62,71 **** #endif ! #ifdef LINUX # ifndef _LINUX_LIMITS_H # include # endif #endif --- 62,73 ---- #endif ! #if defined(__linux__) # ifndef _LINUX_LIMITS_H # include # endif + # define USLEEP + # define BSDTYPES #endif *************** *** 308,314 **** #ifndef VMS /* VMS hates multi-line definitions */ # if defined(SVR4) || defined(SYSV) || defined(sco) || \ ! defined(XENIX) || defined(__osf__) # undef USE_GETCWD # define USE_GETCWD /* use 'getcwd()' instead of 'getwd()' */ # endif --- 310,316 ---- #ifndef VMS /* VMS hates multi-line definitions */ # if defined(SVR4) || defined(SYSV) || defined(sco) || \ ! defined(XENIX) || defined(__osf__) || defined(__linux__) # undef USE_GETCWD # define USE_GETCWD /* use 'getcwd()' instead of 'getwd()' */ # endif *************** *** 327,332 **** --- 329,338 ---- #define HAVE_TIFF #endif + #ifdef DOPNG + #define HAVE_PNG + #endif + #ifdef DOPDS #define HAVE_PDS #endif *************** *** 458,481 **** #define F_TIFINC 0 #endif #define F_GIF 0 #define F_JPEG ( 0 + F_JPGINC) #define F_TIFF ( 0 + F_JPGINC + F_TIFINC) ! #define F_PS ( 1 + F_JPGINC + F_TIFINC) ! #define F_PBMRAW ( 2 + F_JPGINC + F_TIFINC) ! #define F_PBMASCII ( 3 + F_JPGINC + F_TIFINC) ! #define F_XBM ( 4 + F_JPGINC + F_TIFINC) ! #define F_XPM ( 5 + F_JPGINC + F_TIFINC) ! #define F_BMP ( 6 + F_JPGINC + F_TIFINC) ! #define F_SUNRAS ( 7 + F_JPGINC + F_TIFINC) ! #define F_IRIS ( 8 + F_JPGINC + F_TIFINC) ! #define F_TARGA ( 9 + F_JPGINC + F_TIFINC) ! #define F_FITS (10 + F_JPGINC + F_TIFINC) ! #define F_PM (11 + F_JPGINC + F_TIFINC) ! #define F_DELIM1 (12 + F_JPGINC + F_TIFINC) /* ----- */ ! #define F_FILELIST (13 + F_JPGINC + F_TIFINC) ! #define F_MAXFMTS (14 + F_JPGINC + F_TIFINC) /* 15, normally */ --- 464,494 ---- #define F_TIFINC 0 #endif + #ifdef HAVE_PNG + #define F_PNGINC 1 + #else + #define F_PNGINC 0 + #endif + #define F_GIF 0 #define F_JPEG ( 0 + F_JPGINC) #define F_TIFF ( 0 + F_JPGINC + F_TIFINC) ! #define F_PNG ( 0 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_PS ( 1 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_PBMRAW ( 2 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_PBMASCII ( 3 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_XBM ( 4 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_XPM ( 5 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_BMP ( 6 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_SUNRAS ( 7 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_IRIS ( 8 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_TARGA ( 9 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_FITS (10 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_PM (11 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_DELIM1 (12 + F_JPGINC + F_TIFINC + F_PNGINC) /* ----- */ ! #define F_FILELIST (13 + F_JPGINC + F_TIFINC + F_PNGINC) ! #define F_MAXFMTS (14 + F_JPGINC + F_TIFINC + F_PNGINC) /* 17, normally */ *************** *** 505,510 **** --- 518,524 ---- #define RFT_XPM 17 #define RFT_XWD 18 #define RFT_FITS 19 + #define RFT_PNG 20 /* definitions for page up/down, arrow up/down list control */ #define LS_PAGEUP 0 *************** *** 563,569 **** #define RM_CBRICK 7 /* centered on a 'brick' bg */ #define RM_ECENTER 8 /* symmetrical tiled */ #define RM_ECMIRR 9 /* symmetrical mirror tiled */ ! #define RM_MAX RM_ECMIRR /* values of colorMapMode */ --- 577,584 ---- #define RM_CBRICK 7 /* centered on a 'brick' bg */ #define RM_ECENTER 8 /* symmetrical tiled */ #define RM_ECMIRR 9 /* symmetrical mirror tiled */ ! #define RM_UPLEFT 10 /* just in upper left corner */ ! #define RM_MAX RM_UPLEFT /* values of colorMapMode */ *************** *** 613,619 **** #define RMB_CBRICK 8 #define RMB_ECENTER 9 #define RMB_ECMIRR 10 ! #define RMB_MAX 11 /* indicies into conv24MB */ --- 628,635 ---- #define RMB_CBRICK 8 #define RMB_ECENTER 9 #define RMB_ECMIRR 10 ! #define RMB_UPLEFT 11 ! #define RMB_MAX 12 /* indicies into conv24MB */ *************** *** 765,773 **** typedef struct { Window win; /* window ID */ int x,y,w,h; /* window coords in parent */ int active; /* true if can do anything*/ ! int min,max; /* min/max values 'pos' can take */ ! int val; /* 'value' of dial */ ! int page; /* amt val change on pageup/pagedown */ char *title; /* title for this guage */ char *units; /* string appended to value */ u_long fg,bg,hi,lo; /* colors */ --- 781,790 ---- typedef struct { Window win; /* window ID */ int x,y,w,h; /* window coords in parent */ int active; /* true if can do anything*/ ! double min,max; /* min/max values 'pos' can take */ ! double val; /* 'value' of dial */ ! double inc; /* amt val change on up/down */ ! double page; /* amt val change on pageup/pagedown */ char *title; /* title for this guage */ char *units; /* string appended to value */ u_long fg,bg,hi,lo; /* colors */ *************** *** 935,941 **** WHERE unsigned int ncells, dispWIDE, dispHIGH, dispDEEP; WHERE unsigned int vrWIDE, vrHIGH, maxWIDE, maxHIGH; WHERE Colormap theCmap, LocalCmap; ! WHERE Window rootW, mainW, vrootW; WHERE GC theGC; WHERE u_long black, white, fg, bg, infofg, infobg; WHERE u_long hicol, locol; --- 952,958 ---- WHERE unsigned int ncells, dispWIDE, dispHIGH, dispDEEP; WHERE unsigned int vrWIDE, vrHIGH, maxWIDE, maxHIGH; WHERE Colormap theCmap, LocalCmap; ! WHERE Window spec_window, rootW, mainW, vrootW; WHERE GC theGC; WHERE u_long black, white, fg, bg, infofg, infobg; WHERE u_long hicol, locol; *************** *** 1154,1159 **** --- 1171,1183 ---- #endif + #ifdef HAVE_PNG + /* stuff used for 'png' box */ + WHERE Window pngW; + WHERE int pngUp; /* is pngW mapped, or what? */ + #endif + + #undef WHERE *************** *** 1465,1476 **** /*************************** XVDIAL.C ***************************/ ! void DCreate PARM((DIAL *, Window, int, int, int, int, int, ! int, int, int, u_long, u_long, u_long, ! u_long, char *, char *)); ! void DSetRange PARM((DIAL *, int, int, int, int)); ! void DSetVal PARM((DIAL *, int)); void DSetActive PARM((DIAL *, int)); void DRedraw PARM((DIAL *)); int DTrack PARM((DIAL *, int, int)); --- 1489,1500 ---- /*************************** XVDIAL.C ***************************/ ! void DCreate PARM((DIAL *, Window, int, int, int, int, double, ! double, double, double, double, u_long, ! u_long, u_long, u_long, char *, char *)); ! void DSetRange PARM((DIAL *, double,double,double,double,double)); ! void DSetVal PARM((DIAL *, double)); void DSetActive PARM((DIAL *, int)); void DRedraw PARM((DIAL *)); int DTrack PARM((DIAL *, int, int)); *************** *** 1612,1617 **** --- 1636,1648 ---- void TIFFDialog PARM((int)); int TIFFCheckEvent PARM((XEvent *)); void TIFFSaveParams PARM((char *, int)); + + /**************************** XVPNG.C ***************************/ + int LoadPNG PARM((char *, PICINFO *)); + void CreatePNGW PARM((void)); + void PNGDialog PARM((int)); + int PNGCheckEvent PARM((XEvent *)); + void PNGSaveParams PARM((char *, int)); /**************************** XVPDS.C ***************************/ int LoadPDS PARM((char *, PICINFO *)); diff -c xvbmp.c.init xvbmp.c *** xvbmp.c.init Thu Dec 22 14:34:42 1994 --- xvbmp.c Sat May 12 15:37:23 2001 *************** *** 32,38 **** static int loadBMP1 PARM((FILE *, byte *, u_int, u_int)); static int loadBMP4 PARM((FILE *, byte *, u_int, u_int, u_int)); static int loadBMP8 PARM((FILE *, byte *, u_int, u_int, u_int)); ! static int loadBMP24 PARM((FILE *, byte *, u_int, u_int)); static u_int getshort PARM((FILE *)); static u_int getint PARM((FILE *)); static void putshort PARM((FILE *, int)); --- 32,38 ---- static int loadBMP1 PARM((FILE *, byte *, u_int, u_int)); static int loadBMP4 PARM((FILE *, byte *, u_int, u_int, u_int)); static int loadBMP8 PARM((FILE *, byte *, u_int, u_int, u_int)); ! static int loadBMP24 PARM((FILE *, byte *, u_int, u_int, u_int)); static u_int getshort PARM((FILE *)); static u_int getint PARM((FILE *)); static void putshort PARM((FILE *, int)); *************** *** 127,133 **** /* error checking */ ! if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && biBitCount!=24) || biPlanes!=1 || biCompression>BI_RLE4) { sprintf(buf,"Bogus BMP File! (bitCount=%d, Planes=%d, Compression=%d)", --- 127,134 ---- /* error checking */ ! if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && ! biBitCount!=24 && biBitCount!=32) || biPlanes!=1 || biCompression>BI_RLE4) { sprintf(buf,"Bogus BMP File! (bitCount=%d, Planes=%d, Compression=%d)", *************** *** 137,143 **** goto ERROR; } ! if (((biBitCount==1 || biBitCount==24) && biCompression != BI_RGB) || (biBitCount==4 && biCompression==BI_RLE8) || (biBitCount==8 && biCompression==BI_RLE4)) { --- 138,145 ---- goto ERROR; } ! if (((biBitCount==1 || biBitCount==24 || biBitCount==32) ! && biCompression != BI_RGB) || (biBitCount==4 && biCompression==BI_RLE8) || (biBitCount==8 && biCompression==BI_RLE4)) { *************** *** 159,165 **** } /* load up colormap, if any */ ! if (biBitCount!=24) { int i, cmaplen; cmaplen = (biClrUsed) ? biClrUsed : 1 << biBitCount; --- 161,167 ---- } /* load up colormap, if any */ ! if (biBitCount!=24 && biBitCount!=32) { int i, cmaplen; cmaplen = (biClrUsed) ? biClrUsed : 1 << biBitCount; *************** *** 197,203 **** /* create pic8 or pic24 */ ! if (biBitCount==24) { pic24 = (byte *) calloc((size_t) biWidth * biHeight * 3, (size_t) 1); if (!pic24) return (bmpError(bname, "couldn't malloc 'pic24'")); } --- 199,205 ---- /* create pic8 or pic24 */ ! if (biBitCount==24 || biBitCount==32) { pic24 = (byte *) calloc((size_t) biWidth * biHeight * 3, (size_t) 1); if (!pic24) return (bmpError(bname, "couldn't malloc 'pic24'")); } *************** *** 212,227 **** if (biBitCount == 1) rv = loadBMP1(fp,pic8,biWidth,biHeight); else if (biBitCount == 4) rv = loadBMP4(fp,pic8,biWidth,biHeight, biCompression); ! else if (biBitCount == 8) rv = loadBMP8(fp,pic8,biWidth,biHeight, biCompression); ! else rv = loadBMP24(fp,pic24,biWidth,biHeight); if (rv) bmpError(bname, "File appears truncated. Winging it.\n"); fclose(fp); ! if (biBitCount == 24) { pinfo->pic = pic24; pinfo->type = PIC24; } --- 214,231 ---- if (biBitCount == 1) rv = loadBMP1(fp,pic8,biWidth,biHeight); else if (biBitCount == 4) rv = loadBMP4(fp,pic8,biWidth,biHeight, biCompression); ! else if (biBitCount == 8) rv = loadBMP8(fp,pic8,biWidth,biHeight, biCompression); ! else rv = loadBMP24(fp,pic24,biWidth,biHeight, ! biBitCount); ! if (rv) bmpError(bname, "File appears truncated. Winging it.\n"); fclose(fp); ! if (biBitCount == 24 || biBitCount == 32) { pinfo->pic = pic24; pinfo->type = PIC24; } *************** *** 384,393 **** u_int w,h,comp; { int i,j,c,c1,padw,x,y,rv; ! byte *pp; rv = 0; if (comp == BI_RGB) { /* read uncompressed data */ padw = ((w + 3)/4) * 4; /* 'w' padded to a multiple of 4pix (32 bits) */ --- 388,399 ---- u_int w,h,comp; { int i,j,c,c1,padw,x,y,rv; ! byte *pp, *pend; rv = 0; + pend = pic8 + w * h; + if (comp == BI_RGB) { /* read uncompressed data */ padw = ((w + 3)/4) * 4; /* 'w' padded to a multiple of 4pix (32 bits) */ *************** *** 407,418 **** x = y = 0; pp = pic8 + x + (h-y-1)*w; ! while (y=0; i--) { pp = pic24 + (i * w * 3); *************** *** 474,479 **** --- 481,487 ---- pp[2] = getc(fp); /* blue */ pp[1] = getc(fp); /* green */ pp[0] = getc(fp); /* red */ + if (bits==32) getc(fp); pp += 3; } diff -c xvbrowse.c.init xvbrowse.c *** xvbrowse.c.init Thu Jan 19 09:49:17 1995 --- xvbrowse.c Sat May 12 15:37:23 2001 *************** *** 55,60 **** --- 55,61 ---- #include "bits/br_xpm" #include "bits/br_xwd" #include "bits/br_fits" + #include "bits/br_png" #include "bits/br_trash" #include "bits/fcurs" *************** *** 94,100 **** #define BF_XPM 25 #define BF_XWD 26 #define BF_FITS 27 ! #define BF_MAX 28 /* # of built-in icons */ #define ISLOADABLE(ftyp) (ftyp!=BF_DIR && ftyp!=BF_CHR && ftyp!=BF_BLK && \ ftyp!=BF_SOCK && ftyp!=BF_FIFO) --- 95,102 ---- #define BF_XPM 25 #define BF_XWD 26 #define BF_FITS 27 ! #define BF_PNG 28 ! #define BF_MAX 29 /* # of built-in icons */ #define ISLOADABLE(ftyp) (ftyp!=BF_DIR && ftyp!=BF_CHR && ftyp!=BF_BLK && \ ftyp!=BF_SOCK && ftyp!=BF_FIFO) *************** *** 524,529 **** --- 526,532 ---- bfIcons[BF_XPM] =MakePix1(br->win,br_xpm_bits, br_xpm_width, br_xpm_height); bfIcons[BF_XWD] =MakePix1(br->win,br_xwd_bits, br_xwd_width, br_xwd_height); bfIcons[BF_FITS]=MakePix1(br->win,br_fits_bits,br_fits_width,br_fits_height); + bfIcons[BF_PNG]=MakePix1(br->win,br_png_bits,br_png_width,br_png_height); /* check that they all got built */ *************** *** 956,961 **** --- 959,965 ---- char *str; { strncpy(br->dispstr, str, (size_t) 256); + br->dispstr[255] = '\0'; drawBrowStr(br); XFlush(theDisp); } *************** *** 1490,1495 **** --- 1494,1500 ---- if (StringWidth(str) > ISPACE_WIDE-6) { int dotpos; strncpy(tmpstr, str, (size_t) 56); + tmpstr[56] = '\0'; /* MR: otherwise it dies on long file names */ dotpos = strlen(tmpstr); strcat(tmpstr,"..."); *************** *** 1505,1511 **** nstr = tmpstr; } else nstr = str; ! /* draw the title */ sw = StringWidth(nstr); --- 1510,1516 ---- nstr = tmpstr; } else nstr = str; ! /* draw the title */ sw = StringWidth(nstr); *************** *** 3020,3025 **** --- 3025,3031 ---- case RFT_XPM: bf->ftype = BF_XPM; break; case RFT_XWD: bf->ftype = BF_XWD; break; case RFT_FITS: bf->ftype = BF_FITS; break; + case RFT_PNG: bf->ftype = BF_PNG; break; } } } *************** *** 3567,3572 **** --- 3573,3579 ---- case RFT_XPM: strcat(str,"XPM file"); break; case RFT_XWD: strcat(str,"XWD file"); break; case RFT_FITS: strcat(str,"FITS file"); break; + case RFT_PNG: strcat(str,"PNG file"); break; default: strcat(str,"file of unknown type"); break; } diff -c xvctrl.c.init xvctrl.c *** xvctrl.c.init Thu Dec 22 14:34:41 1994 --- xvctrl.c Sat May 12 15:37:23 2001 *************** *** 101,107 **** "Root: centered, warp", "Root: centered, brick", "Root: symmetrical tiled", ! "Root: symmetrical mirrored" }; static char *conv24MList[] = { "8-bit mode\t\2448", "24-bit mode\t\2448", --- 101,108 ---- "Root: centered, warp", "Root: centered, brick", "Root: symmetrical tiled", ! "Root: symmetrical mirrored", ! "Root: upper left corner" }; static char *conv24MList[] = { "8-bit mode\t\2448", "24-bit mode\t\2448", diff -c xvdial.c.init xvdial.c *** xvdial.c.init Tue Jan 3 13:20:31 1995 --- xvdial.c Sat May 12 15:37:23 2001 *************** *** 41,60 **** /* local functions */ ! static int whereInDial PARM((DIAL *, int, int)); ! static void drawArrow PARM((DIAL *)); ! static void drawValStr PARM((DIAL *)); ! static void drawButt PARM((DIAL *, int, int)); ! static int computeDialVal PARM((DIAL *, int, int)); ! static void dimDial PARM((DIAL *)); /***************************************************/ ! void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, page, fg, bg, hi, lo, title, units) DIAL *dp; Window parent; ! int x,y,w,h,minv,maxv,curv,page; unsigned long fg,bg,hi,lo; char *title, *units; { --- 41,61 ---- /* local functions */ ! static int whereInDial PARM((DIAL *, int, int)); ! static void drawArrow PARM((DIAL *)); ! static void drawValStr PARM((DIAL *)); ! static void drawButt PARM((DIAL *, int, int)); ! static double computeDialVal PARM((DIAL *, int, int)); ! static void dimDial PARM((DIAL *)); /***************************************************/ ! void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, inc, page, fg, bg, hi, lo, title, units) DIAL *dp; Window parent; ! int x,y,w,h; ! double minv,maxv,curv,inc,page; unsigned long fg,bg,hi,lo; char *title, *units; { *************** *** 98,115 **** 1,fg,bg); if (!dp->win) FatalError("can't create dial window"); ! DSetRange(dp, minv, maxv, curv, page); XSelectInput(theDisp, dp->win, ExposureMask | ButtonPressMask); } /***************************************************/ ! void DSetRange(dp, minv, maxv, curv, page) ! DIAL *dp; ! int minv, maxv, curv, page; { if (maxvmin = minv; dp->max = maxv; dp->page = page; dp->active = (minv < maxv); DSetVal(dp, curv); --- 99,116 ---- 1,fg,bg); if (!dp->win) FatalError("can't create dial window"); ! DSetRange(dp, minv, maxv, curv, inc, page); XSelectInput(theDisp, dp->win, ExposureMask | ButtonPressMask); } /***************************************************/ ! void DSetRange(dp, minv, maxv, curv, inc, page) ! DIAL *dp; ! double minv, maxv, curv, inc, page; { if (maxvmin = minv; dp->max = maxv; dp->inc = inc; dp->page = page; dp->active = (minv < maxv); DSetVal(dp, curv); *************** *** 118,125 **** /***************************************************/ void DSetVal(dp, curv) ! DIAL *dp; ! int curv; { RANGE(curv, dp->min, dp->max); /* make sure curv is in-range */ --- 119,126 ---- /***************************************************/ void DSetVal(dp, curv) ! DIAL *dp; ! double curv; { RANGE(curv, dp->min, dp->max); /* make sure curv is in-range */ *************** *** 129,135 **** XSetForeground(theDisp, theGC, dp->bg); drawArrow(dp); ! dp->val = curv; /* draw new arrow and string */ XSetForeground(theDisp, theGC, dp->fg); --- 130,136 ---- XSetForeground(theDisp, theGC, dp->bg); drawArrow(dp); ! dp->val = (double)((int)(curv / dp->inc + (curv > 0 ? 0.5 : -0.5))) * dp->inc; /* draw new arrow and string */ XSetForeground(theDisp, theGC, dp->fg); *************** *** 202,208 **** int mx,my; { Window rW,cW; ! int rx,ry, x,y, ipos, pos, lit, i, origval; unsigned int mask; lit = 0; --- 203,210 ---- int mx,my; { Window rW,cW; ! int rx, ry, x, y, ipos, pos, lit; ! double origval; unsigned int mask; lit = 0; *************** *** 224,232 **** if (ipos != INDIAL) { drawButt(dp, ipos, 1); switch (ipos) { ! case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+1); break; case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page); break; ! case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-1); break; case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page); break; } if (dp->drawobj != NULL) (dp->drawobj)(); --- 226,234 ---- if (ipos != INDIAL) { drawButt(dp, ipos, 1); switch (ipos) { ! case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->inc); break; case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page); break; ! case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->inc); break; case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page); break; } if (dp->drawobj != NULL) (dp->drawobj)(); *************** *** 235,242 **** } else { ! i = computeDialVal(dp, mx, my); ! DSetVal(dp, i); if (dp->drawobj != NULL) (dp->drawobj)(); } --- 237,245 ---- } else { ! double v; ! v = computeDialVal(dp, mx, my); ! DSetVal(dp, v); if (dp->drawobj != NULL) (dp->drawobj)(); } *************** *** 246,256 **** if (!(mask & Button1Mask)) break; /* button released */ if (ipos == INDIAL) { ! int j; ! i = computeDialVal(dp, x, y); ! j = dp->val; ! DSetVal(dp, i); ! if (j != dp->val) { /* track whatever dial controls */ if (dp->drawobj != NULL) (dp->drawobj)(); } --- 249,259 ---- if (!(mask & Button1Mask)) break; /* button released */ if (ipos == INDIAL) { ! double v, w; ! v = computeDialVal(dp, x, y); ! w = dp->val; ! DSetVal(dp, v); ! if (w != dp->val) { /* track whatever dial controls */ if (dp->drawobj != NULL) (dp->drawobj)(); } *************** *** 266,276 **** if (lit) { switch (ipos) { ! case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+1); break; case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page); break; ! case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-1); break; case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page); break; --- 269,279 ---- if (lit) { switch (ipos) { ! case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->inc); break; case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page); break; ! case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->inc); break; case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page); break; *************** *** 320,338 **** static void drawArrow(dp) DIAL *dp; { ! int i, rad, cx, cy; XPoint arrow[4]; rad = dp->rad; cx = dp->cx; cy = dp->cy; /* map pos (range minv..maxv) into degrees (range 240..-60) */ ! i = 240 + (-300 * (dp->val - dp->min)) / (dp->max - dp->min); ! arrow[0].x = cx + (int) ((double) rad * .80 * cos(i * DEG2RAD)); ! arrow[0].y = cy - (int) ((double) rad * .80 * sin(i * DEG2RAD)); ! arrow[1].x = cx + (int) ((double) rad * .33 * cos((i+160) * DEG2RAD)); ! arrow[1].y = cy - (int) ((double) rad * .33 * sin((i+160) * DEG2RAD)); ! arrow[2].x = cx + (int) ((double) rad * .33 * cos((i-160) * DEG2RAD)); ! arrow[2].y = cy - (int) ((double) rad * .33 * sin((i-160) * DEG2RAD)); arrow[3].x = arrow[0].x; arrow[3].y = arrow[0].y; XDrawLines(theDisp, dp->win, theGC, arrow, 4, CoordModeOrigin); --- 323,342 ---- static void drawArrow(dp) DIAL *dp; { ! int rad, cx, cy; ! double v; XPoint arrow[4]; rad = dp->rad; cx = dp->cx; cy = dp->cy; /* map pos (range minv..maxv) into degrees (range 240..-60) */ ! v = 240 + (-300 * (dp->val - dp->min)) / (dp->max - dp->min); ! arrow[0].x = cx + (int) ((double) rad * .80 * cos(v * DEG2RAD)); ! arrow[0].y = cy - (int) ((double) rad * .80 * sin(v * DEG2RAD)); ! arrow[1].x = cx + (int) ((double) rad * .33 * cos((v+160) * DEG2RAD)); ! arrow[1].y = cy - (int) ((double) rad * .33 * sin((v+160) * DEG2RAD)); ! arrow[2].x = cx + (int) ((double) rad * .33 * cos((v-160) * DEG2RAD)); ! arrow[2].y = cy - (int) ((double) rad * .33 * sin((v-160) * DEG2RAD)); arrow[3].x = arrow[0].x; arrow[3].y = arrow[0].y; XDrawLines(theDisp, dp->win, theGC, arrow, 4, CoordModeOrigin); *************** *** 343,365 **** static void drawValStr(dp) DIAL *dp; { ! int i, x1, x2; char foo[60], foo1[60]; /* compute longest string necessary so we can right-align this thing */ ! sprintf(foo,"%d",dp->min); x1 = strlen(foo); ! sprintf(foo,"%d",dp->max); x2 = strlen(foo); if (dp->min < 0 && dp->max > 0) x2++; /* put '+' at beginning */ i = x1; if (x2>x1) i = x2; if (dp->units) i += strlen(dp->units); ! if (dp->min < 0 && dp->max > 0) sprintf(foo,"%+d", dp->val); ! else sprintf(foo,"%d", dp->val); if (dp->units) strcat(foo,dp->units); foo1[0] = '\0'; if (strlen(foo) < (size_t) i) { ! for (i = i - strlen(foo); i>0; i--) strcat(foo1," "); } strcat(foo1, foo); --- 347,383 ---- static void drawValStr(dp) DIAL *dp; { ! int tot, i, x1, x2; char foo[60], foo1[60]; /* compute longest string necessary so we can right-align this thing */ ! sprintf(foo,"%d",(int)dp->min); x1 = strlen(foo); ! sprintf(foo,"%d",(int)dp->max); x2 = strlen(foo); if (dp->min < 0 && dp->max > 0) x2++; /* put '+' at beginning */ i = x1; if (x2>x1) i = x2; if (dp->units) i += strlen(dp->units); ! sprintf(foo,"%g",dp->inc); /* space for decimal values */ ! tot = i + strlen(foo) - 1; /* Take away the 0 from the beginning */ ! ! if (dp->min < 0.0 && dp->max > 0.0) sprintf(foo,"%+g", dp->val); ! else sprintf(foo,"%g", dp->val); ! ! if (dp->inc < 1.0) ! { ! int j; ! ! if (dp->val == (double)((int)dp->val)) ! strcat(foo,"."); ! ! for (j = strlen(foo); j < tot; j++) ! strcat(foo,"0"); ! } if (dp->units) strcat(foo,dp->units); foo1[0] = '\0'; if (strlen(foo) < (size_t) i) { ! for (i-=strlen(foo);i>0;i--) strcat(foo1," "); } strcat(foo1, foo); *************** *** 411,422 **** /***************************************************/ ! static int computeDialVal(dp, x, y) DIAL *dp; int x, y; { ! int dx, dy, val; ! double angle; /* compute dx, dy (distance from cx, cy). Note: +dy is *up* */ dx = x - dp->cx; dy = dp->cy - y; --- 429,441 ---- /***************************************************/ ! static double computeDialVal(dp, x, y) DIAL *dp; int x, y; { ! int dx, dy; ! ! double angle, val; /* compute dx, dy (distance from cx, cy). Note: +dy is *up* */ dx = x - dp->cx; dy = dp->cy - y; *************** *** 436,443 **** if (angle > 270.0) angle -= 360.0; if (angle < -90.0) angle += 360.0; ! val = (int) ((dp->max - dp->min) * (240.0 - angle) / 300.0) + dp->min; return val; } --- 455,464 ---- if (angle > 270.0) angle -= 360.0; if (angle < -90.0) angle += 360.0; ! val = ((dp->max - dp->min) * (240.0 - angle) / 300.0) + dp->min; + /* round value to be an even multiple of dp->inc */ + val = (double)((int)(val / dp->inc + 0.5)) * dp->inc; return val; } diff -c xvdir.c.init xvdir.c *** xvdir.c.init Tue Jan 3 13:21:39 1995 --- xvdir.c Sat May 12 15:37:23 2001 *************** *** 62,67 **** --- 62,70 ---- #ifdef HAVE_TIFF "TIFF", #endif + #ifdef HAVE_PNG + "PNG", + #endif "PostScript", "PBM/PGM/PPM (raw)", "PBM/PGM/PPM (ascii)", *************** *** 1115,1120 **** --- 1118,1132 ---- } #endif + #ifdef HAVE_PNG + else if (fmt == F_PNG) { /* PNG */ + PNGSaveParams(fullname, col); + PNGDialog(1); /* open PNG Dialog box */ + dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]); + return 0; /* always 'succeeds' */ + } + #endif + *************** *** 1168,1174 **** case F_XPM: rv = WriteXPM (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, ! fullname, picComments); case F_FITS: rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, picComments); --- 1180,1187 ---- case F_XPM: rv = WriteXPM (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, ! fullname, picComments); break; ! break; case F_FITS: rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, picComments); *************** *** 1200,1205 **** --- 1213,1219 ---- char *st; { strncpy(deffname, st, (size_t) MAXFNLEN-1); + deffname[MAXFNLEN-1] = '\0'; setFName(st); } *************** *** 1380,1393 **** (strcmp(lowsuf,"eps" )==0) || (strcmp(lowsuf,"rgb" )==0) || (strcmp(lowsuf,"tga" )==0) || - (strcmp(lowsuf,"xpm" )==0) || (strcmp(lowsuf,"fits")==0) || (strcmp(lowsuf,"fts" )==0) || (strcmp(lowsuf,"jpg" )==0) || (strcmp(lowsuf,"jpeg")==0) || (strcmp(lowsuf,"jfif")==0) || (strcmp(lowsuf,"tif" )==0) || ! (strcmp(lowsuf,"tiff")==0)) { /* found one. set lowsuf = to the new suffix, and tack on to filename */ --- 1394,1414 ---- (strcmp(lowsuf,"eps" )==0) || (strcmp(lowsuf,"rgb" )==0) || (strcmp(lowsuf,"tga" )==0) || (strcmp(lowsuf,"fits")==0) || (strcmp(lowsuf,"fts" )==0) || + #ifdef HAVE_JPEG (strcmp(lowsuf,"jpg" )==0) || (strcmp(lowsuf,"jpeg")==0) || (strcmp(lowsuf,"jfif")==0) || + #endif + #ifdef HAVE_TIFF (strcmp(lowsuf,"tif" )==0) || ! (strcmp(lowsuf,"tiff")==0) || ! #endif ! #ifdef HAVE_PNG ! (strcmp(lowsuf,"png" )==0) || ! #endif ! (strcmp(lowsuf,"xpm" )==0)) { /* found one. set lowsuf = to the new suffix, and tack on to filename */ *************** *** 1422,1427 **** --- 1443,1452 ---- #ifdef HAVE_TIFF case F_TIFF: strcpy(lowsuf,"tif"); break; + #endif + + #ifdef HAVE_PNG + case F_PNG: strcpy(lowsuf,"png"); break; #endif } diff -c xvevent.c.init xvevent.c *** xvevent.c.init Mon Jan 23 15:20:24 1995 --- xvevent.c Sat May 12 15:37:23 2001 *************** *** 154,160 **** int *donep; { static int wasInfoUp=0, wasCtrlUp=0, wasDirUp=0, wasGamUp=0, wasPsUp=0; ! static int wasJpegUp=0, wasTiffUp=0; static int mainWKludge=0; /* force first mainW expose after a mainW config to redraw all of mainW */ --- 154,160 ---- int *donep; { static int wasInfoUp=0, wasCtrlUp=0, wasDirUp=0, wasGamUp=0, wasPsUp=0; ! static int wasJpegUp=0, wasTiffUp=0, wasPngUp=0; static int mainWKludge=0; /* force first mainW expose after a mainW config to redraw all of mainW */ *************** *** 233,238 **** --- 233,242 ---- if (TIFFCheckEvent(event)) break; /* event has been processed */ #endif + #ifdef HAVE_PNG + if (PNGCheckEvent (event)) break; /* event has been processed */ + #endif + if (GamCheckEvent (event)) break; /* event has been processed */ if (BrowseCheckEvent (event, &retval, &done)) break; /* event eaten */ if (TextCheckEvent (event, &retval, &done)) break; /* event eaten */ *************** *** 359,364 **** --- 363,372 ---- else if (client_event->window == tiffW) TIFFDialog(0); #endif + #ifdef HAVE_PNG + else if (client_event->window == pngW) PNGDialog(0); + #endif + else if (client_event->window == mainW) Quit(0); } } *************** *** 538,543 **** --- 546,555 ---- #ifdef HAVE_TIFF if (wasTiffUp) { TIFFDialog(wasTiffUp); wasTiffUp=0; } #endif + + #ifdef HAVE_PNG + if (wasPngUp) { PNGDialog(wasJpegUp); wasPngUp=0; } + #endif } } } *************** *** 576,581 **** --- 588,597 ---- #ifdef HAVE_TIFF if (tiffUp) { wasTiffUp = tiffUp; TIFFDialog(0); } #endif + + #ifdef HAVE_PNG + if (pngUp) { wasPngUp = pngUp; PNGDialog(0); } + #endif } } } *************** *** 1147,1152 **** --- 1163,1172 ---- if (TIFFCheckEvent(event)) break; #endif + #ifdef HAVE_PNG + if (PNGCheckEvent (event)) break; + #endif + if (GamCheckEvent (event)) break; if (BrowseCheckEvent (event, &retval, &done)) break; if (TextCheckEvent (event, &retval, &done)) break; *************** *** 1366,1371 **** --- 1386,1395 ---- if (TIFFCheckEvent(event)) break; #endif + #ifdef HAVE_PNG + if (PNGCheckEvent (event)) break; + #endif + if (GamCheckEvent (event)) break; if (BrowseCheckEvent (event, &retval, &done)) break; if (TextCheckEvent (event, &retval, &done)) break; *************** *** 2370,2375 **** --- 2394,2403 ---- #ifdef HAVE_TIFF if (tiffUp) TIFFDialog(0); /* close tiff window */ + #endif + + #ifdef HAVE_PNG + if (pngUp) PNGDialog(0); /* close png window */ #endif ClosePopUp(); diff -c xvgam.c.init xvgam.c *** xvgam.c.init Fri Jan 13 11:51:14 1995 --- xvgam.c Sat May 12 15:37:23 2001 *************** *** 265,275 **** BTCreate(&gbut[G_BRNDCOL], cmapF, 5 + 66 + 67 + 2, 189, 66, BUTTH, "Random", infofg, infobg, hicol, locol); ! DCreate(&rhDial, cmapF, 5, 215, 66, 100, 0,360,180, 5, infofg, infobg, hicol, locol, "Hue", NULL); ! DCreate(&gsDial, cmapF, 72, 215, 66, 100, 0,360,180, 5, infofg, infobg, hicol, locol, "Sat.", NULL); ! DCreate(&bvDial, cmapF, 139, 215, 66, 100, 0,360,180, 5, infofg, infobg, hicol, locol, "Value", NULL); rhDial.drawobj = gsDial.drawobj = bvDial.drawobj = dragEditColor; --- 265,275 ---- BTCreate(&gbut[G_BRNDCOL], cmapF, 5 + 66 + 67 + 2, 189, 66, BUTTH, "Random", infofg, infobg, hicol, locol); ! DCreate(&rhDial, cmapF, 5, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0, infofg, infobg, hicol, locol, "Hue", NULL); ! DCreate(&gsDial, cmapF, 72, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0, infofg, infobg, hicol, locol, "Sat.", NULL); ! DCreate(&bvDial, cmapF, 139, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0, infofg, infobg, hicol, locol, "Value", NULL); rhDial.drawobj = gsDial.drawobj = bvDial.drawobj = dragEditColor; *************** *** 359,365 **** srcHD.drawobj = dstHD.drawobj = whtHD.drawobj = dragHueDial; ! DCreate(&satDial, hsvF, 100, 199, 100, 121, -100, 100, 0, 5, infofg, infobg,hicol,locol, "Saturation", "%"); hueRB = RBCreate(NULL, hsvF, 7, 153, "1", --- 359,365 ---- srcHD.drawobj = dstHD.drawobj = whtHD.drawobj = dragHueDial; ! DCreate(&satDial, hsvF, 100, 199, 100, 121, -100.0, 100.0, 0.0, 1.0, 5.0, infofg, infobg,hicol,locol, "Saturation", "%"); hueRB = RBCreate(NULL, hsvF, 7, 153, "1", *************** *** 722,728 **** if (whtHD.enabCB.val && whtHD.satval) hsvnonlinear++; ! if (satDial.val != 0) hsvnonlinear++; /* check intensity graf */ for (i=0; i<256 && intGraf.func[i]==i; i++); --- 722,728 ---- if (whtHD.enabCB.val && whtHD.satval) hsvnonlinear++; ! if (satDial.val != 0.0) hsvnonlinear++; /* check intensity graf */ for (i=0; i<256 && intGraf.func[i]==i; i++); *************** *** 1291,1304 **** rgb2hsv(rcmap[editColor], gcmap[editColor], bcmap[editColor], &h, &s, &v); if (h<0) h = 0; ! DSetVal(&rhDial, (int) h); ! DSetVal(&gsDial, (int) (s*100)); ! DSetVal(&bvDial, (int) (v*100)); } else { ! DSetVal(&rhDial, rcmap[editColor]); ! DSetVal(&gsDial, gcmap[editColor]); ! DSetVal(&bvDial, bcmap[editColor]); } } --- 1291,1304 ---- rgb2hsv(rcmap[editColor], gcmap[editColor], bcmap[editColor], &h, &s, &v); if (h<0) h = 0; ! DSetVal(&rhDial, h); ! DSetVal(&gsDial, s*100); ! DSetVal(&bvDial, v*100); } else { ! DSetVal(&rhDial, (double)rcmap[editColor]); ! DSetVal(&gsDial, (double)gcmap[editColor]); ! DSetVal(&bvDial, (double)bcmap[editColor]); } } *************** *** 1310,1325 **** if (hsvmode) { int rv, gv, bv; ! hsv2rgb((double) rhDial.val, ((double) gsDial.val) / 100.0, ! ((double) bvDial.val) / 100.0, &rv, &gv, &bv); rcmap[editColor] = rv; gcmap[editColor] = gv; bcmap[editColor] = bv; } else { ! rcmap[editColor] = rhDial.val; ! gcmap[editColor] = gsDial.val; ! bcmap[editColor] = bvDial.val; } } --- 1310,1324 ---- if (hsvmode) { int rv, gv, bv; ! hsv2rgb(rhDial.val, gsDial.val / 100.0, bvDial.val / 100.0, &rv, &gv, &bv); rcmap[editColor] = rv; gcmap[editColor] = gv; bcmap[editColor] = bv; } else { ! rcmap[editColor] = (int)rhDial.val; ! gcmap[editColor] = (int)gsDial.val; ! bcmap[editColor] = (int)bvDial.val; } } *************** *** 1561,1569 **** gsDial.title = "Green"; bvDial.title = "Blue"; ! DSetRange(&rhDial, 0, 255, rcmap[editColor], 16); ! DSetRange(&gsDial, 0, 255, gcmap[editColor], 16); ! DSetRange(&bvDial, 0, 255, bcmap[editColor], 16); XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial); XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial); --- 1560,1568 ---- gsDial.title = "Green"; bvDial.title = "Blue"; ! DSetRange(&rhDial, 0.0, 255.0, (double)rcmap[editColor], 1.0, 16.0); ! DSetRange(&gsDial, 0.0, 255.0, (double)gcmap[editColor], 1.0, 16.0); ! DSetRange(&bvDial, 0.0, 255.0, (double)bcmap[editColor], 1.0, 16.0); XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial); XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial); *************** *** 1581,1589 **** &h, &s, &v); if (h<0.0) h = 0.0; ! DSetRange(&rhDial, 0, 360, (int) h, 5); ! DSetRange(&gsDial, 0, 100, (int) (s*100), 5); ! DSetRange(&bvDial, 0, 100, (int) (v*100), 5); XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial); XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial); --- 1580,1588 ---- &h, &s, &v); if (h<0.0) h = 0.0; ! DSetRange(&rhDial, 0.0, 360.0, h, 1.0, 5.0); ! DSetRange(&gsDial, 0.0, 100.0, s*100, 1.0, 5.0); ! DSetRange(&bvDial, 0.0, 100.0, v*100, 1.0, 5.0); XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial); XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial); *************** *** 1891,1897 **** } /* apply satDial value to s */ ! s = s + ((double) satDial.val) / 100.0; if (s<0.0) s = 0.0; if (s>1.0) s = 1.0; --- 1890,1896 ---- } /* apply satDial value to s */ ! s = s + satDial.val / 100.0; if (s<0.0) s = 0.0; if (s>1.0) s = 1.0; *************** *** 2007,2013 **** gs->hueRBnum = RBWhich(hueRB); ! gs->satval = satDial.val; GetGrafState(&intGraf,&gs->istate); GetGrafState(&rGraf, &gs->rstate); GetGrafState(&gGraf, &gs->gstate); --- 2006,2012 ---- gs->hueRBnum = RBWhich(hueRB); ! gs->satval = (int)satDial.val; GetGrafState(&intGraf,&gs->istate); GetGrafState(&rGraf, &gs->rstate); GetGrafState(&gGraf, &gs->gstate); *************** *** 2064,2071 **** changed++; } ! if (gs->satval != satDial.val) { ! DSetVal(&satDial,gs->satval); changed++; } --- 2063,2070 ---- changed++; } ! if (gs->satval != (int)satDial.val) { ! DSetVal(&satDial,(double)gs->satval); changed++; } *************** *** 3200,3206 **** if (whtHD.enabCB.val && whtHD.satval) hsvmod++; ! if (satDial.val != 0) hsvmod++; /* check intensity graf */ for (i=0; i<256; i++) { --- 3199,3205 ---- if (whtHD.enabCB.val && whtHD.satval) hsvmod++; ! if (satDial.val != 0.0) hsvmod++; /* check intensity graf */ for (i=0; i<256; i++) { *************** *** 3284,3290 **** } /* apply satDial value to s */ ! s = s + satDial.val; if (s< 0) s = 0; if (s>100) s = 100; --- 3283,3289 ---- } /* apply satDial value to s */ ! s = s + (int)satDial.val; if (s< 0) s = 0; if (s>100) s = 100; diff -c xvgif.c.init xvgif.c *** xvgif.c.init Tue Jan 10 11:54:41 1995 --- xvgif.c Sat May 12 15:37:23 2001 *************** *** 113,119 **** int aspect, gotimage; /* initialize variables */ ! BitOffset = XC = YC = Pass = OutCount = gotimage = 0; RawGIF = Raster = pic8 = NULL; gif89 = 0; --- 113,120 ---- int aspect, gotimage; /* initialize variables */ ! BitOffset = XC = YC = OutCount = gotimage = 0; ! Pass = -1; RawGIF = Raster = pic8 = NULL; gif89 = 0; *************** *** 692,698 **** { static byte *ptr = NULL; static int oldYC = -1; ! if (oldYC != YC) { ptr = pic8 + YC * Width; oldYC = YC; } if (YCbitmap_unit; - bits_used = bits_per_item; bits_per_pixel = image->bits_per_pixel; if (bits_per_pixel == 32) pixmask = 0xffffffff; else pixmask = (((CARD32) 1) << bits_per_pixel) - 1; --- 641,667 ---- bits_per_item = image->bitmap_unit; bits_per_pixel = image->bits_per_pixel; + + + /* add code for freako 'exceed' server, where bitmapunit = 8 + and bitsperpix = 32 (and depth=24)... */ + + if (bits_per_item < bits_per_pixel) { + bits_per_item = bits_per_pixel; + + /* round bits_per_item up to next legal value, if necc */ + if (bits_per_item < 8) bits_per_item = 8; + else if (bits_per_item < 16) bits_per_item = 16; + else bits_per_item = 32; + } + + + /* which raises the question: how (can?) you ever have a 24 bits per pix, + (ie, 3 bytes, no alpha/padding) */ + + + bits_used = bits_per_item; /* so it will get a new item first time */ if (bits_per_pixel == 32) pixmask = 0xffffffff; else pixmask = (((CARD32) 1) << bits_per_pixel) - 1; diff -c xvimage.c.init xvimage.c *** xvimage.c.init Fri Jan 13 16:11:36 1995 --- xvimage.c Sat May 12 15:37:23 2001 *************** *** 1736,1745 **** if (xim->byte_order == MSBFirst) { for (i=wide*high, ip=imagedata; i>0; i--,pp++) { if (((i+1)&0x1ffff) == 0) WaitCursor(); ! if (dithpic) { ! *ip++ = ((*pp) ? white : black) & 0xffff; ! } ! else *ip++ = xcolors[*pp] & 0xffff; } } else { /* LSBFirst */ --- 1736,1747 ---- if (xim->byte_order == MSBFirst) { for (i=wide*high, ip=imagedata; i>0; i--,pp++) { if (((i+1)&0x1ffff) == 0) WaitCursor(); ! ! if (dithpic) xcol = ((*pp) ? white : black) & 0xffff; ! else xcol = xcolors[*pp] & 0xffff; ! ! *((unsigned char *)ip)++ = (xcol>>8) & 0xff; ! *((unsigned char *)ip)++ = (xcol) & 0xff; } } else { /* LSBFirst */ *************** *** 1749,1756 **** if (dithpic) xcol = ((*pp) ? white : black) & 0xffff; else xcol = xcolors[*pp]; ! /* WAS *ip++ = ((xcol>>8) & 0xff) | ((xcol&0xff) << 8); */ ! *ip++ = (unsigned short) (xcol); } } } --- 1751,1758 ---- if (dithpic) xcol = ((*pp) ? white : black) & 0xffff; else xcol = xcolors[*pp]; ! *((unsigned char *)ip)++ = (xcol) & 0xff; ! *((unsigned char *)ip)++ = (xcol>>8) & 0xff; } } } diff -c xvjpeg.c.init xvjpeg.c *** xvjpeg.c.init Thu Jan 5 00:17:13 1995 --- xvjpeg.c Sat May 12 15:37:23 2001 *************** *** 51,61 **** static void clickJD PARM((int, int)); static void doCmd PARM((int)); static void writeJPEG PARM((void)); ! METHODDEF void xv_error_exit PARM((j_common_ptr)); ! METHODDEF void xv_error_output PARM((j_common_ptr)); ! METHODDEF void xv_prog_meter PARM((j_common_ptr)); static unsigned int j_getc PARM((j_decompress_ptr)); ! METHODDEF boolean xv_process_comment PARM((j_decompress_ptr)); static int writeJFIF PARM((FILE *, byte *, int,int,int)); --- 51,61 ---- static void clickJD PARM((int, int)); static void doCmd PARM((int)); static void writeJPEG PARM((void)); ! METHODDEF(void) xv_error_exit PARM((j_common_ptr)); ! METHODDEF(void) xv_error_output PARM((j_common_ptr)); ! METHODDEF(void) xv_prog_meter PARM((j_common_ptr)); static unsigned int j_getc PARM((j_decompress_ptr)); ! METHODDEF(boolean) xv_process_comment PARM((j_decompress_ptr)); static int writeJFIF PARM((FILE *, byte *, int,int,int)); *************** *** 87,96 **** XSelectInput(theDisp, jpegW, ExposureMask | ButtonPressMask | KeyPressMask); ! DCreate(&qDial, jpegW, 10, 10, 80, 100, 1, 100, 75, 5, infofg, infobg, hicol, locol, "Quality", "%"); ! DCreate(&smDial, jpegW, 120, 10, 80, 100, 0, 100, 0, 5, infofg, infobg, hicol, locol, "Smoothing", "%"); BTCreate(&jbut[J_BOK], jpegW, JWIDE-180-1, JHIGH-10-BUTTH-1, 80, BUTTH, --- 87,96 ---- XSelectInput(theDisp, jpegW, ExposureMask | ButtonPressMask | KeyPressMask); ! DCreate(&qDial, jpegW, 10, 10, 80, 100, 1.0, 100.0, 75.0, 1.0, 5.0, infofg, infobg, hicol, locol, "Quality", "%"); ! DCreate(&smDial, jpegW, 120, 10, 80, 100, 0.0, 100.0, 0.0, 1.0, 5.0, infofg, infobg, hicol, locol, "Smoothing", "%"); BTCreate(&jbut[J_BOK], jpegW, JWIDE-180-1, JHIGH-10-BUTTH-1, 80, BUTTH, *************** *** 400,406 **** /**************************************************/ ! METHODDEF void xv_error_exit(cinfo) j_common_ptr cinfo; { my_error_ptr myerr; --- 400,406 ---- /**************************************************/ ! METHODDEF(void) xv_error_exit(cinfo) j_common_ptr cinfo; { my_error_ptr myerr; *************** *** 412,418 **** /**************************************************/ ! METHODDEF void xv_error_output(cinfo) j_common_ptr cinfo; { my_error_ptr myerr; --- 412,418 ---- /**************************************************/ ! METHODDEF(void) xv_error_output(cinfo) j_common_ptr cinfo; { my_error_ptr myerr; *************** *** 426,432 **** /**************************************************/ ! METHODDEF void xv_prog_meter(cinfo) j_common_ptr cinfo; { struct jpeg_progress_mgr *prog; --- 426,432 ---- /**************************************************/ ! METHODDEF(void) xv_prog_meter(cinfo) j_common_ptr cinfo; { struct jpeg_progress_mgr *prog; *************** *** 671,677 **** /**************************************************/ ! METHODDEF boolean xv_process_comment(cinfo) j_decompress_ptr cinfo; { int length, hasnull; --- 671,677 ---- /**************************************************/ ! METHODDEF(boolean) xv_process_comment(cinfo) j_decompress_ptr cinfo; { int length, hasnull; *************** *** 759,766 **** jpeg_set_defaults(&cinfo); ! jpeg_set_quality(&cinfo, qDial.val, TRUE); ! cinfo.smoothing_factor = smDial.val; jpeg_start_compress(&cinfo, TRUE); --- 759,766 ---- jpeg_set_defaults(&cinfo); ! jpeg_set_quality(&cinfo, (int)qDial.val, TRUE); ! cinfo.smoothing_factor = (int)smDial.val; jpeg_start_compress(&cinfo, TRUE); *************** *** 769,775 **** /*** COMMENT HANDLING ***/ sprintf(xvcmt, "%sXV %s Quality = %d, Smoothing = %d\n", ! CREATOR_STR, REVDATE, qDial.val, smDial.val); if (picComments) { /* append XV comment */ char *sp, *sp1; int done; --- 769,775 ---- /*** COMMENT HANDLING ***/ sprintf(xvcmt, "%sXV %s Quality = %d, Smoothing = %d\n", ! CREATOR_STR, REVDATE, (int)qDial.val, (int)smDial.val); if (picComments) { /* append XV comment */ char *sp, *sp1; int done; diff -c xvmisc.c.init xvmisc.c *** xvmisc.c.init Fri Jan 13 15:41:34 1995 --- xvmisc.c Sat May 12 15:37:23 2001 *************** *** 520,525 **** --- 520,529 ---- if (tiffW) XDestroyWindow(theDisp, tiffW); #endif + #ifdef HAVE_PNG + if (pngW) XDestroyWindow(theDisp, pngW); + #endif + /* if NOT using stdcmap for images, free stdcmap */ if (colorMapMode != CM_STDCMAP) { int j; *************** *** 715,720 **** --- 719,728 ---- #ifdef HAVE_TIFF if (tiffW) XDefineCursor(theDisp, tiffW, otherc); + #endif + + #ifdef HAVE_PNG + if (pngW) XDefineCursor(theDisp, pngW, otherc); #endif } diff -c /dev/null xvpng.c *** /dev/null Thu Aug 24 02:00:32 2000 --- xvpng.c Sat May 12 15:37:23 2001 *************** *** 0 **** --- 1,991 ---- + /* + * xvpng.c - load and write routines for 'PNG' format pictures + * + * callable functions + * + * CreatePNGW() + * PNGDialog(vis) + * PNGCheckEvent(xev) + * PNGSaveParams(fname, col) + * LoadPNG(fname, pinfo) + */ + + /*#include "copyright.h"*/ + /* (c) 1995 by Alexander Lehmann + * this file is a suplement to xv and is supplied under the same copying + * conditions (except the shareware part) + * Modified by Andreas Dilger to fix + * error handling for bad PNGs, add dialogs for interlacing and + * compression selection, and upgrade to libpng-0.89 + * The copyright will be passed on to JB at some future point if he + * so desires. + */ + + #include "xv.h" + + #ifdef HAVE_PNG + + #include "png.h" + + /*** Stuff for PNG Dialog box ***/ + #define PWIDE 318 + #define PHIGH 215 + + #define DISPLAY_GAMMA 2.20 /* Default display gamma */ + /* Default zlib compression level + #define COMPRESSION Z_BEST_COMPRESSION + */ + #define COMPRESSION 6 + + #define DWIDE 86 + #define DHIGH 104 + #define PFX PWIDE-93 + #define PFY 44 + #define PFH 20 + + #define P_BOK 0 + #define P_BCANC 1 + #define P_NBUTTS 2 + + #define BUTTH 24 + + #define LF 10 /* a.k.a. '\n' on ASCII machines */ + #define CR 13 /* a.k.a. '\r' on ASCII machines */ + + /*** local functions ***/ + static void drawPD PARM((int, int, int, int)); + static void clickPD PARM((int, int)); + static void doCmd PARM((int)); + static void writePNG PARM((void)); + static int WritePNG PARM((FILE *, byte *, int, int, int, + byte *, byte *, byte *, int)); + + static void png_xv_error PARM((png_structp png_ptr, + png_const_charp message)); + static void png_xv_warning PARM((png_structp png_ptr, + png_const_charp message)); + + /*** local variables ***/ + static char *filename; + static char *fbasename; + static int colorType; + static int read_anything; + static double Display_Gamma = DISPLAY_GAMMA; + + static DIAL cDial, gDial; + static BUTT pbut[P_NBUTTS]; + static CBUTT interCB; + static CBUTT FdefCB, FnoneCB, FsubCB, FupCB, FavgCB, FPaethCB; + + /**************************************************************************/ + /* PNG SAVE DIALOG ROUTINES ***********************************************/ + /**************************************************************************/ + + + /*******************************************/ + void CreatePNGW() + { + pngW = CreateWindow("xv png", "XVPNG", NULL, + PWIDE, PHIGH, infofg, infobg, 0); + if (!pngW) FatalError("can't create PNG window!"); + + XSelectInput(theDisp, pngW, ExposureMask | ButtonPressMask | KeyPressMask); + + DCreate(&cDial, pngW, 12, 25, DWIDE, DHIGH, (double)Z_NO_COMPRESSION, + (double)Z_BEST_COMPRESSION, COMPRESSION, 1.0, 3.0, + infofg, infobg, hicol, locol, "Compression", NULL); + + DCreate(&gDial, pngW, DWIDE+27, 25, DWIDE, DHIGH, 1.0, 3.5,DISPLAY_GAMMA,0.01,0.2, + infofg, infobg, hicol, locol, "Disp. Gamma", NULL); + + CBCreate(&interCB, pngW, DWIDE+30, DHIGH+3*LINEHIGH+2, "interlace", + infofg, infobg, hicol, locol); + + CBCreate(&FdefCB, pngW, PFX, PFY, "Default", + infofg, infobg, hicol, locol); + FdefCB.val = 1; + + CBCreate(&FnoneCB, pngW, PFX, FdefCB.y + PFH + 4, "none", + infofg, infobg, hicol, locol); + CBCreate(&FsubCB, pngW, PFX, FnoneCB.y + PFH, "sub", + infofg, infobg, hicol, locol); + CBCreate(&FupCB, pngW, PFX, FsubCB.y + PFH, "up", + infofg, infobg, hicol, locol); + CBCreate(&FavgCB, pngW, PFX, FupCB.y + PFH, "average", + infofg, infobg, hicol, locol); + CBCreate(&FPaethCB, pngW, PFX, FavgCB.y + PFH, "Paeth", + infofg, infobg, hicol, locol); + + FnoneCB.val = FsubCB.val = FupCB.val = FavgCB.val = FPaethCB.val = 1; + CBSetActive(&FnoneCB, !FdefCB.val); + CBSetActive(&FsubCB, !FdefCB.val); + CBSetActive(&FupCB, !FdefCB.val); + CBSetActive(&FavgCB, !FdefCB.val); + CBSetActive(&FPaethCB, !FdefCB.val); + + BTCreate(&pbut[P_BOK], pngW, PWIDE-180-1, PHIGH-10-BUTTH-1, 80, BUTTH, + "Ok", infofg, infobg, hicol, locol); + BTCreate(&pbut[P_BCANC], pngW, PWIDE-90-1, PHIGH-10-BUTTH-1, 80, BUTTH, + "Cancel", infofg, infobg, hicol, locol); + + XMapSubwindows(theDisp, pngW); + } + + + /*******************************************/ + void PNGDialog(vis) + int vis; + { + if (vis) { + CenterMapWindow(pngW, pbut[P_BOK].x + (int) pbut[P_BOK].w/2, + pbut[P_BOK].y + (int) pbut[P_BOK].h/2, + PWIDE, PHIGH); + } + else XUnmapWindow(theDisp, pngW); + pngUp = vis; + } + + + /*******************************************/ + int PNGCheckEvent(xev) + XEvent *xev; + { + /* check event to see if it's for one of our subwindows. If it is, + deal accordingly, and return '1'. Otherwise, return '0' */ + + int rv; + rv = 1; + + if (!pngUp) return 0; + + if (xev->type == Expose) { + int x,y,w,h; + XExposeEvent *e = (XExposeEvent *) xev; + x = e->x; y = e->y; w = e->width; h = e->height; + + /* throw away excess expose events for 'dumb' windows */ + if (e->count > 0 && (e->window == cDial.win)) {} + + else if (e->window == pngW) drawPD(x, y, w, h); + else if (e->window == cDial.win) DRedraw(&cDial); + else if (e->window == gDial.win) DRedraw(&gDial); + else rv = 0; + } + + else if (xev->type == ButtonPress) { + XButtonEvent *e = (XButtonEvent *) xev; + int x,y; + x = e->x; y = e->y; + + if (e->button == Button1) { + if (e->window == pngW) clickPD(x,y); + else if (e->window == cDial.win) DTrack(&cDial,x,y); + else if (e->window == gDial.win) DTrack(&gDial,x,y); + else rv = 0; + } /* button1 */ + else rv = 0; + } /* button press */ + + else if (xev->type == KeyPress) { + XKeyEvent *e = (XKeyEvent *) xev; + char buf[128]; KeySym ks; + int stlen; + + stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL); + buf[stlen] = '\0'; + + RemapKeyCheck(ks, buf, &stlen); + + if (e->window == pngW) { + if (stlen) { + if (buf[0] == '\r' || buf[0] == '\n') { /* enter */ + FakeButtonPress(&pbut[P_BOK]); + } + else if (buf[0] == '\033') { /* ESC */ + FakeButtonPress(&pbut[P_BCANC]); + } + } + } + else rv = 0; + } + else rv = 0; + + if (rv==0 && (xev->type == ButtonPress || xev->type == KeyPress)) { + XBell(theDisp, 50); + rv = 1; /* eat it */ + } + + return rv; + } + + + /*******************************************/ + void PNGSaveParams(fname, col) + char *fname; + int col; + { + filename = fname; + colorType = col; + } + + + /*******************************************/ + static void drawPD(x, y, w, h) + int x, y, w, h; + { + char *title = "Save PNG file..."; + + char ctitle1[20]; + char *ctitle2 = "Useful range"; + char *ctitle3 = "is 2 - 7."; + char *ctitle4 = "Uncompressed = 0"; + + char *ftitle = "Row Filters:"; + + char gtitle[20]; + + int i; + XRectangle xr; + + xr.x = x; xr.y = y; xr.width = w; xr.height = h; + XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted); + + XSetForeground(theDisp, theGC, infofg); + XSetBackground(theDisp, theGC, infobg); + + for (i=0; ix, bp->y, bp->w, bp->h)) break; + } + + if (ijmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + return -1; + } + + png_init_io(png_ptr, fp); + + png_set_compression_level(png_ptr, (int)cDial.val); + + /* Don't bother filtering if we aren't compressing the image */ + if (FdefCB.val) + { + if ((int)cDial.val == 0) + png_set_filter(png_ptr, 0, PNG_FILTER_NONE); + } + else + { + filter = FnoneCB.val ? PNG_FILTER_NONE : 0; + filter |= FsubCB.val ? PNG_FILTER_SUB : 0; + filter |= FupCB.val ? PNG_FILTER_UP : 0; + filter |= FavgCB.val ? PNG_FILTER_AVG : 0; + filter |= FPaethCB.val ? PNG_FILTER_PAETH : 0; + + png_set_filter(png_ptr, 0, filter); + } + + info_ptr->width = w; + info_ptr->height = h; + + info_ptr->interlace_type = interCB.val ? 1 : 0; + + if (colorType == F_FULLCOLOR || colorType == F_REDUCED) { + if(ptype == PIC24) { + linesize = 3*w; + info_ptr->color_type = PNG_COLOR_TYPE_RGB; + info_ptr->bit_depth = 8; + } else { + linesize = w; + info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; + if(numcols <= 2) + info_ptr->bit_depth = 1; + else + if(numcols <= 4) + info_ptr->bit_depth = 2; + else + if(numcols <= 16) + info_ptr->bit_depth = 4; + else + info_ptr->bit_depth = 8; + + for(i = 0; i < numcols; i++) { + palette[i].red = rmap[i]; + palette[i].green = gmap[i]; + palette[i].blue = bmap[i]; + } + info_ptr->num_palette = numcols; + info_ptr->palette = palette; + info_ptr->valid |= PNG_INFO_PLTE; + } + } + + else if(colorType == F_GREYSCALE || colorType == F_BWDITHER) { + info_ptr->color_type = PNG_COLOR_TYPE_GRAY; + if(colorType == F_BWDITHER) { + /* shouldn't happen */ + if (ptype == PIC24) FatalError("PIC24 and B/W Stipple in WritePNG()"); + + info_ptr->bit_depth = 1; + if(MONO(rmap[0], gmap[0], bmap[0]) > MONO(rmap[1], gmap[1], bmap[1])) { + remap[0] = 1; + remap[1] = 0; + } + else { + remap[0] = 0; + remap[1] = 1; + } + linesize = w; + } + else { + if(ptype == PIC24) { + linesize = w*3; + info_ptr->bit_depth = 8; + } + else { + int low_presc; + + linesize = w; + + for(i = 0; i < numcols; i++) + remap[i] = MONO(rmap[i], gmap[i], bmap[i]); + + for(; i < 256; i++) + remap[i]=0; + + info_ptr->bit_depth = 8; + + /* Note that this fails most of the time because of gamma */ + /* try to adjust to 4 bit prescision grayscale */ + + low_presc=1; + + for(i = 0; i < numcols; i++) { + if((remap[i] & 0x0f) * 0x11 != remap[i]) { + low_presc = 0; + break; + } + } + + if(low_presc) { + for(i = 0; i < numcols; i++) { + remap[i] &= 0xf; + } + info_ptr->bit_depth = 4; + + /* try to adjust to 2 bit prescision grayscale */ + + for(i = 0; i < numcols; i++) { + if((remap[i] & 0x03) * 0x05 != remap[i]) { + low_presc = 0; + break; + } + } + } + + if(low_presc) { + for(i = 0; i < numcols; i++) { + remap[i] &= 3; + } + info_ptr->bit_depth = 2; + + /* try to adjust to 1 bit prescision grayscale */ + + for(i = 0; i < numcols; i++) { + if((remap[i] & 0x01) * 0x03 != remap[i]) { + low_presc = 0; + break; + } + } + } + + if(low_presc) { + for(i = 0; i < numcols; i++) { + remap[i] &= 1; + } + info_ptr->bit_depth = 1; + } + } + } + } + + else + png_error(png_ptr, "Unknown colorstyle in WritePNG"); + + if ((text = (png_textp)malloc(sizeof(png_text)))) { + sprintf(software, "XV %s", REVDATE); + + text->compression = -1; + text->key = "Software"; + text->text = software; + text->text_length = strlen(text->text); + + info_ptr->max_text = 1; + info_ptr->num_text = 1; + info_ptr->text = text; + } + + Display_Gamma = gDial.val; /* Save the current gamma for loading */ + + info_ptr->gamma = 1.0/gDial.val; + info_ptr->valid |= PNG_INFO_gAMA; + + png_write_info(png_ptr, info_ptr); + + if(info_ptr->bit_depth < 8) + png_set_packing(png_ptr); + + pass=png_set_interlace_handling(png_ptr); + + if((png_line = malloc(linesize)) == NULL) + png_error(png_ptr, "cannot allocate temp image line"); + + for(i = 0; i < pass; i++) { + int j; + p = pic; + for(j = 0; j < h; j++) { + if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY) { + int k; + for(k = 0; k < w; k++) + png_line[k] = ptype==PIC24 ? MONO(p[k*3], p[k*3+1], p[k*3+2]) : + remap[p[k]]; + png_write_row(png_ptr, png_line); + } else /* RGB or palette */ + png_write_row(png_ptr, p); + if((j & 0x1f) == 0) WaitCursor(); + p += linesize; + } + } + + free(png_line); + + if (text) + { + if (picComments && strlen(picComments) && + (savecmnt = (char *)malloc((strlen(picComments) + 1)*sizeof(char)))) { + png_textp tp; + char *comment, *key; + + strcpy(savecmnt, picComments); + key = savecmnt; + tp = text; + info_ptr->num_text = 0; + + comment = strchr(key, ':'); + + do { + /* Allocate a larger structure for comments if necessary */ + if (info_ptr->num_text >= info_ptr->max_text) + { + if ((tp = + realloc(text, (info_ptr->num_text + 2)*sizeof(png_text))) == NULL) + { + break; + } + else + { + text = tp; + tp = &text[info_ptr->num_text]; + info_ptr->max_text += 2; + } + } + + /* See if it looks like a PNG keyword from LoadPNG */ + /* GRR: should test for strictly < 80, right? (key = 1-79 chars only) */ + if(comment && comment[1] == ':' && comment - key <= 80) { + *(comment++) = '\0'; + *(comment++) = '\0'; + + /* If the comment is the 'Software' chunk XV writes, we remove it, + since we have already stored one */ + if (strcmp(key, "Software") == 0 && strncmp(comment, "XV", 2) == 0) { + key = strchr(comment, '\n'); + if(key) + key++; /* skip \n */ + comment = strchr(key, ':'); + } + /* We have another keyword and/or comment to write out */ + else { + tp->key = key; + tp->text = comment; + + /* We have to find the end of this comment, and the next keyword + if there is one */ + for (; NULL != (key = comment = strchr(comment, ':')); comment++) + if (key[1] == ':') + break; + + /* It looks like another keyword, go backward to the beginning */ + if (key) { + while(key > tp->text && *key != '\n') + key--; + + if (key > tp->text && comment - key <= 80) { + *key = '\0'; + key++; + } + } + + tp->text_length = strlen(tp->text); + + /* We don't have another keyword, so remove the last newline */ + if (!key && tp->text[tp->text_length - 1] == '\n') + { + tp->text[tp->text_length] = '\0'; + tp->text_length--; + } + + tp->compression = tp->text_length > 640 ? 0 : -1; + info_ptr->num_text++; + tp++; + } + } + /* Just a generic comment: make sure line-endings are valid for PNG */ + else { + char *p=key, *q=key; /* only deleting chars, not adding any */ + + while (*p) { + if (*p == CR) { /* lone CR or CR/LF: EOL either way */ + *q++ = LF; /* LF is the only allowed PNG line-ending */ + if (p[1] == LF) /* get rid of any original LF */ + ++p; + } else if (*p == LF) /* lone LF */ + *q++ = LF; + else + *q++ = *p; + ++p; + } + *q = '\0'; /* unnecessary...but what the heck */ + tp->key = "Comment"; + tp->text = key; + tp->text_length = q - key; + tp->compression = tp->text_length > 750 ? 0 : -1; + info_ptr->num_text++; + key = NULL; + } + } while (key && *key); + } + else + { + info_ptr->num_text = 0; + } + } + info_ptr->text = text; + + png_convert_from_time_t(&(info_ptr->mod_time), time(NULL)); + info_ptr->valid |= PNG_INFO_tIME; + + png_write_end(png_ptr, info_ptr); + fflush(fp); /* just in case we core-dump before finishing... */ + + if (text) + { + free(text); + /* must do this or png_destroy_write_struct() 0.97+ will free text again: */ + info_ptr->text = (png_textp)NULL; + if (savecmnt) + { + free(savecmnt); + savecmnt = (char *)NULL; + } + } + + png_destroy_write_struct(&png_ptr, &info_ptr); + + return 0; + } + + + /*******************************************/ + int LoadPNG(fname, pinfo) + char *fname; + PICINFO *pinfo; + /*******************************************/ + { + /* returns '1' on success */ + + FILE *fp; + png_struct *png_ptr; + png_info *info_ptr; + png_color_16 my_background; + int i,j; + int linesize; + int filesize; + int pass; + size_t commentsize; + + fbasename = BaseName(fname); + + pinfo->pic = (byte *) NULL; + pinfo->comment = (char *) NULL; + + read_anything=0; + + /* open the file */ + fp = xv_fopen(fname,"r"); + if (!fp) + { + SetISTR(ISTR_WARNING,"%s: can't open file", fname); + return 0; + } + + /* find the size of the file */ + fseek(fp, 0L, 2); + filesize = ftell(fp); + fseek(fp, 0L, 0); + + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, + png_xv_error, png_xv_warning); + if(!png_ptr) { + fclose(fp); + FatalError("malloc failure in LoadPNG"); + } + + info_ptr = png_create_info_struct(png_ptr); + + if(!info_ptr) { + fclose(fp); + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); + FatalError("malloc failure in LoadPNG"); + } + + if(setjmp(png_ptr->jmpbuf)) { + fclose(fp); + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); + if(!read_anything) { + if(pinfo->pic) { + free(pinfo->pic); + pinfo->pic = NULL; + } + if(pinfo->comment) { + free(pinfo->comment); + pinfo->comment = NULL; + } + } + return read_anything; + } + + png_init_io(png_ptr, fp); + png_read_info(png_ptr, info_ptr); + + pinfo->w = pinfo->normw = info_ptr->width; + pinfo->h = pinfo->normh = info_ptr->height; + + pinfo->frmType = F_PNG; + + sprintf(pinfo->fullInfo, "PNG, %d bit ", + info_ptr->bit_depth * info_ptr->channels); + + switch(info_ptr->color_type) { + case PNG_COLOR_TYPE_PALETTE: + strcat(pinfo->fullInfo, "palette color"); + break; + + case PNG_COLOR_TYPE_GRAY: + strcat(pinfo->fullInfo, "grayscale"); + break; + + case PNG_COLOR_TYPE_GRAY_ALPHA: + strcat(pinfo->fullInfo, "grayscale+alpha"); + break; + + case PNG_COLOR_TYPE_RGB: + strcat(pinfo->fullInfo, "truecolor"); + break; + + case PNG_COLOR_TYPE_RGB_ALPHA: + strcat(pinfo->fullInfo, "truecolor+alpha"); + break; + } + + sprintf(pinfo->fullInfo + strlen(pinfo->fullInfo), + ", %sinterlaced. (%d bytes)", + info_ptr->interlace_type ? "" : "non-", filesize); + + sprintf(pinfo->shrtInfo, "%dx%d PNG", info_ptr->width, info_ptr->height); + + if (info_ptr->bit_depth < 8) + png_set_packing(png_ptr); + + if (info_ptr->valid & PNG_INFO_gAMA) + png_set_gamma(png_ptr, Display_Gamma, info_ptr->gamma); + else + png_set_gamma(png_ptr, Display_Gamma, 0.45); + + if (info_ptr->valid & PNG_INFO_bKGD) + png_set_background(png_ptr, &info_ptr->background, + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + else { + my_background.red = my_background.green = my_background.blue = + my_background.gray = 0; + png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN, + 0, Display_Gamma); + } + + if (info_ptr->bit_depth == 16) + png_set_strip_16(png_ptr); + + if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY || + info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (info_ptr->bit_depth == 1) + pinfo->colType = F_BWDITHER; + else + pinfo->colType = F_GREYSCALE; + png_set_expand(png_ptr); + } + + pass=png_set_interlace_handling(png_ptr); + + png_read_update_info(png_ptr, info_ptr); + + if(info_ptr->color_type == PNG_COLOR_TYPE_RGB || + info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { + linesize = pinfo->w * 3; + pinfo->colType = F_FULLCOLOR; + pinfo->type = PIC24; + } else { + linesize = pinfo->w; + pinfo->type = PIC8; + if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY || + info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + for(i = 0; i < 256; i++) + pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i; + } else { + pinfo->colType = F_FULLCOLOR; + for(i = 0; i < info_ptr->num_palette; i++) { + pinfo->r[i] = info_ptr->palette[i].red; + pinfo->g[i] = info_ptr->palette[i].green; + pinfo->b[i] = info_ptr->palette[i].blue; + } + } + } + pinfo->pic = calloc((size_t)(linesize*pinfo->h), (size_t)1); + + if(!pinfo->pic) { + png_error(png_ptr, "can't allocate space for PNG image"); + } + + png_start_read_image(png_ptr); + + for(i = 0; i < pass; i++) { + byte *p = pinfo->pic; + for(j = 0; j < pinfo->h; j++) { + png_read_row(png_ptr, p, NULL); + read_anything = 1; + if((j & 0x1f) == 0) WaitCursor(); + p += linesize; + } + } + + png_read_end(png_ptr, info_ptr); + + if(info_ptr->num_text > 0) { + commentsize = 1; + + for(i = 0; i < info_ptr->num_text; i++) + commentsize += strlen(info_ptr->text[i].key) + 1 + + info_ptr->text[i].text_length + 2; + + if((pinfo->comment = malloc(commentsize)) == NULL) { + png_warning(png_ptr,"can't allocate comment string"); + } + else { + pinfo->comment[0] = '\0'; + for(i = 0; i < info_ptr->num_text; i++) { + strcat(pinfo->comment, info_ptr->text[i].key); + strcat(pinfo->comment, "::"); + strcat(pinfo->comment, info_ptr->text[i].text); + strcat(pinfo->comment, "\n"); + } + } + } + + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); + + fclose(fp); + + return 1; + } + + + /*******************************************/ + static void + png_xv_error(png_ptr, message) + png_structp png_ptr; + png_const_charp message; + { + SetISTR(ISTR_WARNING,"%s: libpng error: %s", fbasename, message); + + longjmp(png_ptr->jmpbuf, 1); + } + + + /*******************************************/ + static void + png_xv_warning(png_ptr, message) + png_structp png_ptr; + png_const_charp message; + { + if (!png_ptr) + return; + + SetISTR(ISTR_WARNING,"%s: libpng warning: %s", fbasename, message); + } + + #endif diff -c xvpopup.c.init xvpopup.c *** xvpopup.c.init Thu Jan 19 10:09:31 1995 --- xvpopup.c Sat May 12 15:37:23 2001 *************** *** 200,213 **** if (!padHaveDooDads) { DCreate(&padWDial, popW, 16, puhigh-16-100-1,75,100, ! 1, 2048, pWIDE, 10, infofg, infobg, hicol, locol, "Width", NULL); DCreate(&padHDial, popW, 16+1+75, puhigh-16-100-1,75,100, ! 1, 2048, pHIGH, 10, infofg, infobg, hicol, locol, "Height", NULL); DCreate(&padODial, popW, 16+1+75+75+9, puhigh-16-100-1,75,100, ! 0, 100, 100, 10, infofg, infobg, hicol, locol, "Opaque", NULL); MBCreate(&padMthdMB, popW, 100-2+44, 10, 140, 19, NULL, --- 200,213 ---- if (!padHaveDooDads) { DCreate(&padWDial, popW, 16, puhigh-16-100-1,75,100, ! 1.0, 2048.0, (double)pWIDE, 1.0, 10.0, infofg, infobg, hicol, locol, "Width", NULL); DCreate(&padHDial, popW, 16+1+75, puhigh-16-100-1,75,100, ! 1.0, 2048.0, (double)pHIGH, 1.0, 10.0, infofg, infobg, hicol, locol, "Height", NULL); DCreate(&padODial, popW, 16+1+75+75+9, puhigh-16-100-1,75,100, ! 0.0, 100.0, 100.0, 1.0, 10.0, infofg, infobg, hicol, locol, "Opaque", NULL); MBCreate(&padMthdMB, popW, 100-2+44, 10, 140, 19, NULL, *************** *** 258,266 **** else if (poptyp == ISPAD) { BTSetActive(&bts[0], (int) strlen(gsBuf)); i = pWIDE * 3; RANGE(i,2048,9999); ! DSetRange(&padWDial, 1, i, padWDial.val, 10); i = pHIGH * 3; RANGE(i,2048,9999); ! DSetRange(&padHDial, 1, i, padHDial.val, 10); DSetActive(&padWDial, (padMode!=PAD_LOAD)); /* DSetRange activates dial */ DSetActive(&padHDial, (padMode!=PAD_LOAD)); --- 258,266 ---- else if (poptyp == ISPAD) { BTSetActive(&bts[0], (int) strlen(gsBuf)); i = pWIDE * 3; RANGE(i,2048,9999); ! DSetRange(&padWDial, 1.0, (double)i, padWDial.val, 1.0, 10.0); i = pHIGH * 3; RANGE(i,2048,9999); ! DSetRange(&padHDial, 1.0, (double)i, padHDial.val, 1.0, 10.0); DSetActive(&padWDial, (padMode!=PAD_LOAD)); /* DSetRange activates dial */ DSetActive(&padHDial, (padMode!=PAD_LOAD)); *************** *** 465,473 **** changedGSBuf(); /* careful! popW doesn't exist yet! */ if (padHaveDooDads) { ! oldW = padWDial.val; ! oldH = padHDial.val; ! oldO = padODial.val; } else { oldW = pWIDE; oldH = pHIGH; oldO = 100; } --- 465,473 ---- changedGSBuf(); /* careful! popW doesn't exist yet! */ if (padHaveDooDads) { ! oldW = (int)padWDial.val; ! oldH = (int)padHDial.val; ! oldO = (int)padODial.val; } else { oldW = pWIDE; oldH = pHIGH; oldO = 100; } *************** *** 486,494 **** } if (rv == 1) { /* cancelled: restore normal values */ ! DSetVal(&padWDial, oldW); ! DSetVal(&padHDial, oldH); ! DSetVal(&padODial, oldO); } XUnmapWindow(theDisp, padWDial.win); --- 486,494 ---- } if (rv == 1) { /* cancelled: restore normal values */ ! DSetVal(&padWDial, (double)oldW); ! DSetVal(&padHDial, (double)oldH); ! DSetVal(&padODial, (double)oldO); } XUnmapWindow(theDisp, padWDial.win); *************** *** 498,506 **** /* load up return values */ *pMode = padMode; *pStr = padBuf; ! *pWide = padWDial.val; ! *pHigh = padHDial.val; ! *pOpaque = padODial.val; *pOmode = padOMode; return rv; --- 498,506 ---- /* load up return values */ *pMode = padMode; *pStr = padBuf; ! *pWide = (int)padWDial.val; ! *pHigh = (int)padHDial.val; ! *pOpaque = (int)padODial.val; *pOmode = padOMode; return rv; *************** *** 560,565 **** --- 560,566 ---- nams[*lenp] = (char *) malloc((size_t) 32); if (!nams[*lenp]) { free(vals[*lenp]); continue; } strncpy(nams[*lenp], vals[*lenp], (size_t) 31); + nams[*lenp][31] = '\0'; } if (strlen(nams[*lenp]) > (size_t) 20) { /* fix long names */ *************** *** 972,979 **** else if (popUp == ISPAD) { if (PTINRECT(x, y, padDButt.x, padDButt.y, padDButt.w, padDButt.h)) { if (BTTrack(&padDButt)) { ! DSetVal(&padWDial, pWIDE); ! DSetVal(&padHDial, pHIGH); } } --- 973,980 ---- else if (popUp == ISPAD) { if (PTINRECT(x, y, padDButt.x, padDButt.y, padDButt.w, padDButt.h)) { if (BTTrack(&padDButt)) { ! DSetVal(&padWDial, (double)pWIDE); ! DSetVal(&padHDial, (double)pHIGH); } } diff -c xvps.c.init xvps.c *** xvps.c.init Thu Dec 22 14:34:42 1994 --- xvps.c Sat May 12 15:37:23 2001 *************** *** 139,147 **** CBCreate(&encapsCB, psW, 240, 7, "preview", infofg, infobg, hicol, locol); CBCreate(&pscompCB, psW, 331, 7, "compress", infofg, infobg, hicol, locol); ! DCreate(&xsDial, psW, 240, 30, 80, 100, 10, 800, 100, 5, infofg, infobg, hicol, locol, "Width", "%"); ! DCreate(&ysDial, psW, 331, 30, 80, 100, 10, 800, 100, 5, infofg, infobg, hicol, locol, "Height", "%"); xsDial.drawobj = changedScale; ysDial.drawobj = changedScale; --- 139,147 ---- CBCreate(&encapsCB, psW, 240, 7, "preview", infofg, infobg, hicol, locol); CBCreate(&pscompCB, psW, 331, 7, "compress", infofg, infobg, hicol, locol); ! DCreate(&xsDial, psW, 240, 30, 80, 100, 10.0, 800.0, 100.0, 0.5, 5.0, infofg, infobg, hicol, locol, "Width", "%"); ! DCreate(&ysDial, psW, 331, 30, 80, 100, 10.0, 800.0, 100.0, 0.5, 5.0, infofg, infobg, hicol, locol, "Height", "%"); xsDial.drawobj = changedScale; ysDial.drawobj = changedScale; *************** *** 236,245 **** if (rd_int("psres")) { /* xv.psres: default paper resolution */ if (def_int >= 10 && def_int <= 720) { ! int i = (int) ((PIX2INCH * 100) / def_int); ! DSetVal(&xsDial, i); ! DSetVal(&ysDial, i); } } --- 236,245 ---- if (rd_int("psres")) { /* xv.psres: default paper resolution */ if (def_int >= 10 && def_int <= 720) { ! double v = (PIX2INCH * 100) / def_int; ! DSetVal(&xsDial, v); ! DSetVal(&ysDial, v); } } *************** *** 836,842 **** if (scx < scy) { sz_iny = h * scx; } else { sz_inx = w * scy; } ! DSetVal(&xsDial, (int) ((100 * (sz_inx * PIX2INCH) / w) + .5)); DSetVal(&ysDial, xsDial.val); sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0); --- 836,842 ---- if (scx < scy) { sz_iny = h * scx; } else { sz_inx = w * scy; } ! DSetVal(&xsDial, 100 * (sz_inx * PIX2INCH) / w); DSetVal(&ysDial, xsDial.val); sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0); *************** *** 1577,1586 **** # ifndef VMS sprintf(tmp1, "-I%s ", GS_LIB); # else ! sprintf(tmp1, "\"-I%s\"", GS_LIB); # endif strcat(tmp, tmp1); #endif if (gsGeomStr) { sprintf(tmp1, "-g%s ", gsGeomStr); --- 1577,1595 ---- # ifndef VMS sprintf(tmp1, "-I%s ", GS_LIB); # else ! sprintf(tmp1, "\"-I%s\" ", GS_LIB); # endif strcat(tmp, tmp1); #endif + + + /* prevent some potential naughtiness... */ + #ifndef VMS + strcat(tmp, "-dSAFER "); + #else + strcat(tmp, "\"-dSAFER\" "); + #endif + if (gsGeomStr) { sprintf(tmp1, "-g%s ", gsGeomStr); diff -c xvroot.c.init xvroot.c *** xvroot.c.init Thu Dec 22 14:34:42 1994 --- xvroot.c Sat May 12 15:37:23 2001 *************** *** 44,49 **** --- 44,50 ---- case RM_MIRROR: case RM_IMIRROR: rpixw = 2*eWIDE; rpixh = 2*eHIGH; break; case RM_CSOLID: + case RM_UPLEFT: case RM_CWARP: case RM_CBRICK: rpixw = dispWIDE; rpixh = dispHIGH; break; *************** *** 101,107 **** else if (rmode == RM_CENTER || rmode == RM_CENTILE || rmode == RM_CSOLID || ! rmode == RM_CWARP || rmode == RM_CBRICK) { /* do some stuff to set up the border around the picture */ if (rmode != RM_CENTILE) { --- 102,108 ---- else if (rmode == RM_CENTER || rmode == RM_CENTILE || rmode == RM_CSOLID || ! rmode == RM_CWARP || rmode == RM_CBRICK || rmode == RM_UPLEFT) { /* do some stuff to set up the border around the picture */ if (rmode != RM_CENTILE) { *************** *** 138,143 **** --- 139,150 ---- else if (rmode == RM_CSOLID) { } + else if (rmode == RM_UPLEFT) { + + XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, 0,0, + (u_int) eWIDE, (u_int) eHIGH); + } + else if (rmode == RM_CWARP) { /* warp effect */ XSetForeground(theDisp, theGC, rootfg); for (i=0; i<=dispWIDE; i+=8) *************** *** 157,163 **** /* draw the image centered on top of the background */ ! if (rmode != RM_CENTILE) XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, ((int) dispWIDE-eWIDE)/2, ((int) dispHIGH-eHIGH)/2, (u_int) eWIDE, (u_int) eHIGH); --- 164,170 ---- /* draw the image centered on top of the background */ ! if ((rmode != RM_CENTILE) && (rmode != RM_UPLEFT)) XPutImage(theDisp, tmpPix, theGC, theImage, 0,0, ((int) dispWIDE-eWIDE)/2, ((int) dispHIGH-eHIGH)/2, (u_int) eWIDE, (u_int) eHIGH); diff -c xvtext.c.init xvtext.c *** xvtext.c.init Fri Jan 13 15:46:28 1995 --- xvtext.c Sat May 12 15:37:23 2001 *************** *** 293,298 **** --- 293,299 ---- tv->textlen = len; tv->freeonclose = freeonclose; strncpy(tv->title, title, (size_t) TITLELEN-1); + tv->title[TITLELEN-1] = '\0'; computeText(tv); /* compute # lines and linestarts array */ diff -c xvtiff.c.init xvtiff.c *** xvtiff.c.init Fri Jan 13 11:53:34 1995 --- xvtiff.c Sat May 12 15:37:23 2001 *************** *** 301,306 **** --- 301,310 ---- static byte **BWmap; static byte **PALmap; + /* XXXX Work around some collisions with the new library. */ + #define tileContigRoutine _tileContigRoutine + #define tileSeparateRoutine _tileSeparateRoutine + typedef void (*tileContigRoutine) PARM((byte*, u_char*, RGBvalue*, uint32, uint32, int, int)); *************** *** 340,346 **** uint32, uint32, int, int)); static void put4bitbwtile PARM((byte *, u_char *, RGBvalue *, uint32, uint32, int, int)); ! static void put16bitbwtile PARM((byte *, u_char *, RGBvalue *, uint32, uint32, int, int)); static void putRGBcontig8bittile PARM((byte *, u_char *, RGBvalue *, --- 344,350 ---- uint32, uint32, int, int)); static void put4bitbwtile PARM((byte *, u_char *, RGBvalue *, uint32, uint32, int, int)); ! static void put16bitbwtile PARM((byte *, u_short *, RGBvalue *, uint32, uint32, int, int)); static void putRGBcontig8bittile PARM((byte *, u_char *, RGBvalue *, *************** *** 1218,1224 **** */ static void put16bitbwtile(cp, pp, Map, w, h, fromskew, toskew) byte *cp; ! u_char *pp; RGBvalue *Map; uint32 w, h; int fromskew, toskew; --- 1222,1228 ---- */ static void put16bitbwtile(cp, pp, Map, w, h, fromskew, toskew) byte *cp; ! u_short *pp; RGBvalue *Map; uint32 w, h; int fromskew, toskew; *************** *** 1227,1234 **** while (h-- > 0) { for (x=w; x>0; x--) { ! *cp++ = Map[(pp[0] << 8) + pp[1]]; ! pp += 2; } cp += toskew; pp += fromskew; --- 1231,1237 ---- while (h-- > 0) { for (x=w; x>0; x--) { ! *cp++ = Map[*pp++]; } cp += toskew; pp += fromskew; *************** *** 1514,1520 **** case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: switch (bitspersample) { ! case 16: put = put16bitbwtile; break; case 8: put = putgreytile; break; case 4: put = put4bitbwtile; break; case 2: put = put2bitbwtile; break; --- 1517,1523 ---- case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: switch (bitspersample) { ! case 16: put = (tileContigRoutine) put16bitbwtile; break; case 8: put = putgreytile; break; case 4: put = put4bitbwtile; break; case 2: put = put2bitbwtile; break; diff -c xvtiffwr.c.init xvtiffwr.c *** xvtiffwr.c.init Tue Jan 3 13:28:13 1995 --- xvtiffwr.c Sat May 12 15:37:23 2001 *************** *** 84,91 **** TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, h); TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, (int)2); ! TIFFSetField(tif, TIFFTAG_XRESOLUTION, (float)1200.0); ! TIFFSetField(tif, TIFFTAG_YRESOLUTION, (float)1200.0); /* write the image data */ --- 84,91 ---- TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, h); TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, (int)2); ! TIFFSetField(tif, TIFFTAG_XRESOLUTION, (float) 72.0); ! TIFFSetField(tif, TIFFTAG_YRESOLUTION, (float) 72.0); /* write the image data */ diff -c xvxwd.c.init xvxwd.c *** xvxwd.c.init Thu Dec 22 14:34:40 1994 --- xvxwd.c Sat May 12 15:37:23 2001 *************** *** 396,406 **** h11P->pixmap_width; bits_per_item = h11P->bitmap_unit; - bits_used = bits_per_item; bits_per_pixel = h11P->bits_per_pixel; byte_order = h11P->byte_order; bit_order = h11P->bitmap_bit_order; if (bits_per_pixel == sizeof(pixel_mask) * 8) pixel_mask = (CARD32) -1; else pixel_mask = (1 << bits_per_pixel) - 1; --- 396,425 ---- h11P->pixmap_width; bits_per_item = h11P->bitmap_unit; bits_per_pixel = h11P->bits_per_pixel; byte_order = h11P->byte_order; bit_order = h11P->bitmap_bit_order; + + /* add sanity-code for freako 'exceed' server, where bitmapunit = 8 + and bitsperpix = 32 (and depth=24)... */ + + if (bits_per_item < bits_per_pixel) { + bits_per_item = bits_per_pixel; + + /* round bits_per_item up to next legal value, if necc */ + if (bits_per_item < 8) bits_per_item = 8; + else if (bits_per_item < 16) bits_per_item = 16; + else bits_per_item = 32; + } + + + /* which raises the question: how (can?) you ever have a 24 bits per pix, + (ie, 3 bytes, no alpha/padding) */ + + + bits_used = bits_per_item; + if (bits_per_pixel == sizeof(pixel_mask) * 8) pixel_mask = (CARD32) -1; else pixel_mask = (1 << bits_per_pixel) - 1;