summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhe <he@pkgsrc.org>2005-08-10 16:50:18 +0000
committerhe <he@pkgsrc.org>2005-08-10 16:50:18 +0000
commit351592d780e17f601487f2f57db086a9e27badfd (patch)
tree2ea820c11dda6de965a168d55f4d309c02be646b
parent35be7aab3b48d8df6784a8bdf5f6427991f752cb (diff)
downloadpkgsrc-351592d780e17f601487f2f57db086a9e27badfd.tar.gz
Instead of separately integrating several different patches, instead
pull in the Jumbo patches from http://www.sonic.net/~roelofs/greg_xv.html. As far as I can see this covers all our existing patches for added functionality, although I cannot claim that I have tested each and every one of them in the new version. These patches disable a number of image formats that I think are less common, which have potential heap overflows in the code due to in- sufficient validation of image dimensions. The version of the Jumbo patch used here is the 20050501 version. Package revision bumped to nb10.
-rw-r--r--graphics/xv/Makefile24
-rw-r--r--graphics/xv/PLIST5
-rw-r--r--graphics/xv/distinfo45
-rw-r--r--graphics/xv/patches/patch-aa13
-rw-r--r--graphics/xv/patches/patch-ab58
-rw-r--r--graphics/xv/patches/patch-ac22
-rw-r--r--graphics/xv/patches/patch-ad12
-rw-r--r--graphics/xv/patches/patch-ae474
-rw-r--r--graphics/xv/patches/patch-af50
-rw-r--r--graphics/xv/patches/patch-ag975
-rw-r--r--graphics/xv/patches/patch-ah42
-rw-r--r--graphics/xv/patches/patch-ai83
-rw-r--r--graphics/xv/patches/patch-aj82
-rw-r--r--graphics/xv/patches/patch-ak62
-rw-r--r--graphics/xv/patches/patch-al179
-rw-r--r--graphics/xv/patches/patch-am63
-rw-r--r--graphics/xv/patches/patch-an233
-rw-r--r--graphics/xv/patches/patch-ao86
-rw-r--r--graphics/xv/patches/patch-ap97
-rw-r--r--graphics/xv/patches/patch-aq152
-rw-r--r--graphics/xv/patches/patch-ar37
-rw-r--r--graphics/xv/patches/patch-as52
-rw-r--r--graphics/xv/patches/patch-at90
-rw-r--r--graphics/xv/patches/patch-au39
-rw-r--r--graphics/xv/patches/patch-av39
-rw-r--r--graphics/xv/patches/patch-aw45
-rw-r--r--graphics/xv/patches/patch-ax395
-rw-r--r--graphics/xv/patches/patch-ay18
28 files changed, 110 insertions, 3362 deletions
diff --git a/graphics/xv/Makefile b/graphics/xv/Makefile
index 9a12acfff6e..43961b5335c 100644
--- a/graphics/xv/Makefile
+++ b/graphics/xv/Makefile
@@ -1,32 +1,28 @@
-# $NetBSD: Makefile,v 1.58 2005/07/19 13:56:48 wiz Exp $
+# $NetBSD: Makefile,v 1.59 2005/08/10 16:50:18 he Exp $
DISTNAME= xv-3.10a
-PKGREVISION= 9
+PKGREVISION= 10
CATEGORIES= graphics x11
-MASTER_SITES= ftp://ftp.cis.upenn.edu/pub/xv/ \
- ftp://ftp.kuis.kyoto-u.ac.jp/X11/contrib/clients/xv/ \
- ftp://ftp.tohoku.ac.jp/pub/X/app/xv/
-DISTFILES= ${DISTNAME}${EXTRACT_SUFX} \
- xv310a-magpic2-PhotoCD-patch.tar.gz # only from Japan
+MASTER_SITES= ftp://ftp.cis.upenn.edu/pub/xv/
+#DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
-PATCH_SITES= ftp://ftp.cis.upenn.edu/pub/xv/
-PATCHFILES= xv-3.10a.JPEG-patch xv-3.10a.TIFF-patch # (for tiff3.4)
+PATCHFILES= xv-3.10a-jumbo-patches-20050501.tar.bz2
+PATCH_SITES= ${MASTER_SITE_SOURCEFORGE:=png-mng/}
+PATCH_DIST_CAT= ${BZCAT} $$patchfile | ${TAR} -Oxf - "*-patch-*"
+PATCH_DIST_STRIP= -p1
MAINTAINER= tech-pkg@NetBSD.org
HOMEPAGE= http://www.trilon.com/xv/
+# and... http://www.sonic.net/~roelofs/greg_xv.html
COMMENT= X11 program that displays images of various formats
-
USE_IMAKE= YES
LICENSE= xv-license
.include "../../mk/bsd.prefs.mk"
-pre-patch:
- @${PATCH} ${PATCH_ARGS} -p1 < ${WRKDIR}/Patch.magpic2.PhotoCD.XV310a
-
-post-patch:
+pre-configure:
${MV} ${WRKSRC}/config.h ${WRKSRC}/config.h.orig && \
${SED} -e 's|@LOCALBASE@|${LOCALBASE}|g' \
${WRKSRC}/config.h.orig > ${WRKSRC}/config.h
diff --git a/graphics/xv/PLIST b/graphics/xv/PLIST
index 00df60171de..b1de604e671 100644
--- a/graphics/xv/PLIST
+++ b/graphics/xv/PLIST
@@ -1,9 +1,10 @@
-@comment $NetBSD: PLIST,v 1.2 2003/03/01 00:06:41 grant Exp $
-bin/xv
+@comment $NetBSD: PLIST,v 1.3 2005/08/10 16:50:18 he Exp $
bin/bggen
bin/vdcomp
bin/xcmap
+bin/xv
bin/xvpictoppm
+lib/X11/xv_mgcsfx.sample
${IMAKE_MAN_DIR}/xv.${IMAKE_MANNEWSUFFIX}
${IMAKE_MAN_DIR}/bggen.${IMAKE_MANNEWSUFFIX}
${IMAKE_MAN_DIR}/vdcomp.${IMAKE_MANNEWSUFFIX}
diff --git a/graphics/xv/distinfo b/graphics/xv/distinfo
index 8d01fe5916c..ffe2928eee7 100644
--- a/graphics/xv/distinfo
+++ b/graphics/xv/distinfo
@@ -1,39 +1,14 @@
-$NetBSD: distinfo,v 1.10 2005/05/25 12:32:30 wiz Exp $
+$NetBSD: distinfo,v 1.11 2005/08/10 16:50:18 he Exp $
SHA1 (xv-3.10a.tar.gz) = 9e6372f154be9e9e355972cbeb91d98d9c342474
RMD160 (xv-3.10a.tar.gz) = 7d545e0c0e5b0120a7d026ea549cba19a53fbc0d
Size (xv-3.10a.tar.gz) = 2259124 bytes
-SHA1 (xv310a-magpic2-PhotoCD-patch.tar.gz) = b36192f0ab6cefba4221f8137d717a4c2cd45abd
-RMD160 (xv310a-magpic2-PhotoCD-patch.tar.gz) = 012c800f252d6d64c4906051e1964e59d32cf128
-Size (xv310a-magpic2-PhotoCD-patch.tar.gz) = 56612 bytes
-SHA1 (xv-3.10a.JPEG-patch) = 05d0de5a3c4babc36f867247e1920eca6b9e9ff0
-RMD160 (xv-3.10a.JPEG-patch) = f69cb0c07c116fbcec58678bcba1b5ef96cb7e62
-Size (xv-3.10a.JPEG-patch) = 3297 bytes
-SHA1 (xv-3.10a.TIFF-patch) = 5e1ce5610a83a88d5878eefe175352a4cc2aa21c
-RMD160 (xv-3.10a.TIFF-patch) = 4c09609558f1b93a67cae2abaf14462208dd850b
-Size (xv-3.10a.TIFF-patch) = 3241 bytes
-SHA1 (patch-aa) = 2c3b3819b77df503d6d86725cbc2fce2d101a1b0
-SHA1 (patch-ab) = dee0a3fc05e01f8b15c636ec4dcf745533eca345
-SHA1 (patch-ac) = 79793d6feb5d15e8e91f3e0747b7b14b00b21254
-SHA1 (patch-ad) = 699c3b8e636b369ec2f0de995df0c028f6b1e91a
-SHA1 (patch-ae) = a2adc219090e3214ff6c891cd76d3285ee0596b0
-SHA1 (patch-af) = 1c6578865affe775936d10118de72aada84887c5
-SHA1 (patch-ag) = 6802096dc1493a92379cd2750448407cf4e08dc4
-SHA1 (patch-ah) = 5d9fbc3459c44e8c61f50d9f0624ec2069795af9
-SHA1 (patch-ai) = 1beb3d45b08be536f297661f5dbdca050591548a
-SHA1 (patch-aj) = 0df06a5187f43dd4a97f795d9ef29fe773b21806
-SHA1 (patch-ak) = cfefb6ed9d0747f620f9ea4dcfc948fd8355f137
-SHA1 (patch-al) = 7a1118af7b5581ab0fd28b95d4a973aefb544b09
-SHA1 (patch-am) = 6b59620ae2998f28a06c88d292c6ab9fc9095ccb
-SHA1 (patch-an) = 8eb0076fc932ad3859e72b5de228806457e812f8
-SHA1 (patch-ao) = a708368db9288b0697d9c7fac117b4a1c2eaa751
-SHA1 (patch-ap) = d80d3f42ef65f8941a9a2b318ec3895cf35a6fa4
-SHA1 (patch-aq) = 5ab291d650c65437000951c6cbb42c0b7799db8f
-SHA1 (patch-ar) = 61747379c2f080d13bc76b2175e8e7ae61647374
-SHA1 (patch-as) = 03e8fafaf267fda7e17aee58ba48096796161e74
-SHA1 (patch-at) = 25e111754de9fbb48f17bf140f984e14a29413a9
-SHA1 (patch-au) = 3cb2fde94db4b71a449c81e4b912132b204b0062
-SHA1 (patch-av) = cb815b12de135927cad826623c5071e938a59509
-SHA1 (patch-aw) = 2085110d88d34a78d14b68dd6a3cbff56251352f
-SHA1 (patch-ax) = 81adbda29a9e3633085bd41b409f5795d0f353b1
-SHA1 (patch-ay) = 55ccef29880f7fed50a1287402dd5e8b50b98b48
+SHA1 (xv-3.10a-jumbo-patches-20050501.tar.bz2) = deb42fc30697312f13fcedb88f10cc3ed0ced8ac
+RMD160 (xv-3.10a-jumbo-patches-20050501.tar.bz2) = d199e7d1b6c5162e0cad09d4118b3735f1d156ef
+Size (xv-3.10a-jumbo-patches-20050501.tar.bz2) = 369886 bytes
+SHA1 (patch-ac) = cc0da5cefbb4a13b86daaca482c52ece4bc3294c
+SHA1 (patch-ad) = 3a49ca0152f6a7d6cf79348e3b5308da509b63ea
+SHA1 (patch-af) = bff31d4bc15986e293cf4796dcd3df808057f6db
+SHA1 (patch-ah) = 830139139ddf49a505786cde8930ba1e9ae006f4
+SHA1 (patch-ai) = 10febc95047fc25a3b93c157eb39ed1ed7a30bc6
+SHA1 (patch-aj) = 7f40c002d8a16b1507c6171db543285447e3cf81
diff --git a/graphics/xv/patches/patch-aa b/graphics/xv/patches/patch-aa
deleted file mode 100644
index d93d0ea5f6f..00000000000
--- a/graphics/xv/patches/patch-aa
+++ /dev/null
@@ -1,13 +0,0 @@
-$NetBSD: patch-aa,v 1.2 1998/08/07 10:40:55 agc Exp $
-
---- ./xvpcd.c.org Wed Jul 2 23:59:27 1997
-+++ ./xvpcd.c Thu Jul 3 00:17:25 1997
-@@ -623,7 +623,7 @@
-
- for (i=0; i<T_NBUTTS; i++) BTRedraw(&tbut[i]);
-
-- ULineString(pcdW, "Resolution", resnRB->x-16, resnRB->y-10-DESCENT);
-+ ULineString(pcdW, resnRB->x-16, resnRB->y-10-DESCENT, "Resolution");
- RBRedraw(resnRB, -1);
-
- XDrawString(theDisp, pcdW, theGC, 20, 19, title, strlen(title));
diff --git a/graphics/xv/patches/patch-ab b/graphics/xv/patches/patch-ab
deleted file mode 100644
index 8fd60ea28e5..00000000000
--- a/graphics/xv/patches/patch-ab
+++ /dev/null
@@ -1,58 +0,0 @@
-$NetBSD: patch-ab,v 1.6 2003/02/28 23:44:38 grant Exp $
-
---- vdcomp.c.orig Sat Mar 1 10:42:12 2003
-+++ vdcomp.c
-@@ -109,12 +109,16 @@
- !defined(__bsd43) && \
- !defined(aux) && \
- !defined(__bsdi__) && \
-- !defined(sequent)
-+ !defined(sequent) && \
-+ !defined(__FreeBSD__) && \
-+ !defined(__NetBSD__) && \
-+ !defined(__DARWIN__)
-
- # if defined(hp300) || defined(hp800) || defined(NeXT)
- # include <sys/malloc.h> /* it's in 'sys' on HPs and NeXT */
- # else
--# if !defined(__386BSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
-+# if !defined(__386BSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) \
-+ && !defined(__Darwin__)
- /*
- I want to use BSD macro for checking if this OS is *BSD or not,
- but the macro is defined in <sys/parm.h>, which I don't know all
-@@ -437,10 +441,13 @@ int host;
- {
- short shortint;
- typedef long off_t;
-+ char *s;
-
- if (inname[0] == ' ') {
- printf("\nEnter name of file to be decompressed: ");
-- gets (inname);
-+ fgets (inname, sizeof(inname), stdin);
-+ if ((s = strchr(inname, '\n')) != NULL)
-+ *s = '\0';
- }
-
- if (host == 1 | host == 2) {
-@@ -482,13 +489,17 @@ int host;
- printf("\n 3. VICAR format.");
- printf("\n 4. Unlabelled binary array.\n");
- printf("\n Enter format number:");
-- gets(inname);
-+ fgets (inname, sizeof(inname), stdin);
-+ if ((s = strchr(inname, '\n')) != NULL)
-+ *s = '\0';
- output_format = atoi(inname);
- } while (output_format < 1 || output_format > 4);
-
- if (outname[0] == ' ') {
- printf("\nEnter name of uncompressed output file: ");
-- gets (outname);
-+ fgets (outname, sizeof(outname), stdin);
-+ if ((s = strchr(outname, '\n')) != NULL)
-+ *s = '\0';
- }
-
- return(host);
diff --git a/graphics/xv/patches/patch-ac b/graphics/xv/patches/patch-ac
index 3637f41d581..90853f8f1fa 100644
--- a/graphics/xv/patches/patch-ac
+++ b/graphics/xv/patches/patch-ac
@@ -1,26 +1,18 @@
-$NetBSD: patch-ac,v 1.7 2000/04/20 16:30:52 jlam Exp $
+$NetBSD: patch-ac,v 1.8 2005/08/10 16:50:18 he Exp $
---- config.h.orig Fri Nov 19 09:32:02 1999
-+++ config.h Fri Nov 19 09:32:57 1999
-@@ -13,7 +13,7 @@
- * definition appropriately. (use 'which gunzip' to find if you have gunzip,
- * and where it lives)
- */
--#undef USE_GUNZIP
-+#define USE_GUNZIP
-
- #ifdef USE_GUNZIP
- # ifdef VMS
-@@ -98,9 +98,9 @@
+--- config.h.orig 2005-07-29 15:11:02.000000000 +0200
++++ config.h
+@@ -116,10 +116,9 @@
* should not need to be changed
*/
-/* #define GS_PATH "/usr/local/bin/gs" */
+-#define GS_PATH "/usr/bin/gs"
-/* #define GS_LIB "." */
-/* #define GS_DEV "ppmraw" */
+#define GS_PATH "@LOCALBASE@/bin/gs"
-+#define GS_LIB "@LOCALBASE@/share/ghostscript"
-+#define GS_DEV "ppmraw"
++#define GS_LIB "@LOCALBASE@/share/ghostscript"
++#define GS_DEV "ppmraw"
/***************************************************************************
diff --git a/graphics/xv/patches/patch-ad b/graphics/xv/patches/patch-ad
index af4546ff890..084cd73ae99 100644
--- a/graphics/xv/patches/patch-ad
+++ b/graphics/xv/patches/patch-ad
@@ -1,7 +1,7 @@
-$NetBSD: patch-ad,v 1.8 2001/04/05 13:57:15 wiz Exp $
+$NetBSD: patch-ad,v 1.9 2005/08/10 16:50:18 he Exp $
---- Imakefile.orig Tue Oct 27 00:45:53 1998
-+++ Imakefile Tue Oct 27 01:13:26 1998
+--- Imakefile.orig 2005-07-29 15:14:59.000000000 +0200
++++ Imakefile
@@ -6,13 +6,15 @@
/* if, for whatever reason, you're unable to get the JPEG library to compile
* on your machine, *COMMENT OUT* the following line
@@ -20,7 +20,7 @@ $NetBSD: patch-ad,v 1.8 2001/04/05 13:57:15 wiz Exp $
/* if, for whatever reason, you're unable to get the PDS/VICAR support
-@@ -119,16 +121,30 @@
+@@ -124,16 +126,30 @@ MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\"
JPEG = -DDOJPEG
JPEGDIR = jpeg
LIBJPEG = $(JPEGDIR)/libjpeg.a
@@ -51,7 +51,7 @@ $NetBSD: patch-ad,v 1.8 2001/04/05 13:57:15 wiz Exp $
#ifdef HavePDS
PDS = -DDOPDS
#endif
-@@ -141,8 +157,8 @@
+@@ -149,8 +165,8 @@ SYS_LIBRARIES= -lm
#endif
@@ -62,7 +62,7 @@ $NetBSD: patch-ad,v 1.8 2001/04/05 13:57:15 wiz Exp $
DEFINES= $(SCO) $(UNIX) $(NODIRENT) $(VPRINTF) $(TIMERS) \
$(HPUX7) $(JPEG) $(TIFF) $(PDS) $(DXWM) $(RAND) \
-@@ -182,10 +198,10 @@
+@@ -194,10 +210,10 @@ OBJS5= xvpictoppm.o
PROGRAMS= xv bggen vdcomp xcmap xvpictoppm
diff --git a/graphics/xv/patches/patch-ae b/graphics/xv/patches/patch-ae
deleted file mode 100644
index 2355ffc298d..00000000000
--- a/graphics/xv/patches/patch-ae
+++ /dev/null
@@ -1,474 +0,0 @@
-$NetBSD: patch-ae,v 1.2 1998/08/07 10:40:56 agc Exp $
-
---- xvimage.c~ Fri Jan 13 18:11:36 1995
-+++ xvimage.c Tue Oct 15 16:41:47 1996
-@@ -46,6 +46,274 @@
- static int ReadImageFile1 PARM((char *, PICINFO *));
-
-
-+/* The following array represents the pixel values for each shade of
-+ * the primary color components.
-+ * If 'p' is a pointer to a source image rgb-byte-triplet, we can
-+ * construct the output pixel value simply by 'oring' together
-+ * the corresponding components:
-+ *
-+ * unsigned char *p;
-+ * unsigned long pixval;
-+ *
-+ * pixval = screen_rgb[0][*p++];
-+ * pixval |= screen_rgb[1][*p++];
-+ * pixval |= screen_rgb[2][*p++];
-+ *
-+ * This is both efficient and generic, since the only assumption
-+ * is that the primary color components have separate bits.
-+ * The order and distribution of bits does not matter, and we
-+ * don't need additional vaiables and shifting/masking code.
-+ * The array size is 3 KBytes total and thus very reasonable.
-+ */
-+
-+static unsigned long screen_rgb[3][256];
-+
-+/* The following array holds the exact color representations
-+ * reported by the system.
-+ * This is useful for less than 24 bit deep displays as a base
-+ * for additional dithering to get smoother output.
-+ */
-+
-+static byte screen_set[3][256];
-+
-+/* The following routine initializes the screen_rgb and screen_set
-+ * arrays.
-+ * Since it is executed only once per program run, it does not need
-+ * to be super-efficient.
-+ *
-+ * The method is to draw points in a pixmap with the specified shades
-+ * of primary colors and then get the corresponding XImage pixel
-+ * representation.
-+ * Thus we can get away with any Bit-order/Byte-Order dependencies.
-+ *
-+ * The routine uses some global X variables: theDisp, theScreen,
-+ * and dispDEEP. Adapt these to your application as necessary.
-+ * I've not passed them in as parameters, since for other platforms
-+ * than X these may be different (see vfixpix.c), and so the
-+ * screen_init() interface is unique.
-+ *
-+ * BUG: I've read in the "Xlib Programming Manual" from O'Reilly &
-+ * Associates, that the DefaultColormap in TrueColor might not
-+ * provide the full shade representation in XAllocColor.
-+ * In this case one had to provide a 'best' colormap instead.
-+ * However, my tests with Xaccel on a Linux-Box with a Mach64
-+ * card were fully successful, so I leave that potential problem
-+ * to you at the moment and would appreciate any suggestions...
-+ */
-+
-+static void screen_init()
-+{
-+ static int init_flag; /* assume auto-init as 0 */
-+ Pixmap check_map;
-+ GC check_gc;
-+ XColor check_col;
-+ XImage *check_image;
-+ int ci, i;
-+
-+ if (init_flag) return;
-+ init_flag = 1;
-+
-+ check_map = XCreatePixmap(theDisp, RootWindow(theDisp,theScreen),
-+ 1, 1, dispDEEP);
-+ check_gc = XCreateGC(theDisp, RootWindow(theDisp,theScreen), 0, NULL);
-+ for (ci = 0; ci < 3; ci++) {
-+ for (i = 0; i < 256; i++) {
-+ check_col.flags = DoRed | DoGreen | DoBlue;
-+ check_col.red = 0;
-+ check_col.green = 0;
-+ check_col.blue = 0;
-+ /* Do proper upscaling from unsigned 8 bit (image data values)
-+ to unsigned 16 bit (X color representation). */
-+ ((unsigned short *)&check_col.red)[ci] = (unsigned short)((i << 8) | i);
-+ if (!XAllocColor(theDisp, DefaultColormap(theDisp,theScreen), &check_col))
-+ FatalError("XAllocColor in screen_init() failed"); /* shouldn't happen */
-+ screen_set[ci][i] =
-+ (((unsigned short *)&check_col.red)[ci] >> 8) & 0xff;
-+ XSetForeground(theDisp, check_gc, check_col.pixel);
-+ XDrawPoint(theDisp, check_map, check_gc, 0, 0);
-+ check_image = XGetImage(theDisp, check_map, 0, 0, 1, 1,
-+ AllPlanes, ZPixmap);
-+ if (!check_image) FatalError("XGetImage in screen_init() failed");
-+ switch (check_image->bits_per_pixel) {
-+ case 8:
-+ screen_rgb[ci][i] = *(CARD8 *)check_image->data;
-+ break;
-+ case 16:
-+ screen_rgb[ci][i] = *(CARD16 *)check_image->data;
-+ break;
-+ case 24:
-+ screen_rgb[ci][i] =
-+ ((unsigned long)*(CARD8 *)check_image->data << 16) |
-+ ((unsigned long)*(CARD8 *)(check_image->data + 1) << 8) |
-+ (unsigned long)*(CARD8 *)(check_image->data + 2);
-+ break;
-+ case 32:
-+ screen_rgb[ci][i] = *(CARD32 *)check_image->data;
-+ break;
-+ }
-+ XDestroyImage(check_image);
-+ }
-+ }
-+ XFreeGC(theDisp, check_gc);
-+ XFreePixmap(theDisp, check_map);
-+}
-+
-+
-+/* The following switch should better be provided at runtime for
-+ * comparison purposes.
-+ * At the moment it's only compile time, unfortunately.
-+ * Who can make adaptions for use as a runtime switch by a menu option?
-+ */
-+
-+#define DO_FIXPIX_SMOOTH
-+
-+#ifdef DO_FIXPIX_SMOOTH
-+
-+/* The following code is based in part on:
-+ *
-+ * jquant1.c
-+ *
-+ * Copyright (C) 1991-1996, Thomas G. Lane.
-+ * This file is part of the Independent JPEG Group's software.
-+ * For conditions of distribution and use, see the accompanying README file.
-+ *
-+ * This file contains 1-pass color quantization (color mapping) routines.
-+ * These routines provide mapping to a fixed color map using equally spaced
-+ * color values. Optional Floyd-Steinberg or ordered dithering is available.
-+ */
-+
-+/* Declarations for Floyd-Steinberg dithering.
-+ *
-+ * Errors are accumulated into the array fserrors[], at a resolution of
-+ * 1/16th of a pixel count. The error at a given pixel is propagated
-+ * to its not-yet-processed neighbors using the standard F-S fractions,
-+ * ... (here) 7/16
-+ * 3/16 5/16 1/16
-+ * We work left-to-right on even rows, right-to-left on odd rows.
-+ *
-+ * We can get away with a single array (holding one row's worth of errors)
-+ * by using it to store the current row's errors at pixel columns not yet
-+ * processed, but the next row's errors at columns already processed. We
-+ * need only a few extra variables to hold the errors immediately around the
-+ * current column. (If we are lucky, those variables are in registers, but
-+ * even if not, they're probably cheaper to access than array elements are.)
-+ *
-+ * The fserrors[] array is indexed [component#][position].
-+ * We provide (#columns + 2) entries per component; the extra entry at each
-+ * end saves us from special-casing the first and last pixels.
-+ */
-+
-+typedef INT16 FSERROR; /* 16 bits should be enough */
-+typedef int LOCFSERROR; /* use 'int' for calculation temps */
-+
-+typedef struct { byte *colorset;
-+ FSERROR *fserrors;
-+ } FSBUF;
-+
-+/* Floyd-Steinberg initialization function.
-+ *
-+ * It is called 'fs2_init' since it's specialized for our purpose and
-+ * could be embedded in a more general FS-package.
-+ *
-+ * Returns a malloced FSBUF pointer which has to be passed as first
-+ * parameter to subsequent 'fs2_dither' calls.
-+ * The FSBUF structure does not need to be referenced by the calling
-+ * application, it can be treated from the app like a void pointer.
-+ *
-+ * The current implementation does only require to free() this returned
-+ * pointer after processing.
-+ *
-+ * Returns NULL if malloc fails.
-+ *
-+ * NOTE: The FSBUF structure is designed to allow the 'fs2_dither'
-+ * function to work with an *arbitrary* number of color components
-+ * at runtime! This is an enhancement over the IJG code base :-).
-+ * Only fs2_init() specifies the (maximum) number of components.
-+ */
-+
-+static FSBUF *fs2_init(width)
-+int width;
-+{
-+ FSBUF *fs;
-+ FSERROR *p;
-+
-+ fs = (FSBUF *)
-+ malloc(sizeof(FSBUF) * 3 + ((size_t)width + 2) * sizeof(FSERROR) * 3);
-+ if (fs == 0) return fs;
-+
-+ fs[0].colorset = screen_set[0];
-+ fs[1].colorset = screen_set[1];
-+ fs[2].colorset = screen_set[2];
-+
-+ p = (FSERROR *)(fs + 3);
-+ memset(p, 0, ((size_t)width + 2) * sizeof(FSERROR) * 3);
-+
-+ fs[0].fserrors = p;
-+ fs[1].fserrors = p + 1;
-+ fs[2].fserrors = p + 2;
-+
-+ return fs;
-+}
-+
-+/* Floyd-Steinberg dithering function.
-+ *
-+ * NOTE:
-+ * (1) The image data referenced by 'ptr' is *overwritten* (input *and*
-+ * output) to allow more efficient implementation.
-+ * (2) Alternate FS dithering is provided by the sign of 'nc'. Pass in
-+ * a negative value for right-to-left processing. The return value
-+ * provides the right-signed value for subsequent calls!
-+ * (3) This particular implementation assumes *no* padding between lines!
-+ * Adapt this if necessary.
-+ */
-+
-+static int fs2_dither(fs, ptr, nc, num_rows, num_cols)
-+FSBUF *fs;
-+byte *ptr;
-+int nc, num_rows, num_cols;
-+{
-+ int abs_nc, ci, row, col;
-+ LOCFSERROR delta, cur, belowerr, bpreverr;
-+ byte *dataptr, *colsetptr;
-+ FSERROR *errorptr;
-+
-+ if ((abs_nc = nc) < 0) abs_nc = -abs_nc;
-+ for (row = 0; row < num_rows; row++) {
-+ for (ci = 0; ci < abs_nc; ci++, ptr++) {
-+ dataptr = ptr;
-+ colsetptr = fs[ci].colorset;
-+ errorptr = fs[ci].fserrors;
-+ if (nc < 0) {
-+ dataptr += (num_cols - 1) * abs_nc;
-+ errorptr += (num_cols + 1) * abs_nc;
-+ }
-+ cur = belowerr = bpreverr = 0;
-+ for (col = 0; col < num_cols; col++) {
-+ cur += errorptr[nc];
-+ cur += 8; cur >>= 4;
-+ if ((cur += *dataptr) < 0) cur = 0;
-+ else if (cur > 255) cur = 255;
-+ *dataptr = cur & 0xff;
-+ cur -= colsetptr[cur];
-+ delta = cur << 1; cur += delta;
-+ bpreverr += cur; cur += delta;
-+ belowerr += cur; cur += delta;
-+ errorptr[0] = (FSERROR)bpreverr;
-+ bpreverr = belowerr;
-+ belowerr = delta >> 1;
-+ dataptr += nc;
-+ errorptr += nc;
-+ }
-+ errorptr[0] = (FSERROR)bpreverr;
-+ }
-+ ptr += (num_cols - 1) * abs_nc;
-+ nc = -nc;
-+ }
-+ return nc;
-+}
-+
-+#endif /* DO_FIXPIX_SMOOTH */
-+
-
- #define DO_CROP 0
- #define DO_ZOOM 1
-@@ -1883,33 +2151,17 @@
- /* Non-ColorMapped Visuals: TrueColor, DirectColor */
- /************************************************************************/
-
-- unsigned long r, g, b, rmask, gmask, bmask, xcol;
-- int rshift, gshift, bshift, bperpix, bperline, border, cshift;
-- int maplen;
-+ unsigned long xcol;
-+ int bperpix, bperline;
- byte *imagedata, *lip, *ip, *pp;
-
-
-- /* compute various shifting constants that we'll need... */
--
-- rmask = theVisual->red_mask;
-- gmask = theVisual->green_mask;
-- bmask = theVisual->blue_mask;
--
-- rshift = 7 - highbit(rmask);
-- gshift = 7 - highbit(gmask);
-- bshift = 7 - highbit(bmask);
--
-- maplen = theVisual->map_entries;
-- if (maplen>256) maplen=256;
-- cshift = 7 - highbit((u_long) (maplen-1));
--
- xim = XCreateImage(theDisp, theVisual, dispDEEP, ZPixmap, 0, NULL,
- wide, high, 32, 0);
- if (!xim) FatalError("couldn't create X image!");
-
- bperline = xim->bytes_per_line;
- bperpix = xim->bits_per_pixel;
-- border = xim->byte_order;
-
- imagedata = (byte *) malloc((size_t) (high * bperline));
- if (!imagedata) FatalError("couldn't malloc imagedata");
-@@ -1923,82 +2175,87 @@
- FatalError(buf);
- }
-
-+ screen_init();
-
-- lip = imagedata; pp = pic24;
-- for (i=0; i<high; i++, lip+=bperline) {
-- for (j=0, ip=lip; j<wide; j++) {
-- r = *pp++; g = *pp++; b = *pp++;
--
-- /* shift r,g,b so that high bit of 8-bit color specification is
-- * aligned with high bit of r,g,b-mask in visual,
-- * AND each component with its mask,
-- * and OR the three components together
-- */
--
-- if (theVisual->class == DirectColor) {
-- r = (u_long) directConv[(r>>cshift) & 0xff] << cshift;
-- g = (u_long) directConv[(g>>cshift) & 0xff] << cshift;
-- b = (u_long) directConv[(b>>cshift) & 0xff] << cshift;
-- }
--
--
-- /* shift the bits around */
-- if (rshift<0) r = r << (-rshift);
-- else r = r >> rshift;
--
-- if (gshift<0) g = g << (-gshift);
-- else g = g >> gshift;
--
-- if (bshift<0) b = b << (-bshift);
-- else b = b >> bshift;
--
-- r = r & rmask;
-- g = g & gmask;
-- b = b & bmask;
--
-- xcol = r | g | b;
--
-- if (bperpix == 32) {
-- if (border == MSBFirst) {
-- *ip++ = (xcol>>24) & 0xff;
-- *ip++ = (xcol>>16) & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = xcol & 0xff;
-- }
-- else { /* LSBFirst */
-- *ip++ = xcol & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = (xcol>>16) & 0xff;
-- *ip++ = (xcol>>24) & 0xff;
-- }
-- }
--
-- else if (bperpix == 24) {
-- if (border == MSBFirst) {
-- *ip++ = (xcol>>16) & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = xcol & 0xff;
-- }
-- else { /* LSBFirst */
-- *ip++ = xcol & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = (xcol>>16) & 0xff;
-+#ifdef DO_FIXPIX_SMOOTH
-+#if 0
-+ /* If we wouldn't have to save the original pic24 image data,
-+ * the following code would do the dither job by overwriting
-+ * the image data, and the normal render code would then work
-+ * without any change on that data.
-+ * Unfortunately, this approach would hurt the xv assumptions...
-+ */
-+ if (bperpix < 24) {
-+ FSBUF *fs = fs2_init(wide);
-+ if (fs) {
-+ fs2_dither(fs, pic24, 3, high, wide);
-+ free(fs);
-+ }
-+ }
-+#else
-+ /* ...so we have to take a different approach with linewise
-+ * dithering/rendering in a loop using a temporary line buffer.
-+ */
-+ if (bperpix < 24) {
-+ int alldone = 0;
-+ FSBUF *fs = fs2_init(wide);
-+ if (fs) {
-+ byte *row_buf = malloc((size_t)wide * 3);
-+ if (row_buf) {
-+ int nc = 3;
-+ byte *picp = pic24; lip = imagedata;
-+ for (i=0; i<high; i++, lip+=bperline, picp+=(size_t)wide*3) {
-+ memcpy(row_buf, picp, (size_t)wide * 3);
-+ nc = fs2_dither(fs, row_buf, nc, 1, wide);
-+ for (j=0, ip=lip, pp=row_buf; j<wide; j++) {
-+
-+ xcol = screen_rgb[0][*pp++];
-+ xcol |= screen_rgb[1][*pp++];
-+ xcol |= screen_rgb[2][*pp++];
-+
-+ switch (bperpix) {
-+ case 8:
-+ *ip++ = xcol & 0xff;
-+ break;
-+ case 16:
-+ *((CARD16 *)ip)++ = (CARD16)xcol;
-+ break;
-+ }
-+ }
- }
-+ alldone = 1;
-+ free(row_buf);
- }
-+ free(fs);
-+ }
-+ if (alldone) return xim;
-+ }
-+#endif
-+#endif
-
-- else if (bperpix == 16) {
-- if (border == MSBFirst) {
-- *ip++ = (xcol>>8) & 0xff;
-- *ip++ = xcol & 0xff;
-- }
-- else { /* LSBFirst */
-- *ip++ = xcol & 0xff;
-- *ip++ = (xcol>>8) & 0xff;
-- }
-- }
-+ lip = imagedata; pp = pic24;
-+ for (i=0; i<high; i++, lip+=bperline) {
-+ for (j=0, ip=lip; j<wide; j++) {
-
-- else if (bperpix == 8) {
-- *ip++ = xcol & 0xff;
-+ xcol = screen_rgb[0][*pp++];
-+ xcol |= screen_rgb[1][*pp++];
-+ xcol |= screen_rgb[2][*pp++];
-+
-+ switch (bperpix) {
-+ case 8:
-+ *ip++ = xcol & 0xff;
-+ break;
-+ case 16:
-+ *((CARD16 *)ip)++ = (CARD16)xcol;
-+ break;
-+ case 24:
-+ *ip++ = (xcol >> 16) & 0xff;
-+ *ip++ = (xcol >> 8) & 0xff;
-+ *ip++ = xcol & 0xff;
-+ break;
-+ case 32:
-+ *((CARD32 *)ip)++ = (CARD32)xcol;
-+ break;
- }
- }
- }
diff --git a/graphics/xv/patches/patch-af b/graphics/xv/patches/patch-af
index 4b407d7a75a..b78207a9b28 100644
--- a/graphics/xv/patches/patch-af
+++ b/graphics/xv/patches/patch-af
@@ -1,8 +1,8 @@
-$NetBSD: patch-af,v 1.4 2004/08/22 08:02:30 minskim Exp $
+$NetBSD: patch-af,v 1.5 2005/08/10 16:50:18 he Exp $
---- xv.h.orig Tue Jan 4 17:12:42 2000
-+++ xv.h Tue Jan 4 17:13:38 2000
-@@ -107,9 +107,7 @@
+--- xv.h.orig 2005-07-29 15:52:23.000000000 +0200
++++ xv.h
+@@ -137,9 +137,7 @@
#endif
@@ -13,24 +13,34 @@ $NetBSD: patch-af,v 1.4 2004/08/22 08:02:30 minskim Exp $
/* include files */
-@@ -128,7 +126,7 @@
+@@ -158,7 +156,7 @@
#ifndef VMS
# include <errno.h>
- extern int errno; /* SHOULD be in errno.h, but often isn't */
--# if !(defined(BSD) && (BSD >= 199103))
-+# if !(defined(BSD) && (BSD >= 199103)) && !defined(__linux__)
- extern char *sys_errlist[]; /* this too... */
- # endif
+ # ifndef __NetBSD__
+-# if !(defined __GLIBC__ && __GLIBC__ >= 2)
++# if !(defined(BSD) && (BSD >= 199103)) && !(defined __GLIBC__ && __GLIBC__ >= 2)
+ extern int errno; /* SHOULD be in errno.h, but often isn't */
+ extern char *sys_errlist[]; /* this too... */
+ # endif
+@@ -170,7 +168,7 @@
+ #ifdef VMS
+ # define ERRSTR(x) strerror(x, vaxc$errno)
+ #else
+-# if defined(__BEOS__) || defined(__linux__) /* or all modern/glibc systems? */
++# if defined(__BEOS__) || defined(__linux__) || defined(__INTERIX) /* or all modern/glibc systems? */
+ # define ERRSTR(x) strerror(x)
+ # else
+ # define ERRSTR(x) sys_errlist[x]
+@@ -345,7 +343,11 @@
#endif
-@@ -134,7 +134,11 @@
- /* not everyone has the strerror() function, or so I'm told */
- #ifndef VMS
-+#if defined(__INTERIX)
-+# define ERRSTR(x) strerror(x)
-+#else
- # define ERRSTR(x) sys_errlist[x]
-+#endif
- #else
- # define ERRSTR(x) strerror(x, vaxc$errno)
+ #ifndef S_IRWUSR
+-# define S_IRWUSR (S_IRUSR|__S_IWRITE)
++# ifdef __S_IWRITE
++# define S_IRWUSR (S_IRUSR|__S_IWRITE)
++# else
++# define S_IRWUSR (S_IRUSR|S_IWUSR)
++# endif
#endif
+
+ #ifndef MAXPATHLEN
diff --git a/graphics/xv/patches/patch-ag b/graphics/xv/patches/patch-ag
deleted file mode 100644
index 6c0bd5d1f08..00000000000
--- a/graphics/xv/patches/patch-ag
+++ /dev/null
@@ -1,975 +0,0 @@
-$NetBSD: patch-ag,v 1.3 2001/04/05 13:57:15 wiz Exp $
-
-The source in this patch is available at
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.c
-
----------------------------------------------------------------------------
-
---- /dev/null Sun Jun 13 01:55:42 1999
-+++ xvpng.c Fri Jun 14 01:42:11 1996
-@@ -0,0 +1,965 @@
-+/*
-+ * 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 <lehmann@mathematik.th-darmstadt.de>
-+ * this file is a suplement to xv and is supplied under the same copying
-+ * conditions (except the shareware part)
-+ * Modified by Andreas Dilger <adilger@enel.ucalgary.ca> 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
-+
-+/*** 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_struct *png_ptr, char *message));
-+static void png_xv_warning PARM((png_struct *png_ptr, char *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, 2.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; i<P_NBUTTS; i++) BTRedraw(&pbut[i]);
-+
-+ DrawString(pngW, 15, 6+ASCENT, title);
-+
-+ sprintf(ctitle1, "Default = %d", COMPRESSION);
-+ DrawString(pngW, 18, 6+DHIGH+cDial.y+ASCENT, ctitle1);
-+ DrawString(pngW, 17, 6+DHIGH+cDial.y+ASCENT+LINEHIGH, ctitle2);
-+ DrawString(pngW, 17, 6+DHIGH+cDial.y+ASCENT+2*LINEHIGH, ctitle3);
-+ DrawString(pngW, 17, 6+DHIGH+cDial.y+ASCENT+3*LINEHIGH, ctitle4);
-+
-+ sprintf(gtitle, "Default = %g", DISPLAY_GAMMA);
-+ DrawString(pngW, DWIDE+30, 6+DHIGH+gDial.y+ASCENT, gtitle);
-+
-+ ULineString(pngW, FdefCB.x, FdefCB.y-3-DESCENT, ftitle);
-+ XDrawRectangle(theDisp, pngW, theGC, FdefCB.x-11, FdefCB.y-LINEHIGH-3,
-+ 93, 8*LINEHIGH+15);
-+ CBRedraw(&FdefCB);
-+ XDrawLine(theDisp, pngW, theGC, FdefCB.x-11, FdefCB.y+LINEHIGH+4,
-+ FdefCB.x+82, FdefCB.y+LINEHIGH+4);
-+
-+ CBRedraw(&FnoneCB);
-+ CBRedraw(&FupCB);
-+ CBRedraw(&FsubCB);
-+ CBRedraw(&FavgCB);
-+ CBRedraw(&FPaethCB);
-+
-+ CBRedraw(&interCB);
-+
-+ XSetClipMask(theDisp, theGC, None);
-+}
-+
-+
-+/*******************************************/
-+static void clickPD(x,y)
-+ int x,y;
-+{
-+ int i;
-+ BUTT *bp;
-+
-+ /* check BUTTs */
-+
-+ for (i=0; i<P_NBUTTS; i++) {
-+ bp = &pbut[i];
-+ if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
-+ }
-+
-+ if (i<P_NBUTTS) { /* found one */
-+ if (BTTrack(bp)) doCmd(i);
-+ }
-+
-+ /* check CBUTTs */
-+
-+ else if (CBClick(&FdefCB,x,y)) {
-+ int oldval = FdefCB.val;
-+
-+ CBTrack(&FdefCB);
-+
-+ if (oldval != FdefCB.val)
-+ {
-+ CBSetActive(&FnoneCB, !FdefCB.val);
-+ CBSetActive(&FsubCB, !FdefCB.val);
-+ CBSetActive(&FupCB, !FdefCB.val);
-+ CBSetActive(&FavgCB, !FdefCB.val);
-+ CBSetActive(&FPaethCB, !FdefCB.val);
-+
-+ CBRedraw(&FnoneCB);
-+ CBRedraw(&FupCB);
-+ CBRedraw(&FsubCB);
-+ CBRedraw(&FavgCB);
-+ CBRedraw(&FPaethCB);
-+ }
-+ }
-+ else if (CBClick(&FnoneCB,x,y)) CBTrack(&FnoneCB);
-+ else if (CBClick(&FsubCB,x,y)) CBTrack(&FsubCB);
-+ else if (CBClick(&FupCB,x,y)) CBTrack(&FupCB);
-+ else if (CBClick(&FavgCB,x,y)) CBTrack(&FavgCB);
-+ else if (CBClick(&FPaethCB,x,y)) CBTrack(&FPaethCB);
-+ else if (CBClick(&interCB,x,y)) CBTrack(&interCB);
-+}
-+
-+
-+/*******************************************/
-+static void doCmd(cmd)
-+ int cmd;
-+{
-+ switch (cmd) {
-+ case P_BOK: {
-+ char *fullname;
-+
-+ writePNG();
-+ PNGDialog(0);
-+
-+ fullname = GetDirFullName();
-+ if (!ISPIPE(fullname[0])) {
-+ XVCreatedFile(fullname);
-+ StickInCtrlList(0);
-+ }
-+ }
-+ break;
-+
-+ case P_BCANC: PNGDialog(0); break;
-+
-+ default: break;
-+ }
-+}
-+
-+
-+/*******************************************/
-+static void writePNG()
-+{
-+ FILE *fp;
-+ int w, h, nc, rv, ptype, pfree;
-+ byte *inpix, *rmap, *gmap, *bmap;
-+
-+ fp = OpenOutFile(filename);
-+ if (!fp) return;
-+
-+ fbasename = BaseName(filename);
-+
-+ WaitCursor();
-+ inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
-+
-+ rv = WritePNG(fp, inpix, ptype, w, h, rmap, gmap, bmap, nc);
-+
-+ SetCursors(-1);
-+
-+ if (CloseOutFile(fp, filename, rv) == 0) DirBox(0);
-+
-+ if (pfree) free(inpix);
-+}
-+
-+
-+/*******************************************/
-+int WritePNG(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols)
-+ FILE *fp;
-+ byte *pic;
-+ int ptype, w, h;
-+ byte *rmap, *gmap, *bmap;
-+ int numcols;
-+{
-+ png_struct *png_ptr;
-+ png_info *info_ptr;
-+ png_color palette[256];
-+ png_textp text;
-+ byte remap[256];
-+ int i, filter, linesize = 0, pass;
-+ byte *p, *png_line;
-+ char software[256];
-+ char *savecmnt = NULL;
-+
-+ if ((png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
-+ png_xv_error, png_xv_warning)) == NULL) {
-+ FatalError("malloc failure in WritePNG");
-+ }
-+
-+ if ((info_ptr = png_create_info_struct(png_ptr)) == NULL)
-+ {
-+ png_destroy_write_struct(&png_ptr, &info_ptr);
-+ FatalError("malloc failure in WritePNG");
-+ }
-+
-+ if (setjmp(png_ptr->jmpbuf)) {
-+ 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++) {
-+ fflush(stdout);
-+ 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 /* rbg 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++;
-+ }
-+ }
-+ /* It is just a generic comment */
-+ else {
-+ tp->key = "Comment";
-+ tp->text = key;
-+ tp->text_length = strlen(tp->text);
-+ 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);
-+ png_destroy_write_struct(&png_ptr, &info_ptr);
-+
-+ if (text)
-+ {
-+ free(text);
-+ if (savecmnt)
-+ free(savecmnt);
-+ }
-+
-+ 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;
-+{
-+ 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;
-+{
-+ if (!png_ptr)
-+ return;
-+
-+ SetISTR(ISTR_WARNING,"%s: libpng warning: %s", fbasename, message);
-+}
-+
-+#endif
diff --git a/graphics/xv/patches/patch-ah b/graphics/xv/patches/patch-ah
index 90ac2fe357d..e2aac4e456f 100644
--- a/graphics/xv/patches/patch-ah
+++ b/graphics/xv/patches/patch-ah
@@ -1,14 +1,7 @@
-$NetBSD: patch-ah,v 1.1 2001/04/05 13:57:15 wiz Exp $
+$NetBSD: patch-ah,v 1.2 2005/08/10 16:50:18 he Exp $
-This patch is based on
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
-It was edited to fit into the NetBSD Packages Collection! - HF
-
----------------------------------------------------------------------------
-
-
---- Imakefile.orig Sun Jun 13 04:15:05 1999
-+++ Imakefile Sun Jun 13 04:31:20 1999
+--- Imakefile.orig 2005-07-29 15:28:09.000000000 +0200
++++ Imakefile
@@ -23,6 +23,9 @@
#define HavePDS
@@ -19,7 +12,7 @@ It was edited to fit into the NetBSD Packages Collection! - HF
/*
* if you are running on a SysV-based machine, such as HP, Silicon Graphics,
* etc, uncomment one of the following lines to get you *most* of the way
-@@ -149,6 +152,35 @@
+@@ -154,6 +157,34 @@ TIFFINCLUDE = -I$(LOCALBASE)/include
PDS = -DDOPDS
#endif
@@ -51,11 +44,10 @@ It was edited to fit into the NetBSD Packages Collection! - HF
+LIBZLIB = ${ZLIB}
+ZLIBINCLUDE = ${ZLIBINC}
+#endif
-+
+
#if defined(SCOArchitecture)
SCO= -Dsco -DPOSIX -DNO_RANDOM
- SYS_LIBRARIES= -lm -lc -lx
-@@ -157,14 +189,14 @@
+@@ -165,14 +196,14 @@ SYS_LIBRARIES= -lm
#endif
@@ -67,30 +59,10 @@ It was edited to fit into the NetBSD Packages Collection! - HF
DEFINES= $(SCO) $(UNIX) $(NODIRENT) $(VPRINTF) $(TIMERS) \
- $(HPUX7) $(JPEG) $(TIFF) $(PDS) $(DXWM) $(RAND) \
+ $(HPUX7) $(JPEG) $(TIFF) $(PNG) $(PDS) $(DXWM) $(RAND) \
- $(BACKING_STORE) $(BSDTYPES) $(SGI)
+ $(BACKING_STORE) $(BSDTYPES) $(SGI) $(MGCSFX)
-INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE)
+INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) $(PNGINCLUDE) $(ZLIBINCLUDE)
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 \
-@@ -172,7 +204,8 @@
- 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 xvmag.c xvmaki.c xvpic.c xvpi.c xvpic2.c xvpcd.c
-+ xvxwd.c xvfits.c xvmag.c xvmaki.c xvpic.c xvpi.c xvpic2.c xvpcd.c \
-+ xvpng.c
-
- OBJS1 = 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 \
-@@ -180,7 +213,8 @@
- 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 xvmag.o xvmaki.o xvpic.o xvpi.o xvpic2.o xvpcd.o
-+ xvxwd.o xvfits.o xvmag.o xvmaki.o xvpic.o xvpi.o xvpic2.o xvpcd.o \
-+ xvpng.o
-
- SRCS2= bggen.c
- OBJS2= bggen.o
diff --git a/graphics/xv/patches/patch-ai b/graphics/xv/patches/patch-ai
index 1f3686606ed..c8135669581 100644
--- a/graphics/xv/patches/patch-ai
+++ b/graphics/xv/patches/patch-ai
@@ -1,67 +1,22 @@
-$NetBSD: patch-ai,v 1.1 2001/04/05 13:57:16 wiz Exp $
+$NetBSD: patch-ai,v 1.2 2005/08/10 16:50:18 he Exp $
-This patch is based on
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
-It was edited to fit into the NetBSD Packages Collection! - HF
-
----------------------------------------------------------------------------
-
-
---- Makefile.patched Sun Jun 13 02:40:36 1999
-+++ Makefile Sun Jun 13 02:44:11 1999
-@@ -54,6 +54,24 @@
- $(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
+--- Makefile.orig 2005-07-29 15:30:40.000000000 +0200
++++ Makefile
+@@ -41,7 +41,7 @@ CLEANDIR = cleandir
+
+
+ ### Installation locations
+-PREFIX = /usr/local
++PREFIX = ${LOCALBASE}
+ BINDIR = $(PREFIX)/bin
+ MANDIR = $(PREFIX)/man/man1
+ MANSUF = 1
+@@ -89,7 +89,7 @@ JPEGLIB = -L$(JPEGDIR)/lib -ljpeg
+ ### on your machine, *COMMENT OUT* the following lines
+ ###
+ PNG = -DDOPNG
+-PNGDIR = /usr
+PNGDIR = ${LOCALBASE}
-+PNGINC = -I$(PNGDIR)/include
-+PNGLIB = -L$(PNGDIR)/lib -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
-+ZLIBINC = -I$(ZLIBDIR)/include
-+ZLIBLIB = -L$(ZLIBDIR)/lib -lz
-+
-
+ #PNGDIR = /usr/local
+ #PNGDIR = ../../libpng
###
- ### if, for whatever reason, you're unable to get the TIFF library to compile
-@@ -188,9 +206,9 @@
-
- CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
- $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
-- $(DXWM) $(MCHN)
-+ $(DXWM) $(MCHN) $(PNG) $(PNGINC) $(ZLIBINC)
-
--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 \
-@@ -198,7 +216,8 @@
- 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 xvmag.o xvmaki.o xvpic.o xvpi.o xvpic2.o xcpcd.o
-+ xvxwd.o xvfits.o xvmag.o xvmaki.o xvpic.o xvpi.o xvpic2.o xcpcd.o \
-+ xvpng.o
-
- MISC = README INSTALL CHANGELOG IDEAS
-
-@@ -269,7 +288,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 --git a/graphics/xv/patches/patch-aj b/graphics/xv/patches/patch-aj
index a7b965011ae..38fe3742a71 100644
--- a/graphics/xv/patches/patch-aj
+++ b/graphics/xv/patches/patch-aj
@@ -1,68 +1,22 @@
-$NetBSD: patch-aj,v 1.1 2001/04/05 13:57:16 wiz Exp $
+$NetBSD: patch-aj,v 1.2 2005/08/10 16:50:18 he Exp $
-This patch is based on
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
-It was edited to fit into the NetBSD Packages Collection! - HF
-
----------------------------------------------------------------------------
-
-
---- Makefile.std.patched Sun Jun 13 03:16:57 1999
-+++ Makefile.std Sun Jun 13 03:21:41 1999
-@@ -56,6 +56,25 @@
-
-
+--- Makefile.std.orig 2005-07-29 15:33:26.000000000 +0200
++++ Makefile.std
+@@ -41,7 +41,7 @@ CLEANDIR = cleandir
+
+
+ ### Installation locations
+-PREFIX = /usr/local
++PREFIX = ${LOCALBASE}
+ BINDIR = $(PREFIX)/bin
+ MANDIR = $(PREFIX)/man/man1
+ MANSUF = 1
+@@ -89,7 +89,7 @@ JPEGLIB = -L$(JPEGDIR)/lib -ljpeg
+ ### on your machine, *COMMENT OUT* the following lines
###
-+### if, for whatever reason, you're unable to get the PNG library to compile
-+### on your machine, *COMMENT OUT* the following lines
-+###
-+PNG = -DDOPNG
+ PNG = -DDOPNG
+-PNGDIR = /usr
+PNGDIR = ${LOCALBASE}
-+PNGINC = -I$(PNGDIR)/include
-+PNGLIB = -L$(PNGDIR)/lib -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
-+ZLIBINC = -I$(ZLIBDIR)/include
-+ZLIBLIB = -L$(ZLIBDIR)/lib -lz
-+
-+
-+###
- ### if, for whatever reason, you're unable to get the TIFF library to compile
- ### on your machine, *COMMENT OUT* the following lines
+ #PNGDIR = /usr/local
+ #PNGDIR = ../../libpng
###
-@@ -188,9 +207,9 @@
-
- CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
- $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
-- $(DXWM) $(MCHN)
-+ $(DXWM) $(MCHN) $(PNG) $(PNGINC) $(ZLIBINC)
-
--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 \
-@@ -198,7 +217,8 @@
- 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 xvmag.o xvmaki.o xvpic.o xvpi.o xvpic2.o xcpcd.o
-+ xvxwd.o xvfits.o xvmag.o xvmaki.o xvpic.o xvpi.o xvpic2.o xcpcd.o \
-+ xvpng.o
-
- MISC = README INSTALL CHANGELOG IDEAS
-
-@@ -269,7 +289,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 --git a/graphics/xv/patches/patch-ak b/graphics/xv/patches/patch-ak
deleted file mode 100644
index cbdb7dc0e21..00000000000
--- a/graphics/xv/patches/patch-ak
+++ /dev/null
@@ -1,62 +0,0 @@
-$NetBSD: patch-ak,v 1.2 2002/10/06 16:26:57 he Exp $
-
-This patch is based on
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
-It was edited to fit into the NetBSD Packages Collection! - HF
-
-It is also modified by
-ftp://ftp.trilon.com/pub/xv/patches/mp-tiff-patch
-
----------------------------------------------------------------------------
-
-
---- xv.c.orig Fri Aug 9 17:09:06 2002
-+++ xv.c
-@@ -279,6 +279,10 @@
-
- pcdW = (Window) NULL; pcdUp = 0;
-
-+#ifdef HAVE_PNG
-+ pngW = (Window) NULL; pngUp = 0;
-+#endif
-+
- imap = ctrlmap = gmap = browmap = cmtmap = 0;
-
- ch_offx = ch_offy = p_offx = p_offy = 0;
-@@ -786,6 +790,11 @@
-
- CreatePCDW();
- XSetTransientForHint(theDisp, pcdW, dirW);
-+
-+#ifdef HAVE_PNG
-+ CreatePNGW();
-+ XSetTransientForHint(theDisp, pngW, dirW);
-+#endif
-
- LoadFishCursors();
- SetCursors(-1);
-@@ -2649,6 +2658,11 @@
- (magicno[0]=='I' && magicno[1]=='I')) rv = RFT_TIFF;
- #endif
-
-+#ifdef HAVE_PNG
-+ else if (magicno[0]==0x89 && magicno[1]=='P' &&
-+ magicno[2]=='N' && magicno[3]=='G') rv = RFT_PNG;
-+#endif
-+
- #ifdef HAVE_PDS
- else if (strncmp((char *) magicno, "NJPL1I00", (size_t) 8)==0 ||
- strncmp((char *) magicno+2,"NJPL1I", (size_t) 6)==0 ||
-@@ -2739,7 +2753,11 @@
- #endif
-
- #ifdef HAVE_TIFF
-- case RFT_TIFF: rv = LoadTIFF (fname, pinfo); break;
-+ case RFT_TIFF: rv = LoadTIFF (fname, pinfo, quick); break;
-+#endif
-+
-+#ifdef HAVE_PNG
-+ case RFT_PNG: rv = LoadPNG (fname, pinfo); break;
- #endif
-
- #ifdef HAVE_PDS
diff --git a/graphics/xv/patches/patch-al b/graphics/xv/patches/patch-al
deleted file mode 100644
index 28d8190fa70..00000000000
--- a/graphics/xv/patches/patch-al
+++ /dev/null
@@ -1,179 +0,0 @@
-$NetBSD: patch-al,v 1.2 2002/10/06 16:26:57 he Exp $
-
-This patch is based on
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
-It was edited to fit into the NetBSD Packages Collection! - HF
-
-It is also modified by
-ftp://ftp.trilon.com/pub/xv/patches/mp-tiff-patch
-
----------------------------------------------------------------------------
-
-
---- xv.h.orig Fri Aug 9 17:09:14 2002
-+++ xv.h
-@@ -8,8 +8,8 @@
- #include "config.h"
-
-
--#define REVDATE "Version 3.10a Rev: 12/29/94"
--#define VERSTR "3.10a"
-+#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
-@@ -343,6 +343,10 @@
- #define HAVE_TIFF
- #endif
-
-+#ifdef DOPNG
-+#define HAVE_PNG
-+#endif
-+
- #ifdef DOPDS
- #define HAVE_PDS
- #endif
-@@ -478,31 +482,38 @@
- #define MACBSIZE 128
- #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_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_MAG (12 + F_JPGINC + F_TIFINC)
--#define F_PIC (13 + F_JPGINC + F_TIFINC)
--#define F_MAKI (14 + F_JPGINC + F_TIFINC)
--#define F_PI (15 + F_JPGINC + F_TIFINC)
--#define F_PIC2_SS (16 + F_JPGINC + F_TIFINC)
--#define F_PIC2_SF (17 + F_JPGINC + F_TIFINC)
--#define F_PIC2_BM (18 + F_JPGINC + F_TIFINC)
--#define F_PIC2_BI (19 + F_JPGINC + F_TIFINC) /* ----- */
--#define F_DELIM1 (20 + F_JPGINC + F_TIFINC)
--#define F_FILELIST (21 + F_JPGINC + F_TIFINC)
--#define F_MAXFMTS (22 + F_JPGINC + F_TIFINC) /* 16, normally */
-+#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_MAG (12 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PIC (13 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_MAKI (14 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PI (15 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PIC2_SS (16 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PIC2_SF (17 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PIC2_BM (18 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_PIC2_BI (19 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_DELIM1 (20 + F_JPGINC + F_TIFINC + F_PNGINC) /* ----- */
-+#define F_FILELIST (21 + F_JPGINC + F_TIFINC + F_PNGINC)
-+#define F_MAXFMTS (22 + F_JPGINC + F_TIFINC + F_PNGINC) /* 25, normally */
-
-
-
-@@ -538,6 +549,7 @@
- #define RFT_PI 23
- #define RFT_PIC2 24
- #define RFT_PCD 25
-+#define RFT_PNG 26 /* HF: was 20 */
-
- /* definitions for page up/down, arrow up/down list control */
- #define LS_PAGEUP 0
-@@ -798,9 +810,10 @@
- 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 */
-+ 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 */
-@@ -1192,6 +1205,13 @@
- WHERE Window pcdW;
- WHERE int pcdUp; /* is pcdW mapped, or what? */
-
-+#ifdef HAVE_PNG
-+/* stuff used for 'png' box */
-+WHERE Window pngW;
-+WHERE int pngUp; /* is pngW mapped, or what? */
-+#endif
-+
-+
- #undef WHERE
-
-
-@@ -1289,6 +1309,7 @@
- void xv_getwd PARM((char *, size_t));
- char *xv_strstr PARM((char *, char *));
- FILE *xv_fopen PARM((char *, char *));
-+void xv_mktemp PARM((char *, char *));
- void Timer PARM((int));
-
- /*************************** XVCOLOR.C ***************************/
-@@ -1506,12 +1527,12 @@
-
-
- /*************************** 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 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 *, int, int, int, int));
--void DSetVal PARM((DIAL *, int));
-+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));
-@@ -1648,11 +1669,18 @@
- void JPEGSaveParams PARM((char *, int));
-
- /**************************** XVTIFF.C ***************************/
--int LoadTIFF PARM((char *, PICINFO *));
-+int LoadTIFF PARM((char *, PICINFO *, int));
- void CreateTIFFW PARM((void));
- 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 --git a/graphics/xv/patches/patch-am b/graphics/xv/patches/patch-am
deleted file mode 100644
index 11eab1f68d4..00000000000
--- a/graphics/xv/patches/patch-am
+++ /dev/null
@@ -1,63 +0,0 @@
-$NetBSD: patch-am,v 1.2 2004/03/29 00:50:41 dillo Exp $
-
-This patch is based on
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
-It was edited to fit into the NetBSD Packages Collection! - HF
-
-It is also based on
-ftp://ftp.trilon.com/pub/xv/patches/longname.patch
----------------------------------------------------------------------------
-
-
---- xvbrowse.c.orig Sun Mar 21 21:27:18 2004
-+++ xvbrowse.c
-@@ -61,6 +61,7 @@ typedef unsigned int mode_t; /* file mo
- #include "bits/br_pic"
- #include "bits/br_pi"
- #include "bits/br_pic2"
-+#include "bits/br_png"
-
- #include "bits/br_trash"
- #include "bits/fcurs"
-@@ -106,7 +107,8 @@ typedef unsigned int mode_t; /* file mo
- #define BF_PI 31
- #define BF_PIC2 32
- #define BF_PCD 33
--#define BF_MAX 34 /* # of built-in icons */
-+#define BF_PNG 34
-+#define BF_MAX 35 /* # of built-in icons */
-
- #define ISLOADABLE(ftyp) (ftyp!=BF_DIR && ftyp!=BF_CHR && ftyp!=BF_BLK && \
- ftyp!=BF_SOCK && ftyp!=BF_FIFO)
-@@ -543,6 +545,7 @@ void CreateBrowse(geom, fgstr, bgstr, hi
- bfIcons[BF_PI] = MakePix1(br->win,br_pi_bits,br_pi_width,br_pi_height);
- bfIcons[BF_PIC2]=MakePix1(br->win,br_pic2_bits,br_pic2_width,br_pic2_height);
- bfIcons[BF_PCD] = MakePix1(br->win,br_pcd_bits,br_pcd_width,br_pcd_height);
-+ bfIcons[BF_PNG]=MakePix1(br->win,br_png_bits,br_png_width,br_png_height);
-
-
- /* check that they all got built */
-@@ -1509,6 +1512,7 @@ static void drawIcon(br, num)
- if (StringWidth(str) > ISPACE_WIDE-6) {
- int dotpos;
- strncpy(tmpstr, str, (size_t) 56);
-+ tmpstr[56] = '\0';
- dotpos = strlen(tmpstr);
- strcat(tmpstr,"...");
-
-@@ -3045,6 +3049,7 @@ static void scanFile(br, bf, name)
- case RFT_PI: bf->ftype = BF_PI; break;
- case RFT_PIC2: bf->ftype = BF_PIC2; break;
- case RFT_PCD: bf->ftype = BF_PCD; break;
-+ case RFT_PNG: bf->ftype = BF_PNG; break;
- }
- }
- }
-@@ -3612,6 +3617,7 @@ static void genIcon(br, bf)
- case RFT_PI: strcat(str,"PI file"); break;
- case RFT_PIC2: strcat(str,"PIC2 file"); break;
- case RFT_PCD: strcat(str,"PhotoCD file"); break;
-+ case RFT_PNG: strcat(str,"PNG file"); break;
- default: strcat(str,"file of unknown type"); break;
- }
-
diff --git a/graphics/xv/patches/patch-an b/graphics/xv/patches/patch-an
deleted file mode 100644
index 6e063168696..00000000000
--- a/graphics/xv/patches/patch-an
+++ /dev/null
@@ -1,233 +0,0 @@
-$NetBSD: patch-an,v 1.1 2001/04/05 13:57:16 wiz Exp $
-
---- xvdial.c.orig Tue Jan 3 22:20:31 1995
-+++ xvdial.c Sun Nov 14 14:05:49 1999
-@@ -45,16 +45,17 @@
- 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 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)
-+void DSetRange(dp, minv, maxv, curv, inc, page)
- DIAL *dp;
--int minv, maxv, curv, page;
-+double minv, maxv, curv, inc, page;
- {
- if (maxv<minv) maxv=minv;
-- dp->min = 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);
-@@ -119,7 +120,7 @@
- /***************************************************/
- void DSetVal(dp, curv)
- DIAL *dp;
--int curv;
-+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 --git a/graphics/xv/patches/patch-ao b/graphics/xv/patches/patch-ao
deleted file mode 100644
index de9aed5b99a..00000000000
--- a/graphics/xv/patches/patch-ao
+++ /dev/null
@@ -1,86 +0,0 @@
-$NetBSD: patch-ao,v 1.2 2004/03/29 00:50:41 dillo Exp $
-
-This patch is based on
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
-It was edited to fit into the NetBSD Packages Collection! - HF
-
-It is also based on
-ftp://ftp.trilon.com/pub/xv/patches/longname.patch
-
----------------------------------------------------------------------------
-
-
---- xvdir.c.orig Sun Mar 21 21:18:09 2004
-+++ xvdir.c
-@@ -62,6 +62,9 @@ static char *saveFormats[] = { "GIF",
- #ifdef HAVE_TIFF
- "TIFF",
- #endif
-+#ifdef HAVE_PNG
-+ "PNG",
-+#endif
- "PostScript",
- "PBM/PGM/PPM (raw)",
- "PBM/PGM/PPM (ascii)",
-@@ -1123,6 +1126,14 @@ int DoSave()
- }
- #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
-
-
-
-@@ -1181,6 +1192,7 @@ int DoSave()
- case F_FITS:
- rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
- picComments);
-+ break;
- case F_MAG:
- rv = WriteMAG (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
- picComments); break;
-@@ -1416,19 +1428,26 @@ static void changeSuffix()
- (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) ||
- (strcmp(lowsuf,"pi" )==0) ||
-- (strcmp(lowsuf,"p2" )==0)){
-+ (strcmp(lowsuf,"p2" )==0)) {
-
- /* found one. set lowsuf = to the new suffix, and tack on to filename */
-
-@@ -1463,6 +1482,9 @@ static void changeSuffix()
-
- #ifdef HAVE_TIFF
- case F_TIFF: strcpy(lowsuf,"tif"); break;
-+#endif
-+#ifdef HAVE_PNG
-+ case F_PNG: strcpy(lowsuf,"png"); break;
- #endif
- case F_MAG: strcpy(lowsuf,"mag"); break;
- case F_PIC: strcpy(lowsuf,"pic"); break;
diff --git a/graphics/xv/patches/patch-ap b/graphics/xv/patches/patch-ap
deleted file mode 100644
index 523cd909dc7..00000000000
--- a/graphics/xv/patches/patch-ap
+++ /dev/null
@@ -1,97 +0,0 @@
-$NetBSD: patch-ap,v 1.1 2001/04/05 13:57:17 wiz Exp $
-
-This patch is based on
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
-It was edited to fit into the NetBSD Packages Collection! - HF
-
----------------------------------------------------------------------------
-
-
---- xvevent.c.patched Sun Jun 13 03:34:03 1999
-+++ xvevent.c Sun Jun 13 03:37:59 1999
-@@ -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 wasPcdUp=0;
-
- static int mainWKludge=0; /* force first mainW expose after a mainW config
-@@ -234,6 +234,10 @@
- if (TIFFCheckEvent(event)) break; /* event has been processed */
- #endif
-
-+#ifdef HAVE_PNG
-+ if (PNGCheckEvent (event)) break; /* event has been processed */
-+#endif
-+
- if (PCDCheckEvent(event)) break; /* event has been processed */
-
- if (GamCheckEvent (event)) break; /* event has been processed */
-@@ -362,6 +366,10 @@
- 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 == pcdW) PCDDialog(0);
-
- else if (client_event->window == mainW) Quit(0);
-@@ -544,6 +552,10 @@
- if (wasTiffUp) { TIFFDialog(wasTiffUp); wasTiffUp=0; }
- #endif
-
-+#ifdef HAVE_PNG
-+ if (wasPngUp) { PNGDialog(wasJpegUp); wasPngUp=0; }
-+#endif
-+
- if (wasPcdUp) { PCDDialog(wasPcdUp); wasPcdUp=0; }
-
- }
-@@ -585,6 +597,10 @@
- if (tiffUp) { wasTiffUp = tiffUp; TIFFDialog(0); }
- #endif
-
-+#ifdef HAVE_PNG
-+ if (pngUp) { wasPngUp = pngUp; PNGDialog(0); }
-+#endif
-+
- if (pcdUp) { wasPcdUp = pcdUp; PCDDialog(0); }
-
- }
-@@ -1158,6 +1174,10 @@
- if (TIFFCheckEvent(event)) break;
- #endif
-
-+#ifdef HAVE_PNG
-+ if (PNGCheckEvent (event)) break;
-+#endif
-+
- if (PCDCheckEvent(event)) break;
-
- if (GamCheckEvent (event)) break;
-@@ -1379,6 +1399,10 @@
- if (TIFFCheckEvent(event)) break;
- #endif
-
-+#ifdef HAVE_PNG
-+ if (PNGCheckEvent (event)) break;
-+#endif
-+
- if (PCDCheckEvent(event)) break;
-
- if (GamCheckEvent (event)) break;
-@@ -2385,6 +2409,10 @@
-
- #ifdef HAVE_TIFF
- if (tiffUp) TIFFDialog(0); /* close tiff window */
-+#endif
-+
-+#ifdef HAVE_PNG
-+ if (pngUp) PNGDialog(0); /* close png window */
- #endif
-
- if (pcdUp) PCDDialog(0); /* close pcd window */
diff --git a/graphics/xv/patches/patch-aq b/graphics/xv/patches/patch-aq
deleted file mode 100644
index 2be8d04fb63..00000000000
--- a/graphics/xv/patches/patch-aq
+++ /dev/null
@@ -1,152 +0,0 @@
-$NetBSD: patch-aq,v 1.1 2001/04/05 13:57:17 wiz Exp $
-
---- xvgam.c.orig Fri Jan 13 20:51:14 1995
-+++ xvgam.c Sun Nov 14 14:05:49 1999
-@@ -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 --git a/graphics/xv/patches/patch-ar b/graphics/xv/patches/patch-ar
deleted file mode 100644
index e6fabf7f0c5..00000000000
--- a/graphics/xv/patches/patch-ar
+++ /dev/null
@@ -1,37 +0,0 @@
-$NetBSD: patch-ar,v 1.1 2001/04/05 13:57:17 wiz Exp $
-
---- xvjpeg.c.orig Sun Nov 14 14:05:46 1999
-+++ xvjpeg.c Sun Nov 14 14:05:49 1999
-@@ -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,
-@@ -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 --git a/graphics/xv/patches/patch-as b/graphics/xv/patches/patch-as
deleted file mode 100644
index bb57067a215..00000000000
--- a/graphics/xv/patches/patch-as
+++ /dev/null
@@ -1,52 +0,0 @@
-$NetBSD: patch-as,v 1.2 2002/10/06 16:26:57 he Exp $
-
---- xvmisc.c.orig Fri Aug 9 17:09:23 2002
-+++ xvmisc.c
-@@ -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)
- */
-
-@@ -522,6 +524,10 @@
-
- if (pcdW) XDestroyWindow(theDisp, pcdW);
-
-+#ifdef HAVE_PNG
-+ if (pngW) XDestroyWindow(theDisp, pngW);
-+#endif
-+
- /* if NOT using stdcmap for images, free stdcmap */
- if (colorMapMode != CM_STDCMAP) {
- int j;
-@@ -718,6 +724,10 @@
- #ifdef HAVE_TIFF
- if (tiffW) XDefineCursor(theDisp, tiffW, otherc);
- #endif
-+
-+#ifdef HAVE_PNG
-+ if (pngW) XDefineCursor(theDisp, pngW, otherc);
-+#endif
-
- if (pcdW) XDefineCursor(theDisp, pcdW, otherc);
- }
-@@ -1070,6 +1080,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 --git a/graphics/xv/patches/patch-at b/graphics/xv/patches/patch-at
deleted file mode 100644
index 5c9c2c07220..00000000000
--- a/graphics/xv/patches/patch-at
+++ /dev/null
@@ -1,90 +0,0 @@
-$NetBSD: patch-at,v 1.2 2004/03/29 00:50:41 dillo Exp $
-
-This patch is partially based on
-ftp://ftp.trilon.com/pub/xv/patches/longname.patch
-
------------------------
-
-
---- xvpopup.c.orig Sun Mar 21 21:18:09 2004
-+++ xvpopup.c
-@@ -200,14 +200,14 @@ static int doPopUp(txt, labels, n, popty
-
- 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 @@ static int doPopUp(txt, labels, n, popty
- 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 @@ int PadPopUp(pMode, pStr, pWide,pHigh, p
- 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 @@ int PadPopUp(pMode, pStr, pWide,pHigh, p
- }
-
- 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 @@ int PadPopUp(pMode, pStr, pWide,pHigh, p
- /* 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;
-@@ -973,8 +973,8 @@ static void clickPUD(x,y)
- 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 --git a/graphics/xv/patches/patch-au b/graphics/xv/patches/patch-au
deleted file mode 100644
index 9fcad862eca..00000000000
--- a/graphics/xv/patches/patch-au
+++ /dev/null
@@ -1,39 +0,0 @@
-$NetBSD: patch-au,v 1.1 2001/04/05 13:57:18 wiz Exp $
-
---- xvps.c.orig Thu Dec 22 23:34:42 1994
-+++ xvps.c Sun Nov 14 14:05:49 1999
-@@ -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 --git a/graphics/xv/patches/patch-av b/graphics/xv/patches/patch-av
deleted file mode 100644
index 33e75459613..00000000000
--- a/graphics/xv/patches/patch-av
+++ /dev/null
@@ -1,39 +0,0 @@
-$NetBSD: patch-av,v 1.1 2001/04/05 13:57:18 wiz Exp $
-
-The source for this file can be found at
-http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/bits/br_png
-
-- HF
-
-
---- /dev/null Sun Jun 13 02:17:04 1999
-+++ bits/br_png Thu Jun 13 22: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 --git a/graphics/xv/patches/patch-aw b/graphics/xv/patches/patch-aw
deleted file mode 100644
index bba52f7a553..00000000000
--- a/graphics/xv/patches/patch-aw
+++ /dev/null
@@ -1,45 +0,0 @@
-$NetBSD: patch-aw,v 1.2 2002/08/09 18:06:36 drochner Exp $
-
---- xv.c.orig Fri Aug 9 19:14:10 2002
-+++ xv.c Fri Aug 9 19:51:18 2002
-@@ -1872,11 +1872,13 @@
- if (filenum == LOADPIC) {
- fullname = GetDirFullName();
-
-+#ifdef BROKEN_PIPE_HANDLING_FROM_DIRECTORY_BOX
- if (ISPIPE(fullname[0])) { /* read from a pipe. */
- strcpy(filename, fullname);
- if (readpipe(fullname, filename)) goto FAILED;
- frompipe = 1;
- }
-+#endif
- }
- else fullname = namelist[filenum];
-
-@@ -1902,6 +1904,7 @@
- }
-
-
-+#ifdef BROKEN_PIPE_HANDLING_FROM_DIRECTORY_BOX
- if (filenum == LOADPIC && ISPIPE(fullname[0])) {
- /* if we're reading from a pipe, 'filename' will have the /tmp/xvXXXXXX
- filename, and we can skip a lot of stuff: (such as prepending
-@@ -1913,6 +1916,9 @@
- }
-
- else { /* NOT reading from a PIPE */
-+#else
-+ {
-+#endif
-
- /* if fullname doesn't start with a '/' (ie, it's a relative path),
- (and it's not LOADPIC and it's not the special case '<stdin>')
-@@ -2233,7 +2239,7 @@
- SetISTR(ISTR_INFO,formatStr);
-
- SetInfoMode(INF_PART);
-- SetISTR(ISTR_FILENAME,
-+ SetISTR(ISTR_FILENAME, "%s",
- (filenum==DFLTPIC || filenum==GRABBED || frompipe)
- ? "<none>" : basefname);
-
diff --git a/graphics/xv/patches/patch-ax b/graphics/xv/patches/patch-ax
deleted file mode 100644
index 715d2e541b1..00000000000
--- a/graphics/xv/patches/patch-ax
+++ /dev/null
@@ -1,395 +0,0 @@
-$NetBSD: patch-ax,v 1.1 2002/10/06 16:26:57 he Exp $
-
-This patch is partly based on
- ftp://ftp.trilon.com/pub/xv/patches/mp-tiff-patch
-as found on
- http://www.trilon.com/xv/downloads.html#patches
-It was edited to fit into the NetBSD Packages Collection! - HE
-
-------------------------------------------------------------
-
-
---- xvtiff.c.orig Fri Aug 9 17:22:16 2002
-+++ xvtiff.c
-@@ -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... */
-+
-+ 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");
-+
-+ 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);
-@@ -1018,7 +1258,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); \
-@@ -1030,7 +1270,7 @@
- }
-
- #define UNROLL4(w, op1, op2) { \
-- register uint32 x; \
-+ uint32 x; \
- for (x = w; x >= 4; x -= 4) { \
- op1; \
- REPEAT4(op2); \
-@@ -1042,7 +1282,7 @@
- }
-
- #define UNROLL2(w, op1, op2) { \
-- register uint32 x; \
-+ uint32 x; \
- for (x = w; x >= 2; x -= 2) { \
- op1; \
- REPEAT2(op2); \
-@@ -1384,7 +1624,7 @@
- }
- }
-
--#define Code2V(c, RB, RW, CR) ((((c)-(int)RB)*(float)CR)/(float)(RW-RB))
-+#define Code2V(c, RB, RW, CR) (((((int)c)-(int)RB)*(float)CR)/(float)(RW-RB))
-
- #define CLAMP(f,min,max) \
- (int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5)
diff --git a/graphics/xv/patches/patch-ay b/graphics/xv/patches/patch-ay
deleted file mode 100644
index 71892e60565..00000000000
--- a/graphics/xv/patches/patch-ay
+++ /dev/null
@@ -1,18 +0,0 @@
-$NetBSD: patch-ay,v 1.1 2004/03/29 00:50:41 dillo Exp $
-
-This patch is based on
-ftp://ftp.trilon.com/pub/xv/patches/longname.patch
-
---------------------------
-
-
---- xvtext.c.orig Sat Jan 14 00:46:28 1995
-+++ xvtext.c
-@@ -293,6 +293,7 @@ void OpenTextView(text, len, title, free
- 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 */
-