diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/Imakefile ./Imakefile --- ../xv-3.10a-jp-extension-5.3.3/Imakefile Thu Oct 15 22:53:53 1998 +++ ./Imakefile Fri Oct 13 21:29:29 2000 @@ -15,6 +15,11 @@ #define HaveTiff +/* if, for whatever reason, you're unable to get the PNG library to compile + * on your machine, *COMMENT OUT* the following line + */ +#define HavePng + /* if, for whatever reason, you're unable to get the PDS/VICAR support * to compile (xvpds.c, and vdcomp.c), *COMMENT OUT* the following line */ @@ -113,7 +118,7 @@ - +#include "config.h" /* This marks the end of the configuration parameters */ @@ -123,15 +128,38 @@ #ifdef HaveJpeg JPEG = -DDOJPEG JPEGDIR = jpeg +# ifndef UseInstalledJpeg LIBJPEG = $(JPEGDIR)/libjpeg.a JPEGINCLUDE = -I$(JPEGDIR) +# else +LIBJPEG = /opt/local/lib/libjpeg.a +JPEGINCLUDE = -I/opt/local/include +# endif #endif #ifdef HaveTiff TIFF = -DDOTIFF TIFFDIR = tiff +# ifndef UseInstalledTiff LIBTIFF = $(TIFFDIR)/libtiff.a TIFFINCLUDE = -I$(TIFFDIR) +# else +LIBTIFF = /opt/local/lib/libtiff.a +TIFFINCLUDE = -I/opt/local/include +# endif +#endif + +#ifdef HavePng +PNG = -DDOPNG +PNGDIR = libpng +# ifndef UseInstalledPng +LIBPNG = $(PNGDIR)/libpng.a +PNGINCLUDE = -I$(PNGDIR) +# else +LIBPNG = /opt/local/lib/libpng.a +PNGINCLUDE = -I/opt/local/include +# endif +LIBZLIB = -L/opt/local/lib -lz #endif #ifdef HavePDS @@ -149,14 +177,14 @@ #endif -DEPLIBS = $(LIBJPEG) $(LIBTIFF) -LOCAL_LIBRARIES = $(XLIB) $(DEPLIBS) +DEPLIBS = $(LIBJPEG) $(LIBTIFF) $(LIBPNG) +LOCAL_LIBRARIES = $(XLIB) $(DEPLIBS) $(LIBZLIB) DEFINES= $(SCO) $(UNIX) $(NODIRENT) $(VPRINTF) $(TIMERS) \ - $(HPUX7) $(JPEG) $(TIFF) $(PDS) $(DXWM) $(RAND) \ + $(HPUX7) $(JPEG) $(TIFF) $(PNG) $(PDS) $(DXWM) $(RAND) \ $(BACKING_STORE) $(BSDTYPES) $(SGI) $(MGCSFX) -INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) +INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) $(PNGINCLUDE) SRCS1 = xv.c xvevent.c xvroot.c xvmisc.c xvimage.c xvcolor.c xvsmooth.c \ xv24to8.c xvgif.c xvpm.c xvinfo.c xvctrl.c xvscrl.c xvalg.c \ @@ -164,7 +192,7 @@ xvdial.c xvgraf.c xvsunras.c xvjpeg.c xvps.c xvpopup.c xvdflt.c \ xvtiff.c xvtiffwr.c xvpds.c xvrle.c xviris.c xvgrab.c vprintf.c \ xvbrowse.c xvtext.c xvpcx.c xviff.c xvtarga.c xvxpm.c xvcut.c \ - xvxwd.c xvfits.c \ + xvxwd.c xvfits.c xvpng.c \ xvmag.c xvpic.c xvmaki.c xvpi.c xvpic2.c xvpcd.c xvvd.c xvmgcsfx.c \ xvml.c @@ -174,7 +202,7 @@ 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 \ + xvxwd.o xvfits.o xvpng.o \ xvmag.o xvpic.o xvmaki.o xvpi.o xvpic2.o xvpcd.o xvvd.o xvmgcsfx.o \ xvml.o @@ -200,18 +228,42 @@ @echo "" -#if defined(HaveJpeg) || defined(HaveTiff) -# ifdef HaveJpeg -# ifdef HaveTiff - SUBDIRS = tiff +#if defined(HaveJpeg) && !defined(UseInstalledJpeg) +# if defined(HaveTiff) && !defined(UseInstalledTiff) +# if defined(HavePng) && !defined(UseInstalledPng) + SUBDIRS = $(JPEGDIR) $(TIFFDIR) $(PNGDIR) +# define PassCDebugFlags +# define IHaveSubdirs # else - SUBDIRS = + SUBDIRS = $(JPEGDIR) $(TIFFDIR) +# define PassCDebugFlags +# define IHaveSubdirs # endif # else - SUBDIRS = tiff + SUBDIRS = $(JPEGDIR) +# define PassCDebugFlags +# define IHaveSubdirs +# endif +#else +# if defined(HaveTiff) && !defined(UseInstalledTiff) +# if defined(HavePng) && !defined(UseInstalledPng) + SUBDIRS = $(TIFFDIR) $(PNGDIR) +# define PassCDebugFlags +# define IHaveSubdirs +# else + SUBDIRS = $(TIFFDIR) +# define PassCDebugFlags +# define IHaveSubdirs +# endif +# else +# if defined(HavePng) && !defined(UseInstalledPng) + SUBDIRS = $(PNGDIR) +# define PassCDebugFlags +# define IHaveSubdirs +# else + SUBDIRS = +# endif # endif -# define PassCDebugFlags -# define IHaveSubdirs #endif @@ -220,7 +272,7 @@ @echo "" -#ifdef HaveJpeg +#if defined(HaveJpeg) && !defined(UseInstalledJpeg) $(LIBJPEG): cd $(JPEGDIR); $(MAKE) libjpeg.a @@ -232,14 +284,25 @@ @echo "" #endif -#ifdef HaveTiff +#if defined(HaveTiff) && !defined(UseInstalledTiff) $(LIBTIFF): cd $(TIFFDIR); $(MAKE) libtiff.a - + clean:: @echo " cleaning in $(TIFFDIR) ..." @echo "" ( cd $(TIFFDIR) ; $(MAKE) clean ) + @echo "" +#endif + +#if defined(HavePng) && !defined(UseInstalledPng) +$(LIBPNG): + cd $(PNGDIR); $(MAKE) libpng.a + +clean:: + @echo " cleaning in $(PNGDIR) ..." + @echo "" + ( cd $(PNGDIR) ; $(MAKE) clean ) @echo "" #endif diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/Makefile.std ./Makefile.std --- ../xv-3.10a-jp-extension-5.3.3/Makefile.std Thu Oct 15 22:53:53 1998 +++ ./Makefile.std Fri Oct 16 09:09:40 1998 @@ -56,6 +56,25 @@ ### +### 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 + + +### ### if, for whatever reason, you're unable to get the TIFF library to compile ### on your machine, *COMMENT OUT* the following lines ### @@ -201,9 +220,10 @@ CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \ $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \ - $(DXWM) $(MCHN) $(TVL10N) $(MGCSFX) + $(DXWM) $(MCHN) $(PNG) $(PNGINC) $(ZLIBINC) \ + $(TVL10N) $(MGCSFX) -LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm +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 \ @@ -211,7 +231,7 @@ 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 \ + xvxwd.o xvfits.o xvpng.o \ xvmag.o xvpic.o xvmaki.o xvpi.o xvpic2.o xvpcd.o xvvd.o xvmgcsfx.o \ xvml.o @@ -285,7 +305,7 @@ 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 +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 -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/README.PNG ./README.PNG --- ../xv-3.10a-jp-extension-5.3.3/README.PNG Thu Jan 1 09:00:00 1970 +++ ./README.PNG Fri Jun 14 06:32:08 1996 @@ -0,0 +1,33 @@ +This archive contains context diffs suitable for use with the GNU +patch utility. It adds the ability to read and write PNG format +files with XV 3.10a. This patch was written by Andreas Dilger + based on a patch written by Alexander +Lehmann . No warranty, expressed +or implied, of merchant-ability or fitness for a particular purpose +is given with this patch. It is also an unofficial patch, in the +sense that the XV author had nothing to do with it. Despite all that, +it is reasonably reliable. + +The following files are required for adding PNG to XV 3.10a. +xvpng.c +xvpng.diff +bits/br_png + +Move them into the same directory as the XV source code, and apply +the patch via "patch -p1 < xvpng.diff". You may need to edit your +makefile to indicate the location of libpng and zlib, which are not +included here. Both are available at ftp.uu.net and various other +locations on the internet. This patch was created with libpng-0.89 +and zlib-1.0.2, but later versions should also work. + +The xvjpeg.diff and xvtiff.diff are not required for the PNG +functionality, but were modifications I needed to make to get XV +to compile with the latest versions of the respective libraries +(libjpeg 6.0 and libtiff 3.4.beta027 respectively). You do not +need to apply them if you are using the libraries included with XV. + +The xcmap.diff file allows this program to work properly with a 1-bit +X display. It is not required for PNG functionality. Why use xcmap +for a 1-bit display? Because I have an xcmap icon for fvwm, and it +always starts regardless of the display, so it was easier to fix xcmap +than to stop xcmap from starting based on the display depth. diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/bits/br_png ./bits/br_png --- ../xv-3.10a-jp-extension-5.3.3/bits/br_png Thu Jan 1 09:00:00 1970 +++ ./bits/br_png Fri Jun 14 06:32:08 1996 @@ -0,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 -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/config.h ./config.h --- ../xv-3.10a-jp-extension-5.3.3/config.h Fri Oct 13 22:22:02 2000 +++ ./config.h Fri Oct 13 21:44:15 2000 @@ -25,7 +25,7 @@ # if defined(__linux__) # define GUNZIP "/bin/gunzip -q" # else -# define GUNZIP "/usr/local/bin/gunzip -q" +# define GUNZIP "/opt/local/bin/gunzip -q" # endif # endif # endif @@ -103,7 +103,7 @@ * should not need to be changed */ -#define GS_PATH "/usr/local/bin/gs" +#define GS_PATH "/opt/local/bin/gs" #define GS_LIB "." #define GS_DEV "ppmraw" @@ -134,6 +134,12 @@ #define BACKING_STORE +/*************************************************************************** + * UseInstalledJpeg, UseInstalledTiff, UseInstalledPng + */ +#define UseInstalledJpeg +#define UseInstalledTiff +#define UseInstalledPng /*************************************************************************** * MAG/PIC/MAKI/Pi/PIC2/PhotoCD format Support: @@ -320,7 +326,7 @@ * 'undef' to 'define' in the following line. */ -#define TV_MULTILINGUAL +#undef TV_MULTILINGUAL #define TV_DEFAULT_CODESET TV_EUC_JAPAN diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xcmap.c ./xcmap.c --- ../xv-3.10a-jp-extension-5.3.3/xcmap.c Wed Jan 4 06:14:52 1995 +++ ./xcmap.c Fri Oct 16 08:57:22 1998 @@ -140,8 +140,13 @@ nxcells = nycells = 8; else if (dispcells>4) nxcells = nycells = 4; - else + else if (dispcells>2) nxcells = nycells = 2; + else + { + nxcells = 2; + nycells = 1; + } /**************** Create/Open X Resources ***************/ if ((mfinfo = XLoadQueryFont(theDisp,FONT))==NULL) { @@ -267,18 +272,25 @@ x=y=w=h=1; i=XParseGeometry(geom,&x,&y,&w,&h); - if (i&WidthValue) WIDE = (int) w; - if (i&HeightValue) HIGH = (int) h; - - if (i&XValue || i&YValue) hints.flags = USPosition; - else hints.flags = PPosition; - - hints.flags |= USSize; - - if (i&XValue && i&XNegative) - x = XDisplayWidth(theDisp,theScreen)-WIDE-abs(x); - if (i&YValue && i&YNegative) - y = XDisplayHeight(theDisp,theScreen)-HIGH-abs(y); + if (i&WidthValue) + { + WIDE = (int) w; + hints.flags |= USSize; + } + if (i&HeightValue) + { + HIGH = (int) h; + hints.flags |= USSize; + } + + if (i&XValue || i&YValue) + { + if (i&XNegative) + x = XDisplayWidth(theDisp,theScreen)-WIDE-abs(x); + if (i&YNegative) + y = XDisplayHeight(theDisp,theScreen)-HIGH-abs(y); + hints.flags |= USPosition; + } hints.x=x; hints.y=y; hints.width = WIDE; hints.height = HIGH; diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xv.c ./xv.c --- ../xv-3.10a-jp-extension-5.3.3/xv.c Thu Oct 15 22:53:55 1998 +++ ./xv.c Fri Oct 16 10:05:08 1998 @@ -306,6 +306,10 @@ tiffW = (Window) NULL; tiffUp = 0; #endif +#ifdef HAVE_PNG + pngW = (Window) NULL; pngUp = 0; +#endif + #ifdef HAVE_PIC2 pic2W = (Window) NULL; pic2Up = 0; #endif /* HAVE_PIC2 */ @@ -371,37 +375,51 @@ */ - /* 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; + best = -1; rvinfo.class = TrueColor; rvinfo.screen = theScreen; - flags = VisualClassMask | VisualScreenMask; + flags = VisualClassMask | VisualScreenMask; + defvid = XVisualIDFromVisual(DefaultVisual(theDisp, + DefaultScreen(theDisp))); vinfo = XGetVisualInfo(theDisp, flags, &rvinfo, &numvis); - if (vinfo) { /* look for a TrueColor, 24-bit or more (pref 24) */ - for (i=0, best = -1; i24-bit */ + for (i=0; i= 24)) best=i; + } + for (i=0; i24 && best<0) 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, best = -1; i= 24)) best=i; + } + for (i=0; i24 && best<0) best = i; + } + for (i=0; i24-bit ? */ + if (vinfo[i].depth >= 24) best = i; } } } @@ -409,8 +427,8 @@ if (best>=0 && bestwin,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); bfIcons[BF_MAG] = MakePix1(br->win,br_mag_bits,br_mag_width,br_mag_height); bfIcons[BF_MAKI] = MakePix1(br->win,br_maki_bits, br_maki_width,br_maki_height); @@ -3206,6 +3209,7 @@ 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; case RFT_MAG: bf->ftype = BF_MAG; break; case RFT_MAKI: bf->ftype = BF_MAKI; break; case RFT_PIC: bf->ftype = BF_PIC; break; @@ -3826,6 +3830,7 @@ 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; case RFT_MAG: strcat(str,"MAG file"); break; case RFT_MAKI: strcat(str,"MAKI file"); break; case RFT_PIC: strcat(str,"PIC file"); break; diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvdial.c ./xvdial.c --- ../xv-3.10a-jp-extension-5.3.3/xvdial.c Wed Jan 4 06:20:31 1995 +++ ./xvdial.c Fri Oct 16 08:59:20 1998 @@ -41,20 +41,21 @@ /* 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 *)); +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, page, +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,minv,maxv,curv,page; +int x,y,w,h; +double minv,maxv,curv,inc,page; unsigned long fg,bg,hi,lo; char *title, *units; { @@ -98,18 +99,18 @@ 1,fg,bg); if (!dp->win) FatalError("can't create dial window"); - DSetRange(dp, minv, maxv, curv, page); + DSetRange(dp, minv, maxv, curv, inc, page); XSelectInput(theDisp, dp->win, ExposureMask | ButtonPressMask); } /***************************************************/ -void DSetRange(dp, minv, maxv, curv, page) -DIAL *dp; -int minv, maxv, curv, page; +void DSetRange(dp, minv, maxv, curv, inc, page) +DIAL *dp; +double minv, maxv, curv, inc, page; { if (maxvmin = minv; dp->max = maxv; dp->page = page; + dp->min = minv; dp->max = maxv; dp->inc = inc; dp->page = page; dp->active = (minv < maxv); DSetVal(dp, curv); @@ -118,8 +119,8 @@ /***************************************************/ void DSetVal(dp, curv) -DIAL *dp; -int curv; +DIAL *dp; +double curv; { RANGE(curv, dp->min, dp->max); /* make sure curv is in-range */ @@ -129,7 +130,7 @@ XSetForeground(theDisp, theGC, dp->bg); drawArrow(dp); - dp->val = curv; + 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,7 +203,8 @@ int mx,my; { Window rW,cW; - int rx,ry, x,y, ipos, pos, lit, i, origval; + int rx, ry, x, y, ipos, pos, lit; + double origval; unsigned int mask; lit = 0; @@ -224,9 +226,9 @@ if (ipos != INDIAL) { drawButt(dp, ipos, 1); switch (ipos) { - case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+1); break; + 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-1); 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,8 +237,9 @@ } else { - i = computeDialVal(dp, mx, my); - DSetVal(dp, i); + double v; + v = computeDialVal(dp, mx, my); + DSetVal(dp, v); if (dp->drawobj != NULL) (dp->drawobj)(); } @@ -246,11 +249,11 @@ 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) { + 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,11 +269,11 @@ if (lit) { switch (ipos) { - case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+1); + 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-1); + 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,19 +323,20 @@ static void drawArrow(dp) DIAL *dp; { - int i, rad, cx, cy; + 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) */ - 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)); + 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,23 +347,37 @@ static void drawValStr(dp) DIAL *dp; { - int i, x1, x2; + int tot, 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); + 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); - if (dp->min < 0 && dp->max > 0) sprintf(foo,"%+d", dp->val); - else sprintf(foo,"%d", dp->val); + 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 = i - strlen(foo); i>0; i--) strcat(foo1," "); + for (i-=strlen(foo);i>0;i--) strcat(foo1," "); } strcat(foo1, foo); @@ -411,12 +429,13 @@ /***************************************************/ -static int computeDialVal(dp, x, y) +static double computeDialVal(dp, x, y) DIAL *dp; int x, y; { - int dx, dy, val; - double angle; + 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,8 +455,10 @@ 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; + 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 -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvdir.c ./xvdir.c --- ../xv-3.10a-jp-extension-5.3.3/xvdir.c Thu Oct 15 22:53:56 1998 +++ ./xvdir.c Fri Oct 16 09:40:23 1998 @@ -62,6 +62,9 @@ #ifdef HAVE_TIFF "TIFF", #endif +#ifdef HAVE_PNG + "PNG", +#endif "PostScript", "PBM/PGM/PPM (raw)", "PBM/PGM/PPM (ascii)", @@ -1167,6 +1170,15 @@ } #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 + #ifdef HAVE_PIC2 else if (fmt == F_PIC2) { /* PIC2 */ if (PIC2SaveParams(fullname, col) < 0) @@ -1238,12 +1250,11 @@ case F_XPM: rv = WriteXPM (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, - fullname, picComments); - break; - case F_FITS: - rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, - picComments); - break; + fullname, picComments); break; + case F_FITS: + rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, + picComments); + break; #ifdef HAVE_MAG case F_MAG: rv = WriteMAG (fp, thepic, ptype, w, h, rp, gp, bp, nc, col, @@ -1266,7 +1277,7 @@ #endif /* HAVE_PI */ } - + if (CloseOutFile(fp, fullname, rv) == 0) { DirBox(0); @@ -1472,14 +1483,21 @@ (strcmp(lowsuf,"eps" )==0) || (strcmp(lowsuf,"rgb" )==0) || (strcmp(lowsuf,"tga" )==0) || - (strcmp(lowsuf,"xpm" )==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) || (strcmp(lowsuf,"mag" )==0) || (strcmp(lowsuf,"pic" )==0) || (strcmp(lowsuf,"mki" )==0) || @@ -1520,6 +1538,10 @@ #ifdef HAVE_TIFF case F_TIFF: strcpy(lowsuf,"tif"); break; +#endif + +#ifdef HAVE_PNG + case F_PNG: strcpy(lowsuf,"png"); break; #endif #ifdef HAVE_MAG diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvevent.c ./xvevent.c --- ../xv-3.10a-jp-extension-5.3.3/xvevent.c Thu Oct 15 22:53:56 1998 +++ ./xvevent.c Fri Oct 16 09:30:38 1998 @@ -154,7 +154,7 @@ int *donep; { static int wasInfoUp=0, wasCtrlUp=0, wasDirUp=0, wasGamUp=0, wasPsUp=0; - static int wasJpegUp=0, wasTiffUp=0; + static int wasJpegUp=0, wasTiffUp=0, wasPngUp=0; static int wasPic2Up=0, wasPcdUp=0; static int wasMgcSfxUp=0; @@ -235,6 +235,10 @@ if (TIFFCheckEvent(event)) break; /* event has been processed */ #endif +#ifdef HAVE_PNG + if (PNGCheckEvent (event)) break; /* event has been processed */ +#endif + #ifdef HAVE_PIC2 if (PIC2CheckEvent(event)) break; /* event has been processed */ #endif /* HAVE_PIC2 */ @@ -380,6 +384,10 @@ else if (client_event->window == tiffW) TIFFDialog(0); #endif +#ifdef HAVE_PNG + else if (client_event->window == pngW) PNGDialog(0); +#endif + #ifdef HAVE_PIC2 else if (client_event->window == pic2W) PIC2Dialog(0); #endif /* HAVE_PIC2 */ @@ -572,6 +580,10 @@ if (wasTiffUp) { TIFFDialog(wasTiffUp); wasTiffUp=0; } #endif +#ifdef HAVE_PNG + if (wasPngUp) { PNGDialog(wasJpegUp); wasPngUp=0; } +#endif + #ifdef HAVE_PIC2 if (wasPic2Up) { PIC2Dialog(wasPic2Up); wasPic2Up=0; } #endif /* HAVE_PIC2 */ @@ -623,6 +635,10 @@ if (tiffUp) { wasTiffUp = tiffUp; TIFFDialog(0); } #endif +#ifdef HAVE_PNG + if (pngUp) { wasPngUp = pngUp; PNGDialog(0); } +#endif + #ifdef HAVE_PIC2 if (pic2Up) { wasPic2Up = pic2Up; PIC2Dialog(0); } #endif /* HAVE_PIC2 */ @@ -1206,6 +1222,10 @@ if (TIFFCheckEvent(event)) break; #endif +#ifdef HAVE_PNG + if (PNGCheckEvent (event)) break; +#endif + #ifdef HAVE_PIC2 if (PIC2CheckEvent(event)) break; #endif /* HAVE_PIC2 */ @@ -1441,6 +1461,10 @@ if (TIFFCheckEvent(event)) break; #endif +#ifdef HAVE_PNG + if (PNGCheckEvent (event)) break; +#endif + #ifdef HAVE_PIC2 if (PIC2CheckEvent(event)) break; #endif /* HAVE_PIC2 */ @@ -2457,6 +2481,10 @@ #ifdef HAVE_TIFF if (tiffUp) TIFFDialog(0); /* close tiff window */ +#endif + +#ifdef HAVE_PNG + if (pngUp) PNGDialog(0); /* close png window */ #endif #ifdef HAVE_PIC2 diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvgam.c ./xvgam.c --- ../xv-3.10a-jp-extension-5.3.3/xvgam.c Sat Jan 14 04:51:14 1995 +++ ./xvgam.c Fri Oct 16 08:59:21 1998 @@ -265,11 +265,11 @@ 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, + 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,360,180, 5, + 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,360,180, 5, + 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,7 +359,7 @@ srcHD.drawobj = dstHD.drawobj = whtHD.drawobj = dragHueDial; - DCreate(&satDial, hsvF, 100, 199, 100, 121, -100, 100, 0, 5, + 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,7 +722,7 @@ if (whtHD.enabCB.val && whtHD.satval) hsvnonlinear++; - if (satDial.val != 0) hsvnonlinear++; + if (satDial.val != 0.0) hsvnonlinear++; /* check intensity graf */ for (i=0; i<256 && intGraf.func[i]==i; i++); @@ -1291,14 +1291,14 @@ 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)); + DSetVal(&rhDial, h); + DSetVal(&gsDial, s*100); + DSetVal(&bvDial, v*100); } else { - DSetVal(&rhDial, rcmap[editColor]); - DSetVal(&gsDial, gcmap[editColor]); - DSetVal(&bvDial, bcmap[editColor]); + DSetVal(&rhDial, (double)rcmap[editColor]); + DSetVal(&gsDial, (double)gcmap[editColor]); + DSetVal(&bvDial, (double)bcmap[editColor]); } } @@ -1310,16 +1310,15 @@ if (hsvmode) { int rv, gv, bv; - hsv2rgb((double) rhDial.val, ((double) gsDial.val) / 100.0, - ((double) bvDial.val) / 100.0, &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] = rhDial.val; - gcmap[editColor] = gsDial.val; - bcmap[editColor] = bvDial.val; + rcmap[editColor] = (int)rhDial.val; + gcmap[editColor] = (int)gsDial.val; + bcmap[editColor] = (int)bvDial.val; } } @@ -1561,9 +1560,9 @@ 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); + 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,9 +1580,9 @@ &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); + 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,7 +1890,7 @@ } /* apply satDial value to s */ - s = s + ((double) satDial.val) / 100.0; + s = s + satDial.val / 100.0; if (s<0.0) s = 0.0; if (s>1.0) s = 1.0; @@ -2007,7 +2006,7 @@ gs->hueRBnum = RBWhich(hueRB); - gs->satval = satDial.val; + gs->satval = (int)satDial.val; GetGrafState(&intGraf,&gs->istate); GetGrafState(&rGraf, &gs->rstate); GetGrafState(&gGraf, &gs->gstate); @@ -2064,8 +2063,8 @@ changed++; } - if (gs->satval != satDial.val) { - DSetVal(&satDial,gs->satval); + if (gs->satval != (int)satDial.val) { + DSetVal(&satDial,(double)gs->satval); changed++; } @@ -3200,7 +3199,7 @@ if (whtHD.enabCB.val && whtHD.satval) hsvmod++; - if (satDial.val != 0) hsvmod++; + if (satDial.val != 0.0) hsvmod++; /* check intensity graf */ for (i=0; i<256; i++) { @@ -3284,7 +3283,7 @@ } /* apply satDial value to s */ - s = s + satDial.val; + s = s + (int)satDial.val; if (s< 0) s = 0; if (s>100) s = 100; diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvgrab.c ./xvgrab.c --- ../xv-3.10a-jp-extension-5.3.3/xvgrab.c Fri Dec 23 07:34:47 1994 +++ ./xvgrab.c Thu Oct 15 22:56:52 1998 @@ -341,16 +341,16 @@ ConfigureNotify on mainW */ state = 0; - while (1) { + while (state != 3) { XEvent event; XNextEvent(theDisp, &event); HandleEvent(&event, &i); - if (state==0 && event.type == MapNotify && - event.xmap.window == mainW) state = 1; + if (!(state&1) && event.type == MapNotify && + event.xmap.window == mainW) state |= 1; - if (state==1 && event.type == ConfigureNotify && - event.xconfigure.window == mainW) break; + if (!(state&2) && event.type == ConfigureNotify && + event.xconfigure.window == mainW) state |= 2; } if (DEBUG) fprintf(stderr,"==after remapping mainW, GOT Config.\n"); diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvjpeg.c ./xvjpeg.c --- ../xv-3.10a-jp-extension-5.3.3/xvjpeg.c Thu Jan 5 17:17:13 1995 +++ ./xvjpeg.c Fri Oct 16 08:59:21 1998 @@ -51,11 +51,11 @@ 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)); +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)); +METHODDEF(boolean) xv_process_comment PARM((j_decompress_ptr)); static int writeJFIF PARM((FILE *, byte *, int,int,int)); @@ -87,10 +87,10 @@ XSelectInput(theDisp, jpegW, ExposureMask | ButtonPressMask | KeyPressMask); - DCreate(&qDial, jpegW, 10, 10, 80, 100, 1, 100, 75, 5, + 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, 100, 0, 5, + 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,7 +400,7 @@ /**************************************************/ -METHODDEF void xv_error_exit(cinfo) +METHODDEF(void) xv_error_exit(cinfo) j_common_ptr cinfo; { my_error_ptr myerr; @@ -412,7 +412,7 @@ /**************************************************/ -METHODDEF void xv_error_output(cinfo) +METHODDEF(void) xv_error_output(cinfo) j_common_ptr cinfo; { my_error_ptr myerr; @@ -426,7 +426,7 @@ /**************************************************/ -METHODDEF void xv_prog_meter(cinfo) +METHODDEF(void) xv_prog_meter(cinfo) j_common_ptr cinfo; { struct jpeg_progress_mgr *prog; @@ -671,7 +671,7 @@ /**************************************************/ -METHODDEF boolean xv_process_comment(cinfo) +METHODDEF(boolean) xv_process_comment(cinfo) j_decompress_ptr cinfo; { int length, hasnull; @@ -759,8 +759,8 @@ jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, qDial.val, TRUE); - cinfo.smoothing_factor = smDial.val; + jpeg_set_quality(&cinfo, (int)qDial.val, TRUE); + cinfo.smoothing_factor = (int)smDial.val; jpeg_start_compress(&cinfo, TRUE); @@ -769,7 +769,7 @@ /*** COMMENT HANDLING ***/ sprintf(xvcmt, "%sXV %s Quality = %d, Smoothing = %d\n", - CREATOR_STR, REVDATE, qDial.val, smDial.val); + CREATOR_STR, REVDATE, (int)qDial.val, (int)smDial.val); if (picComments) { /* append XV comment */ char *sp, *sp1; int done; diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvmisc.c ./xvmisc.c --- ../xv-3.10a-jp-extension-5.3.3/xvmisc.c Thu Oct 15 22:53:57 1998 +++ ./xvmisc.c Fri Oct 16 09:31:47 1998 @@ -28,6 +28,8 @@ * int xvbcmp (s1, s2, length) * void xvbzero(s, length) * char *xv_strstr(s1, s2) + * FILE *xv_fopen(str, str) + * void xv_mktemp(str) * void Timer(milliseconds) */ @@ -525,6 +527,10 @@ if (tiffW) XDestroyWindow(theDisp, tiffW); #endif +#ifdef HAVE_PNG + if (pngW) XDestroyWindow(theDisp, pngW); +#endif + #ifdef HAVE_PIC2 if (pic2W) XDestroyWindow(theDisp, pic2W); #endif /* HAVE_PIC2 */ @@ -734,6 +740,10 @@ if (tiffW) XDefineCursor(theDisp, tiffW, otherc); #endif +#ifdef HAVE_PNG + if (pngW) XDefineCursor(theDisp, pngW, otherc); +#endif + #ifdef HAVE_PIC2 if (pic2W) XDefineCursor(theDisp, pic2W, otherc); #endif /* HAVE_PIC2 */ @@ -1098,6 +1108,16 @@ } +/***************************************************/ +void xv_mktemp(buf, fname) + char *buf, *fname; +{ +#ifndef VMS + sprintf(buf, "%s/%s", tmpdir, fname); +#else + sprintf(buf, "Sys$Disk:[]%s", fname); +#endif +} /*******/ diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvpng.c ./xvpng.c --- ../xv-3.10a-jp-extension-5.3.3/xvpng.c Thu Jan 1 09:00:00 1970 +++ ./xvpng.c Fri Oct 16 10:00:56 1998 @@ -0,0 +1,998 @@ +/* + * 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 */ + 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 */ + do { + key = comment = strchr(comment, ':'); + } while (key && key[1] != ':'); + + /* 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_struct *png_ptr; + char *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_struct *png_ptr; + char *message; + */ + png_structp png_ptr; + png_const_charp message; +{ + if (!png_ptr) + return; + + SetISTR(ISTR_WARNING,"%s: libpng warning: %s", fbasename, message); +} + +#endif diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvpopup.c ./xvpopup.c --- ../xv-3.10a-jp-extension-5.3.3/xvpopup.c Fri Jan 20 03:09:31 1995 +++ ./xvpopup.c Fri Oct 16 08:59:21 1998 @@ -200,14 +200,14 @@ if (!padHaveDooDads) { DCreate(&padWDial, popW, 16, puhigh-16-100-1,75,100, - 1, 2048, pWIDE, 10, + 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, 2048, pHIGH, 10, + 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, 100, 100, 10, + 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,9 +258,9 @@ else if (poptyp == ISPAD) { BTSetActive(&bts[0], (int) strlen(gsBuf)); i = pWIDE * 3; RANGE(i,2048,9999); - DSetRange(&padWDial, 1, i, padWDial.val, 10); + DSetRange(&padWDial, 1.0, (double)i, padWDial.val, 1.0, 10.0); i = pHIGH * 3; RANGE(i,2048,9999); - DSetRange(&padHDial, 1, i, padHDial.val, 10); + 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,9 +465,9 @@ changedGSBuf(); /* careful! popW doesn't exist yet! */ if (padHaveDooDads) { - oldW = padWDial.val; - oldH = padHDial.val; - oldO = padODial.val; + oldW = (int)padWDial.val; + oldH = (int)padHDial.val; + oldO = (int)padODial.val; } else { oldW = pWIDE; oldH = pHIGH; oldO = 100; } @@ -486,9 +486,9 @@ } if (rv == 1) { /* cancelled: restore normal values */ - DSetVal(&padWDial, oldW); - DSetVal(&padHDial, oldH); - DSetVal(&padODial, oldO); + DSetVal(&padWDial, (double)oldW); + DSetVal(&padHDial, (double)oldH); + DSetVal(&padODial, (double)oldO); } XUnmapWindow(theDisp, padWDial.win); @@ -498,9 +498,9 @@ /* load up return values */ *pMode = padMode; *pStr = padBuf; - *pWide = padWDial.val; - *pHigh = padHDial.val; - *pOpaque = padODial.val; + *pWide = (int)padWDial.val; + *pHigh = (int)padHDial.val; + *pOpaque = (int)padODial.val; *pOmode = padOMode; return rv; @@ -972,8 +972,8 @@ 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); + DSetVal(&padWDial, (double)pWIDE); + DSetVal(&padHDial, (double)pHIGH); } } diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvps.c ./xvps.c --- ../xv-3.10a-jp-extension-5.3.3/xvps.c Fri Dec 23 07:34:42 1994 +++ ./xvps.c Fri Oct 16 08:59:21 1998 @@ -139,9 +139,9 @@ 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, + 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, 800, 100, 5, + 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,10 +236,10 @@ if (rd_int("psres")) { /* xv.psres: default paper resolution */ if (def_int >= 10 && def_int <= 720) { - int i = (int) ((PIX2INCH * 100) / def_int); + double v = (PIX2INCH * 100) / def_int; - DSetVal(&xsDial, i); - DSetVal(&ysDial, i); + DSetVal(&xsDial, v); + DSetVal(&ysDial, v); } } @@ -836,7 +836,7 @@ if (scx < scy) { sz_iny = h * scx; } else { sz_inx = w * scy; } - DSetVal(&xsDial, (int) ((100 * (sz_inx * PIX2INCH) / w) + .5)); + DSetVal(&xsDial, 100 * (sz_inx * PIX2INCH) / w); DSetVal(&ysDial, xsDial.val); sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0); diff -ruN --exclude=jpeg* --exclude=tiff* --exclude=*binaries ../xv-3.10a-jp-extension-5.3.3/xvtiff.c ./xvtiff.c --- ../xv-3.10a-jp-extension-5.3.3/xvtiff.c Thu Oct 15 22:53:58 1998 +++ ./xvtiff.c Fri Oct 16 08:54:03 1998 @@ -1,7 +1,7 @@ /* * xvtiff.c - load routine for 'TIFF' format pictures * - * LoadTIFF(fname, numcols) - load a TIFF file + * LoadTIFF(fname, numcols, quick) - load a TIFF file */ #ifndef va_start @@ -15,6 +15,35 @@ #include "tiffio.h" /* has to be after xv.h, as it needs varargs/stdarg */ +/* Portions fall under the following copyright: + * + * Copyright (c) 1992, 1993, 1994 Sam Leffler + * Copyright (c) 1992, 1993, 1994 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +static int copyTiff PARM((TIFF *, char *)); +static int cpStrips PARM((TIFF *, TIFF *)); +static int cpTiles PARM((TIFF *, TIFF *)); static byte *loadPalette PARM((TIFF *, uint32, uint32, int, int, PICINFO *)); static byte *loadColor PARM((TIFF *, uint32, uint32, int, int, PICINFO *)); static int loadImage PARM((TIFF *, uint32, uint32, byte *, int)); @@ -28,19 +57,23 @@ static int error_occurred; /*******************************************/ -int LoadTIFF(fname, pinfo) - char *fname; +int LoadTIFF(fname, pinfo, quick) + char *fname; PICINFO *pinfo; + int quick; /*******************************************/ { /* returns '1' on success, '0' on failure */ TIFF *tif; uint32 w, h; + float xres, yres; short bps, spp, photo, orient; FILE *fp; byte *pic8; char *desc, oldpath[MAXPATHLEN+1], tmppath[MAXPATHLEN+1], *sp; + char tmp[256], tmpname[256]; + int i, nump; error_occurred = 0; @@ -60,6 +93,8 @@ filesize = ftell(fp); fclose(fp); + + rmap = pinfo->r; gmap = pinfo->g; bmap = pinfo->b; /* a kludge: temporarily cd to the directory that the file is in (if @@ -81,9 +116,57 @@ } } + + nump = 1; + + if (!quick) { + /* see if there's more than 1 image in tiff file, to determine if we + should do multi-page thing... */ + + tif = TIFFOpen(filename,"r"); + if (!tif) return 0; + while (TIFFReadDirectory(tif)) nump++; + TIFFClose(tif); + if (DEBUG) + fprintf(stderr,"LoadTIFF: %d page%s found\n", nump, nump==1 ? "" : "s"); + + /* if there are multiple images, copy them out to multiple tmp files, + and load the first one... */ - tif=TIFFOpen(filename,"r"); + xv_mktemp(tmpname, "xvpgXXXXXX"); + + if (tmpname[0] == '\0') { /* mktemp() blew up */ + sprintf(str,"LoadTIFF: Unable to create temporary filename???"); + ErrPopUp(str, "\nHow unlikely!"); + return 0; + } + + if (nump>1) { + TIFF *in, *out; + + in = TIFFOpen(filename, "r"); + if (!in) return 0; + for (i=1; i<=nump; i++) { + sprintf(tmp, "%s%d", tmpname, i); + if (!copyTiff(in, tmp)) { + SetISTR(ISTR_WARNING, "LoadTIFF: Error writing page files!"); + break; + } + + if (!TIFFReadDirectory(in)) break; + } + if (DEBUG) + fprintf(stderr,"LoadTIFF: %d page%s written\n", + i-1, (i-1)==1 ? "" : "s"); + + sprintf(tmp, "%s%d", tmpname, 1); /* open page #1 */ + filename = tmp; + } + } /* if (!quick) ... */ + + + tif = TIFFOpen(filename,"r"); if (!tif) return 0; /* flip orientation so that image comes in X order */ @@ -107,6 +190,11 @@ TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bps); TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photo); TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &spp); + if ((TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) == 1) && + (TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) == 1)) { + normaspect = yres / xres; + if (DEBUG) fprintf(stderr,"TIFF aspect = %f\n", normaspect); + } if (spp == 1) { pic8 = loadPalette(tif, w, h, photo, bps, pinfo); @@ -139,6 +227,8 @@ if (pic8) free(pic8); if (pinfo->comment) free(pinfo->comment); pinfo->comment = (char *) NULL; + if (!quick && nump>1) KillPageFiles(tmpname, nump); + SetCursors(-1); return 0; } @@ -148,17 +238,167 @@ pinfo->normw = pinfo->w; pinfo->normh = pinfo->h; pinfo->frmType = F_TIFF; + if (nump>1) strcpy(pinfo->pagebname, tmpname); + pinfo->numpages = nump; if (pinfo->pic) return 1; + /* failed. if we malloc'd a comment, free it */ if (pinfo->comment) free(pinfo->comment); pinfo->comment = (char *) NULL; + if (!quick && nump>1) KillPageFiles(tmpname, nump); + SetCursors(-1); + return 0; } + + +/*******************************************/ + +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) +#define CopyField2(tag, v1, v2) \ + if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) +#define CopyField3(tag, v1, v2, v3) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) + + +/*******************************************/ +static int copyTiff(in, fname) + TIFF *in; + char *fname; +{ + /* copies tiff image to given filename. Returns 0 on error */ + + TIFF *out; + short bitspersample, samplesperpixel, shortv, *shortav; + uint32 w, l; + float floatv; + char *stringv; + uint32 longv; + uint16 *red, *green, *blue, shortv2; + int rv; + + out = TIFFOpen(fname, "w"); + if (!out) return 0; + + CopyField (TIFFTAG_SUBFILETYPE, longv); + CopyField (TIFFTAG_TILEWIDTH, w); + CopyField (TIFFTAG_TILELENGTH, l); + CopyField (TIFFTAG_IMAGEWIDTH, w); + CopyField (TIFFTAG_IMAGELENGTH, l); + CopyField (TIFFTAG_BITSPERSAMPLE, bitspersample); + CopyField (TIFFTAG_COMPRESSION, shortv); + CopyField (TIFFTAG_PREDICTOR, shortv); + CopyField (TIFFTAG_PHOTOMETRIC, shortv); + CopyField (TIFFTAG_THRESHHOLDING, shortv); + CopyField (TIFFTAG_FILLORDER, shortv); + CopyField (TIFFTAG_ORIENTATION, shortv); + CopyField (TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); + CopyField (TIFFTAG_MINSAMPLEVALUE, shortv); + CopyField (TIFFTAG_MAXSAMPLEVALUE, shortv); + CopyField (TIFFTAG_XRESOLUTION, floatv); + CopyField (TIFFTAG_YRESOLUTION, floatv); + CopyField (TIFFTAG_GROUP3OPTIONS, longv); + CopyField (TIFFTAG_GROUP4OPTIONS, longv); + CopyField (TIFFTAG_RESOLUTIONUNIT, shortv); + CopyField (TIFFTAG_PLANARCONFIG, shortv); + CopyField (TIFFTAG_ROWSPERSTRIP, longv); + CopyField (TIFFTAG_XPOSITION, floatv); + CopyField (TIFFTAG_YPOSITION, floatv); + CopyField (TIFFTAG_IMAGEDEPTH, longv); + CopyField (TIFFTAG_TILEDEPTH, longv); + CopyField2(TIFFTAG_EXTRASAMPLES, shortv, shortav); + CopyField3(TIFFTAG_COLORMAP, red, green, blue); + CopyField2(TIFFTAG_PAGENUMBER, shortv, shortv2); + CopyField (TIFFTAG_ARTIST, stringv); + CopyField (TIFFTAG_IMAGEDESCRIPTION,stringv); + CopyField (TIFFTAG_MAKE, stringv); + CopyField (TIFFTAG_MODEL, stringv); + CopyField (TIFFTAG_SOFTWARE, stringv); + CopyField (TIFFTAG_DATETIME, stringv); + CopyField (TIFFTAG_HOSTCOMPUTER, stringv); + CopyField (TIFFTAG_PAGENAME, stringv); + CopyField (TIFFTAG_DOCUMENTNAME, stringv); + + if (TIFFIsTiled(in)) rv = cpTiles (in, out); + else rv = cpStrips(in, out); + + TIFFClose(out); + return rv; +} + + +/*******************************************/ +static int cpStrips(in, out) + TIFF *in, *out; +{ + tsize_t bufsize; + byte *buf; + + bufsize = TIFFStripSize(in); + buf = (byte *) malloc((size_t) bufsize); + if (buf) { + tstrip_t s, ns = TIFFNumberOfStrips(in); + uint32 *bytecounts; + + TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts); + for (s = 0; s < ns; s++) { + if (bytecounts[s] > bufsize) { + buf = (unsigned char *) realloc(buf, (size_t) bytecounts[s]); + if (!buf) return (0); + bufsize = bytecounts[s]; + } + if (TIFFReadRawStrip (in, s, buf, (tsize_t) bytecounts[s]) < 0 || + TIFFWriteRawStrip(out, s, buf, (tsize_t) bytecounts[s]) < 0) { + free(buf); + return 0; + } + } + free(buf); + return 1; + } + return 0; +} + + +/*******************************/ +static int cpTiles(in, out) + TIFF *in, *out; +{ + tsize_t bufsize; + byte *buf; + + bufsize = TIFFTileSize(in); + buf = (unsigned char *) malloc((size_t) bufsize); + if (buf) { + ttile_t t, nt = TIFFNumberOfTiles(in); + uint32 *bytecounts; + + TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); + for (t = 0; t < nt; t++) { + if (bytecounts[t] > bufsize) { + buf = (unsigned char *)realloc(buf, (size_t) bytecounts[t]); + if (!buf) return (0); + bufsize = bytecounts[t]; + } + if (TIFFReadRawTile (in, t, buf, (tsize_t) bytecounts[t]) < 0 || + TIFFWriteRawTile(out, t, buf, (tsize_t) bytecounts[t]) < 0) { + free(buf); + return 0; + } + } + free(buf); + return 1; + } + return 0; +} + + /*******************************************/ static byte *loadPalette(tif, w, h, photo, bps, pinfo) TIFF *tif; @@ -186,7 +426,7 @@ break; } - sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h); + sprintf(pinfo->shrtInfo, "%ux%u TIFF.",(u_int) w, (u_int) h); pic8 = (byte *) malloc((size_t) w*h); if (!pic8) FatalError("loadPalette() - couldn't malloc 'pic8'"); @@ -214,7 +454,7 @@ "???"), filesize); - sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h); + sprintf(pinfo->shrtInfo, "%ux%u TIFF.",(u_int) w, (u_int) h); /* allocate 24-bit image */ pic24 = (byte *) malloc((size_t) w*h*3); @@ -301,10 +541,10 @@ static byte **BWmap; static byte **PALmap; -typedef void (*tileContigRoutine) PARM((byte*, u_char*, RGBvalue*, +typedef void (*xvtileContigRoutine) PARM((byte*, u_char*, RGBvalue*, uint32, uint32, int, int)); -typedef void (*tileSeparateRoutine) PARM((byte*, u_char*, u_char*, u_char*, +typedef void (*xvtileSeparateRoutine) PARM((byte*, u_char*, u_char*, u_char*, RGBvalue*, uint32, uint32, int, int)); @@ -340,7 +580,7 @@ uint32, uint32, int, int)); static void put4bitbwtile PARM((byte *, u_char *, RGBvalue *, uint32, uint32, int, int)); -static void put16bitbwtile PARM((byte *, u_char *, RGBvalue *, +static void put16bitbwtile PARM((byte *, u_short *, RGBvalue *, uint32, uint32, int, int)); static void putRGBcontig8bittile PARM((byte *, u_char *, RGBvalue *, @@ -366,8 +606,8 @@ static void putcontig8bitYCbCrtile PARM((byte *, u_char *, RGBvalue *, uint32, uint32, int, int)); -static tileContigRoutine pickTileContigCase PARM((RGBvalue *)); -static tileSeparateRoutine pickTileSeparateCase PARM((RGBvalue *)); +static xvtileContigRoutine pickTileContigCase PARM((RGBvalue *)); +static xvtileSeparateRoutine pickTileSeparateCase PARM((RGBvalue *)); /*******************************************/ @@ -641,7 +881,7 @@ u_char *buf; int fromskew, toskew; u_int nrow; - tileContigRoutine put; + xvtileContigRoutine put; put = pickTileContigCase(Map); if (put == 0) return (0); @@ -708,7 +948,7 @@ int tilesize; int fromskew, toskew; u_int nrow; - tileSeparateRoutine put; + xvtileSeparateRoutine put; put = pickTileSeparateCase(Map); if (put == 0) return (0); @@ -779,7 +1019,7 @@ { uint32 row, y, nrow; u_char *buf; - tileContigRoutine put; + xvtileContigRoutine put; uint32 rowsperstrip; uint32 imagewidth; int scanline; @@ -832,7 +1072,7 @@ u_char *r, *g, *b; uint32 row, y, nrow; int scanline; - tileSeparateRoutine put; + xvtileSeparateRoutine put; uint32 rowsperstrip; uint32 imagewidth; u_int stripsize; @@ -1014,7 +1254,7 @@ #define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; } #define UNROLL8(w, op1, op2) { \ - uint32 x; \ + uint32 x; \ for (x = w; x >= 8; x -= 8) { \ op1; \ REPEAT8(op2); \ @@ -1026,7 +1266,7 @@ } #define UNROLL4(w, op1, op2) { \ - register uint32 x; \ + uint32 x; \ for (x = w; x >= 4; x -= 4) { \ op1; \ REPEAT4(op2); \ @@ -1038,7 +1278,7 @@ } #define UNROLL2(w, op1, op2) { \ - register uint32 x; \ + uint32 x; \ for (x = w; x >= 2; x -= 2) { \ op1; \ REPEAT2(op2); \ @@ -1065,7 +1305,7 @@ int fromskew, toskew; { while (h-- > 0) { - UNROLL8(w,0, *cp++ = PALmap[*pp++][0]); + UNROLL8(w,, *cp++ = PALmap[*pp++][0]); cp += toskew; pp += fromskew; } @@ -1218,7 +1458,7 @@ */ static void put16bitbwtile(cp, pp, Map, w, h, fromskew, toskew) byte *cp; - u_char *pp; + u_short *pp; RGBvalue *Map; uint32 w, h; int fromskew, toskew; @@ -1227,8 +1467,7 @@ while (h-- > 0) { for (x=w; x>0; x--) { - *cp++ = Map[(pp[0] << 8) + pp[1]]; - pp += 2; + *cp++ = Map[*pp++]; } cp += toskew; pp += fromskew; @@ -1262,7 +1501,7 @@ } } else { while (h-- > 0) { - UNROLL8(w,0, + UNROLL8(w,, *cp++ = pp[0]; *cp++ = pp[1]; *cp++ = pp[2]; @@ -1335,7 +1574,7 @@ } } else { while (h-- > 0) { - UNROLL8(w,0, + UNROLL8(w,, *cp++ = *r++; *cp++ = *g++; *cp++ = *b++; @@ -1489,16 +1728,16 @@ /* * Select the appropriate conversion routine for packed data. */ -static tileContigRoutine pickTileContigCase(Map) +static xvtileContigRoutine pickTileContigCase(Map) RGBvalue* Map; { - tileContigRoutine put = 0; + xvtileContigRoutine put = 0; switch (photometric) { case PHOTOMETRIC_RGB: switch (bitspersample) { - case 8: put = (tileContigRoutine) putRGBcontig8bittile; break; - case 16: put = (tileContigRoutine) putRGBcontig16bittile; break; + case 8: put = putRGBcontig8bittile; break; + case 16: put = (xvtileContigRoutine)putRGBcontig16bittile; break; } break; @@ -1514,7 +1753,7 @@ case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: switch (bitspersample) { - case 16: put = put16bitbwtile; break; + case 16: put = (tileContigRoutine) put16bitbwtile; break; case 8: put = putgreytile; break; case 4: put = put4bitbwtile; break; case 2: put = put2bitbwtile; break; @@ -1540,16 +1779,16 @@ * NB: we assume that unpacked single channel data is directed * to the "packed routines. */ -static tileSeparateRoutine pickTileSeparateCase(Map) +static xvtileSeparateRoutine pickTileSeparateCase(Map) RGBvalue* Map; { - tileSeparateRoutine put = 0; + xvtileSeparateRoutine put = 0; switch (photometric) { case PHOTOMETRIC_RGB: switch (bitspersample) { - case 8: put = (tileSeparateRoutine) putRGBseparate8bittile; break; - case 16: put = (tileSeparateRoutine) putRGBseparate16bittile; break; + case 8: put = (xvtileSeparateRoutine) putRGBseparate8bittile; break; + case 16: put = (xvtileSeparateRoutine) putRGBseparate16bittile; break; } break; }