pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/graphics/xv
Module Name: pkgsrc
Committed By: tsutsui
Date: Sun Jul 30 07:55:45 UTC 2023
Modified Files:
pkgsrc/graphics/xv: Makefile distinfo
pkgsrc/graphics/xv/patches: patch-Imakefile patch-xv.h
Added Files:
pkgsrc/graphics/xv/patches: patch-bits_br__webp patch-xv.c
patch-xvbrowse.c patch-xvdir.c patch-xvevent.c patch-xvmisc.c
patch-xvwebp.c
Log Message:
xv: add webp support.
Taken from https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
and several fixes by me (see patch comments for details).
Bump PKGREVISION.
To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 pkgsrc/graphics/xv/Makefile
cvs rdiff -u -r1.25 -r1.26 pkgsrc/graphics/xv/distinfo
cvs rdiff -u -r1.1 -r1.2 pkgsrc/graphics/xv/patches/patch-Imakefile \
pkgsrc/graphics/xv/patches/patch-xv.h
cvs rdiff -u -r0 -r1.1 pkgsrc/graphics/xv/patches/patch-bits_br__webp \
pkgsrc/graphics/xv/patches/patch-xv.c \
pkgsrc/graphics/xv/patches/patch-xvbrowse.c \
pkgsrc/graphics/xv/patches/patch-xvdir.c \
pkgsrc/graphics/xv/patches/patch-xvevent.c \
pkgsrc/graphics/xv/patches/patch-xvmisc.c \
pkgsrc/graphics/xv/patches/patch-xvwebp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/graphics/xv/Makefile
diff -u pkgsrc/graphics/xv/Makefile:1.96 pkgsrc/graphics/xv/Makefile:1.97
--- pkgsrc/graphics/xv/Makefile:1.96 Tue Jan 3 17:37:33 2023
+++ pkgsrc/graphics/xv/Makefile Sun Jul 30 07:55:44 2023
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.96 2023/01/03 17:37:33 wiz Exp $
+# $NetBSD: Makefile,v 1.97 2023/07/30 07:55:44 tsutsui Exp $
DISTNAME= xv-3.10a
-PKGREVISION= 26
+PKGREVISION= 27
CATEGORIES= graphics x11
MASTER_SITES= ftp://ftp.cis.upenn.edu/pub/xv/
DISTFILES= ${DEFAULT_DISTFILES} ${JUMBO_PATCHES}
@@ -64,6 +64,7 @@ post-install:
BUILDLINK_DEPMETHOD.libXt?= build
+.include "../../graphics/libwebp/buildlink3.mk"
.include "../../graphics/png/buildlink3.mk"
.include "../../graphics/tiff/buildlink3.mk"
.include "../../x11/libXext/buildlink3.mk"
Index: pkgsrc/graphics/xv/distinfo
diff -u pkgsrc/graphics/xv/distinfo:1.25 pkgsrc/graphics/xv/distinfo:1.26
--- pkgsrc/graphics/xv/distinfo:1.25 Tue Oct 26 10:47:25 2021
+++ pkgsrc/graphics/xv/distinfo Sun Jul 30 07:55:44 2023
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.25 2021/10/26 10:47:25 nia Exp $
+$NetBSD: distinfo,v 1.26 2023/07/30 07:55:44 tsutsui Exp $
BLAKE2s (xv-3.10a-enhancements.20070520-20081216.diff) = 1333e3066444f6adf64e83c33a129a46143678d4b2c805f3740baae1320d3449
SHA512 (xv-3.10a-enhancements.20070520-20081216.diff) = d7152799f6ec65404496b8d83a93681122fe1280741ffe4d20d7dc1b3791873081c778b3d9806f1217b9d45f5b5bfce6fdbfb655c26ed5e87388a6f517c4f2f7
@@ -9,10 +9,17 @@ Size (xv-3.10a-jumbo-patches-20070520.ta
BLAKE2s (xv-3.10a.tar.gz) = 1a48a6b641074c1fc1c51a01d6516024489ed0fab550abdd708f7d12aef8d292
SHA512 (xv-3.10a.tar.gz) = 5b8c5890503e2796638921cabae8967e458c73e332acea8561b1025ed13c771bc44c0e309b4592852e33726eeaa9784f933d1312073b0ba2e0b8c0cedabcaa3f
Size (xv-3.10a.tar.gz) = 2259124 bytes
-SHA1 (patch-Imakefile) = e27d7d2f110d4edbce9a5d236e45a556714b5be0
+SHA1 (patch-Imakefile) = ea44bbda2a848a81fceac78d2f581269a053fb7f
+SHA1 (patch-bits_br__webp) = 47f2495f0e8d443e0e20b718593de331cf319dea
SHA1 (patch-config.h) = fd0ef6bbf774a57dd0bb94676927dcc6eeef1014
SHA1 (patch-vdcomp.c) = 4c603cdc2c01925fed283b2aa6030d1933cdaddc
-SHA1 (patch-xv.h) = 894c5a9d4e1cb5fb18a9914c75408b67f1e6e5d4
+SHA1 (patch-xv.c) = 6f42b3cfa60fc724b9022b61794201252161e60a
+SHA1 (patch-xv.h) = abe4ae7018bc62b983274c47c31741f0474d48ac
+SHA1 (patch-xvbrowse.c) = f15e6e8e4db2776f072f34355ecad7844a764c2a
+SHA1 (patch-xvdir.c) = 070714b588bc28f5d6e8974a88c960c6ab9df94f
+SHA1 (patch-xvevent.c) = bfb7fd815b8ff86f68c09098c74ab0adc8a36a32
SHA1 (patch-xvinfo.c) = 33b2392de259f1380e5be180f8e7293a9551fc52
+SHA1 (patch-xvmisc.c) = ad326175632736e2d6dd257972d8cba5b24635a3
SHA1 (patch-xvpcd.c) = 1825015f441b9af91916f9a62e8d1dee6ddfdef9
SHA1 (patch-xvpng.c) = 2bda08bae67fcf127c49b9ed780b7a247579c088
+SHA1 (patch-xvwebp.c) = ad2a1a87176ab099c8d3f51bf5d20e2bbe2faf2a
Index: pkgsrc/graphics/xv/patches/patch-Imakefile
diff -u pkgsrc/graphics/xv/patches/patch-Imakefile:1.1 pkgsrc/graphics/xv/patches/patch-Imakefile:1.2
--- pkgsrc/graphics/xv/patches/patch-Imakefile:1.1 Thu Feb 21 14:32:32 2019
+++ pkgsrc/graphics/xv/patches/patch-Imakefile Sun Jul 30 07:55:45 2023
@@ -1,11 +1,14 @@
-$NetBSD: patch-Imakefile,v 1.1 2019/02/21 14:32:32 tsutsui Exp $
+$NetBSD: patch-Imakefile,v 1.2 2023/07/30 07:55:45 tsutsui Exp $
- use jpeg, png, tiff, and zlib from pkgsrc
- make ghostscript support optional
+- add webp support from forked upstream
+ https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
+ and use libwebp from pkgsrc
---- Imakefile.orig 2019-02-21 14:07:37.512579350 +0000
+--- Imakefile.orig 2023-07-30 04:38:19.657014071 +0000
+++ Imakefile
-@@ -6,13 +6,15 @@
+@@ -6,13 +6,20 @@
/* if, for whatever reason, you're unable to get the JPEG library to compile
* on your machine, *COMMENT OUT* the following line
*/
@@ -13,6 +16,11 @@ $NetBSD: patch-Imakefile,v 1.1 2019/02/2
+/* #define HaveJpeg */
+#define UseInstalledJpeg
++/* if, for whatever reason, you're unable to get the WEBP library to compile
++ * on your machine, *COMMENT OUT* the following line
++ */
++/* #define HaveWEBP */
++#define UseInstalledWEBP
/* if, for whatever reason, you're unable to get the TIFF library to compile
* on your machine, *COMMENT OUT* the following line
@@ -23,7 +31,7 @@ $NetBSD: patch-Imakefile,v 1.1 2019/02/2
/* if, for whatever reason, you're unable to get the PDS/VICAR support
-@@ -21,6 +23,10 @@
+@@ -21,6 +28,10 @@
#define HavePDS
@@ -34,7 +42,27 @@ $NetBSD: patch-Imakefile,v 1.1 2019/02/2
/*
* 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
-@@ -124,20 +130,66 @@ MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\"
+@@ -116,28 +127,84 @@ MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\"
+
+ /* This marks the end of the configuration parameters */
+
++#ifdef HaveWEBP
++WEBP = -DDOWEBP
++WEBPDIR = /usr
++LIBWEBP = $(WEBPDIR)/lib/libwebp.so
++DEPLIBWEBP = $(LIBWEBP)
++WEBPINCLUDE = -I$(WEBPDIR)/include
++#endif
+
+-
+-
++#ifdef UseInstalledWEBP
++WEBP = -DDOWEBP
++LIBWEBP = $(LDFLAGS) -L$(PREFIX)/lib -Wl,-R$(PREFIX)/lib -lwebp
++WEBPINCLUDE = -I$(PREFIX)/include
++#endif
+
+ #ifdef HaveJpeg
JPEG = -DDOJPEG
JPEGDIR = jpeg
LIBJPEG = $(JPEGDIR)/libjpeg.a
@@ -101,22 +129,41 @@ $NetBSD: patch-Imakefile,v 1.1 2019/02/2
#if defined(SCOArchitecture)
SCO= -Dsco -DPOSIX -DNO_RANDOM
-@@ -149,14 +201,14 @@ SYS_LIBRARIES= -lm
+@@ -149,14 +216,15 @@ SYS_LIBRARIES= -lm
#endif
-DEPLIBS = $(LIBJPEG) $(LIBTIFF)
-LOCAL_LIBRARIES = $(XLIB) $(DEPLIBS)
-+DEPLIBS = $(DEPLIBJPEG) $(DEPLIBTIFF) $(DEPLIBPNG) $(DEPLIBZLIB)
-+LOCAL_LIBRARIES = $(XLIB) $(LIBJPEG) $(LIBTIFF) $(LIBPNG) $(LIBZLIB)
++DEPLIBS = $(DEPLIBJPEG) $(DEPLIBTIFF) $(DEPLIBPNG) $(DEPLIBWEBP) $(DEPLIBZLIB)
++LOCAL_LIBRARIES = $(XLIB) $(LIBJPEG) $(LIBTIFF) $(LIBPNG) $(LIBWEBP) $(LIBZLIB)
DEFINES= $(SCO) $(UNIX) $(NODIRENT) $(VPRINTF) $(TIMERS) \
- $(HPUX7) $(JPEG) $(TIFF) $(PDS) $(DXWM) $(RAND) \
-+ $(HPUX7) $(JPEG) $(TIFF) $(GS) $(PNG) $(PDS) $(DXWM) $(RAND) \
++ $(HPUX7) $(JPEG) $(TIFF) $(GS) $(PNG) $(WEBP) $(PDS) $(DXWM) $(RAND) \
$(BACKING_STORE) $(BSDTYPES) $(SGI) $(MGCSFX)
-INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE)
-+INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) $(PNGINCLUDE) $(ZLIBINCLUDE)
++INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) $(PNGINCLUDE) $(WEBPINCLUDE) \
++ $(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 \
+@@ -166,7 +234,7 @@ SRCS1 = xv.c xvevent.c xvroot.c xvmisc.c
+ xvbrowse.c xvtext.c xvpcx.c xviff.c xvtarga.c xvxpm.c xvcut.c \
+ xvxwd.c xvfits.c xvpng.c xvzx.c xvwbmp.c xvpcd.c \
+ xvmag.c xvpic.c xvmaki.c xvpi.c xvpic2.c xvvd.c xvmgcsfx.c \
+- xvml.c
++ xvml.c xvwebp.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 \
+@@ -176,7 +244,7 @@ OBJS1 = xv.o xvevent.o xvroot.o xvmisc.o
+ xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \
+ xvxwd.o xvfits.o xvpng.o xvzx.o xvwbmp.o xvpcd.o \
+ xvmag.o xvpic.o xvmaki.o xvpi.o xvpic2.o xvvd.o xvmgcsfx.o \
+- xvml.o
++ xvml.o xvwebp.o
+
+ SRCS2= bggen.c
+ OBJS2= bggen.o
Index: pkgsrc/graphics/xv/patches/patch-xv.h
diff -u pkgsrc/graphics/xv/patches/patch-xv.h:1.1 pkgsrc/graphics/xv/patches/patch-xv.h:1.2
--- pkgsrc/graphics/xv/patches/patch-xv.h:1.1 Thu Feb 21 14:32:32 2019
+++ pkgsrc/graphics/xv/patches/patch-xv.h Sun Jul 30 07:55:45 2023
@@ -1,10 +1,12 @@
-$NetBSD: patch-xv.h,v 1.1 2019/02/21 14:32:32 tsutsui Exp $
+$NetBSD: patch-xv.h,v 1.2 2023/07/30 07:55:45 tsutsui Exp $
- don't declare errno and sys_errlist
- use strerror
- use getcwd, not getwd
+- add webp support from forked upstream
+ https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
---- xv.h.orig 2019-02-21 14:07:38.801848956 +0000
+--- xv.h.orig 2023-07-30 04:38:20.907901851 +0000
+++ xv.h
@@ -139,9 +139,7 @@
#endif
@@ -55,3 +57,71 @@ $NetBSD: patch-xv.h,v 1.1 2019/02/21 14:
# define USE_GETCWD
#endif
+@@ -411,6 +411,9 @@
+ /* END OF CONFIGURATION INFO */
+ /*****************************/
+
++#ifdef DOWEBP
++# define HAVE_WEBP
++#endif
+
+ #ifdef DOJPEG
+ # define HAVE_JPEG
+@@ -568,6 +571,12 @@
+ # define F_TIFINC 0
+ #endif
+
++#ifdef HAVE_WEBP
++# define F_WEBPINC 1
++#else
++# define F_WEBPINC 0
++#endif
++
+ #ifdef HAVE_PNG
+ # define F_PNGINC 1
+ #else
+@@ -621,7 +630,8 @@
+ #define F_JPC ( 0 + F_PNGINC + F_JPGINC)
+ #define F_JP2 ( 0 + F_PNGINC + F_JPGINC + F_JP2INC)
+ #define F_GIF ( 0 + F_PNGINC + F_JPGINC + F_JP2INC + F_JP2INC) /* always avail; index varies */
+-#define F_TIFF ( 0 + F_PNGINC + F_JPGINC + F_JP2INC + F_JP2INC + F_TIFINC)
++#define F_WEBP ( 0 + F_PNGINC + F_JPGINC + F_JP2INC + F_JP2INC + F_WEBPINC)
++#define F_TIFF ( 0 + F_PNGINC + F_JPGINC + F_JP2INC + F_JP2INC + F_WEBPINC + F_TIFINC)
+ #define F_PS ( 1 + F_TIFF)
+ #define F_PBMRAW ( 2 + F_TIFF)
+ #define F_PBMASCII ( 3 + F_TIFF)
+@@ -691,6 +701,7 @@
+ #define RFT_PI (JP_EXT_RFT + 4)
+ #define RFT_PIC2 (JP_EXT_RFT + 5)
+ #define RFT_MGCSFX (JP_EXT_RFT + 6)
++#define RFT_WEBP (JP_EXT_RFT + 7)
+
+ /* definitions for page up/down, arrow up/down list control */
+ #define LS_PAGEUP 0
+@@ -1404,6 +1415,11 @@ WHERE Window pngW;
+ WHERE int pngUp; /* is pngW mapped, or what? */
+ #endif
+
++#ifdef HAVE_WEBP
++/* stuff used for 'webp' box */
++WHERE Window webpW;
++WHERE int webpUp; /* is webpW mapped, or what? */
++#endif
+
+ #ifdef ENABLE_FIXPIX_SMOOTH
+ WHERE int do_fixpix_smooth; /* GRR 19980607: runtime FS dithering */
+@@ -2094,6 +2110,14 @@ int LoadSunRas PARM((char *,
+ int WriteSunRas PARM((FILE *, byte *, int, int, int, byte *,
+ byte *, byte*, int, int, int));
+
++/**************************** XVWEBP.C ***************************/
++int LoadWEBP PARM((char *, PICINFO *));
++void CreateWEBPW PARM((void));
++void WEBPDialog PARM((int));
++int WEBPCheckEvent PARM((XEvent *));
++void WEBPSaveParams PARM((char *));
++void VersionInfoWEBP PARM((void));
++
+ /**************************** XVTARGA.C ***************************/
+ int LoadTarga PARM((char *, PICINFO *));
+ int WriteTarga PARM((FILE *, byte *, int, int, int, byte *,
Added files:
Index: pkgsrc/graphics/xv/patches/patch-bits_br__webp
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-bits_br__webp:1.1
--- /dev/null Sun Jul 30 07:55:45 2023
+++ pkgsrc/graphics/xv/patches/patch-bits_br__webp Sun Jul 30 07:55:45 2023
@@ -0,0 +1,31 @@
+$NetBSD: patch-bits_br__webp,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
+
+- add webp support from forked upstream
+ https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
+
+--- bits/br_webp.orig 2023-07-30 04:38:21.013694459 +0000
++++ bits/br_webp
+@@ -0,0 +1,23 @@
++#define br_webp_width 48
++#define br_webp_height 48
++static char br_webp_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,0x7f,0x02,0x20,0x00,0x00,0x00,0x00,0x02,
++ 0x20,0xff,0xff,0xff,0x7f,0x02,0x20,0x00,0x00,0x00,0x00,0x02,0x20,0x83,0x7d,
++ 0x3f,0x3f,0x02,0x20,0x83,0x7d,0x7f,0x7f,0x02,0x20,0x83,0x0d,0x63,0x63,0x02,
++ 0x20,0x93,0x0d,0x63,0x63,0x02,0x20,0x93,0x0d,0x63,0x63,0x02,0x20,0xbb,0x7d,
++ 0x7f,0x73,0x02,0x20,0xbb,0x7d,0x3f,0x3f,0x02,0x20,0xef,0x0d,0x63,0x1f,0x02,
++ 0x20,0xef,0x0d,0x63,0x03,0x02,0x20,0xc7,0x0d,0x63,0x03,0x02,0x20,0xc7,0x0d,
++ 0x63,0x03,0x02,0x20,0x83,0x7d,0x7f,0x03,0x02,0x20,0x83,0x7d,0x3f,0x03,0x02,
++ 0x20,0x00,0x00,0x00,0x00,0x02,0x20,0xff,0xff,0xff,0x7f,0x02,0x20,0x00,0x00,
++ 0x00,0x00,0x02,0x20,0xff,0xff,0xff,0x7f,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};
Index: pkgsrc/graphics/xv/patches/patch-xv.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xv.c:1.1
--- /dev/null Sun Jul 30 07:55:45 2023
+++ pkgsrc/graphics/xv/patches/patch-xv.c Sun Jul 30 07:55:45 2023
@@ -0,0 +1,67 @@
+$NetBSD: patch-xv.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
+
+- add webp support from forked upstream
+ https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
+
+--- xv.c.orig 2023-07-30 04:38:20.015663071 +0000
++++ xv.c
+@@ -337,6 +337,10 @@ int main(argc, argv)
+ pngW = (Window) NULL; pngUp = 0;
+ #endif
+
++#ifdef HAVE_WEBP
++ webpW = (Window) NULL; webpUp = 0;
++#endif
++
+ pcdW = (Window) NULL; pcdUp = 0;
+
+ #ifdef HAVE_PIC2
+@@ -980,6 +984,11 @@ int main(argc, argv)
+ XSetTransientForHint(theDisp, pngW, dirW);
+ #endif
+
++#ifdef HAVE_WEBP
++ CreateWEBPW();
++ XSetTransientForHint(theDisp, webpW, dirW);
++#endif
++
+ #ifdef HAVE_PCD
+ CreatePCDW();
+ XSetTransientForHint(theDisp, pcdW, dirW);
+@@ -1870,6 +1879,9 @@ static void cmdSyntax()
+ #ifdef HAVE_PNG
+ VersionInfoPNG();
+ #endif
++#ifdef HAVE_WEBP
++ VersionInfoWEBP();
++#endif
+ /* pbm/pgm/ppm support is native, not via pbmplus/netpbm libraries */
+ fprintf(stderr, "\n");
+
+@@ -3121,6 +3133,15 @@ int ReadFileType(fname)
+ magicno[2]=='N' && magicno[3]=='G') rv = RFT_PNG;
+ #endif
+
++#ifdef HAVE_WEBP
++ else if (magicno[0]==0x52 && magicno[1]==0x49 &&
++ magicno[2]==0x46 && magicno[3]==0x46 &&
++ magicno[8]==0x57 && magicno[9]==0x45 &&
++ magicno[10]==0x42 && magicno[11]==0x50 &&
++ magicno[12]==0x56 && magicno[13]==0x50 &&
++ magicno[14]==0x38) rv = RFT_WEBP;
++#endif
++
+ #ifdef HAVE_PDS
+ else if (strncmp((char *) magicno, "NJPL1I00", (size_t) 8)==0 ||
+ strncmp((char *) magicno+2,"NJPL1I", (size_t) 6)==0 ||
+@@ -3258,6 +3279,10 @@ int ReadPicFile(fname, ftype, pinfo, qui
+ case RFT_PNG: rv = LoadPNG (fname, pinfo); break;
+ #endif
+
++#ifdef HAVE_WEBP
++ case RFT_WEBP: rv = LoadWEBP (fname, pinfo); break;
++#endif
++
+ #ifdef HAVE_PDS
+ case RFT_PDSVICAR: rv = LoadPDS (fname, pinfo); break;
+ #endif
Index: pkgsrc/graphics/xv/patches/patch-xvbrowse.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xvbrowse.c:1.1
--- /dev/null Sun Jul 30 07:55:45 2023
+++ pkgsrc/graphics/xv/patches/patch-xvbrowse.c Sun Jul 30 07:55:45 2023
@@ -0,0 +1,49 @@
+$NetBSD: patch-xvbrowse.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
+
+- add webp support from forked upstream
+ https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
+
+--- xvbrowse.c.orig 2023-07-30 04:38:20.155639398 +0000
++++ xvbrowse.c
+@@ -69,6 +69,7 @@ typedef unsigned int mode_t; /* file mo
+ #include "bits/br_targa"
+ #include "bits/br_tiff"
+ #include "bits/br_utah"
++#include "bits/br_webp"
+ #include "bits/br_xbm"
+ #include "bits/br_xpm"
+ #include "bits/br_xwd"
+@@ -117,7 +118,8 @@ typedef unsigned int mode_t; /* file mo
+ #define BF_PCD 30
+ #define BF_BZIP2 31
+ #define BF_JP2 32
+-#define BF_JPC 33
++#define BF_WEBP 33
++#define BF_JPC 34
+ #define JP_EXT_BF (BF_JPC)
+ #define BF_MAG (JP_EXT_BF + 1)
+ #define BF_MAKI (JP_EXT_BF + 2)
+@@ -605,6 +607,7 @@ void CreateBrowse(geom, fgstr, bgstr, hi
+ bfIcons[BF_PS] =MakePix1(br->win,br_ps_bits, br_ps_width, br_ps_height);
+ bfIcons[BF_TGA] =MakePix1(br->win,br_tga_bits, br_tga_width, br_tga_height);
+ bfIcons[BF_TIFF]=MakePix1(br->win,br_tiff_bits,br_tiff_width,br_tiff_height);
++ bfIcons[BF_WEBP]=MakePix1(br->win,br_webp_bits,br_webp_width,br_webp_height);
+ bfIcons[BF_XBM] =MakePix1(br->win,br_xbm_bits, br_xbm_width, br_xbm_height);
+ bfIcons[BF_XPM] =MakePix1(br->win,br_xpm_bits, br_xpm_width, br_xpm_height);
+ bfIcons[BF_XWD] =MakePix1(br->win,br_xwd_bits, br_xwd_width, br_xwd_height);
+@@ -3351,6 +3354,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_MGCSFX: bf->ftype = BF_MGCSFX; break;
++ case RFT_WEBP: bf->ftype = BF_WEBP; break;
+ }
+ }
+ }
+@@ -3975,6 +3979,7 @@ ms_auto_no:
+ case RFT_PI: strcat(str,"PI file"); break;
+ case RFT_PIC2: strcat(str,"PIC2 file"); break;
+ case RFT_MGCSFX: strcat(str,"Magic Suffix file"); break;
++ case RFT_WEBP: strcat(str,"WEBP file"); break;
+ default: strcat(str,"file of unknown type"); break;
+ }
+
Index: pkgsrc/graphics/xv/patches/patch-xvdir.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xvdir.c:1.1
--- /dev/null Sun Jul 30 07:55:45 2023
+++ pkgsrc/graphics/xv/patches/patch-xvdir.c Sun Jul 30 07:55:45 2023
@@ -0,0 +1,75 @@
+$NetBSD: patch-xvdir.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
+
+- add webp support from forked upstream
+ https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
+
+--- xvdir.c.orig 2023-07-30 04:38:20.909134802 +0000
++++ xvdir.c
+@@ -65,8 +65,11 @@ static const char *saveFormats[] = {
+ #ifdef HAVE_JP2K
+ "JPEG 2000",
+ "JP2",
+-#endif
++#endif
+ "GIF",
++#ifdef HAVE_WEBP
++ "WEBP",
++#endif
+ #ifdef HAVE_TIFF
+ "TIFF",
+ #endif
+@@ -1235,6 +1238,16 @@ int DoSave()
+ }
+ #endif
+
++
++#ifdef HAVE_WEBP
++ else if (fmt == F_WEBP) { /* WEBP */
++ WEBPSaveParams(fullname);
++ WEBPDialog(1); /* open WEBP Dialog box */
++ dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]);
++ return 0; /* always 'succeeds' */
++ }
++#endif
++
+ #ifdef HAVE_PIC2
+ else if (fmt == F_PIC2) { /* PIC2 */
+ if (PIC2SaveParams(fullname, col) < 0)
+@@ -1488,7 +1501,15 @@ void SetDirSaveMode(group, bnum)
+ colMB.dim[F_REDUCED] = 1;
+ MBSelect(&colMB, F_BWDITHER);
+ }
+-
++#ifdef HAVE_WEBP
++ else if (MBWhich(&fmtMB) == F_WEBP) { /* turn off all but FULLCOLOR */
++ colMB.dim[F_FULLCOLOR] = 0;
++ colMB.dim[F_GREYSCALE] = 1;
++ colMB.dim[F_BWDITHER] = 1;
++ colMB.dim[F_REDUCED] = 1;
++ MBSelect(&colMB, F_FULLCOLOR);
++ }
++#endif
+ else if (MBWhich(&fmtMB) == F_FITS) { /* turn off 'color' modes */
+ colMB.dim[F_FULLCOLOR] = 1;
+ colMB.dim[F_GREYSCALE] = 0;
+@@ -1578,6 +1599,9 @@ static void changeSuffix()
+ #ifdef HAVE_PNG
+ (strcmp(lowsuf,"png" )==0) ||
+ #endif
++#ifdef HAVE_WEBP
++ (strcmp(lowsuf,"webp")==0) ||
++#endif
+ (strcmp(lowsuf,"wbmp")==0) ||
+ (strcmp(lowsuf,"xpm" )==0) ||
+ (strcmp(lowsuf,"tiff")==0) ||
+@@ -1645,6 +1669,10 @@ static void changeSuffix()
+ case F_MAKI: strcpy(lowsuf,"mki"); break;
+ #endif
+
++#ifdef HAVE_WEBP
++ case F_WEBP: strcpy(lowsuf,"webp"); break;
++#endif
++
+ #ifdef HAVE_PI
+ case F_PI: strcpy(lowsuf,"pi"); break;
+ #endif
Index: pkgsrc/graphics/xv/patches/patch-xvevent.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xvevent.c:1.1
--- /dev/null Sun Jul 30 07:55:45 2023
+++ pkgsrc/graphics/xv/patches/patch-xvevent.c Sun Jul 30 07:55:45 2023
@@ -0,0 +1,93 @@
+$NetBSD: patch-xvevent.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
+
+- add webp support using pkgsrc libwebp, from forked upstream
+ https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
+ - a pasto of a comment is also fixed
+
+--- xvevent.c.orig 2023-07-30 04:38:20.332206971 +0000
++++ xvevent.c
+@@ -212,6 +212,9 @@ int HandleEvent(event, donep)
+ #ifdef HAVE_PNG
+ static int wasPngUp=0;
+ #endif
++#ifdef HAVE_WEBP
++ static int wasWebpUp=0;
++#endif
+ #ifdef HAVE_PCD
+ static int wasPcdUp=0;
+ #endif
+@@ -307,6 +310,10 @@ int HandleEvent(event, donep)
+ if (PNGCheckEvent (event)) break; /* event has been processed */
+ #endif
+
++#ifdef HAVE_WEBP
++ if (WEBPCheckEvent(event)) break; /* event has been processed */
++#endif
++
+ if (PCDCheckEvent(event)) break; /* event has been processed */
+
+ #ifdef HAVE_PIC2
+@@ -462,6 +469,10 @@ int HandleEvent(event, donep)
+ else if (client_event->window == pngW) PNGDialog(0);
+ #endif
+
++#ifdef HAVE_WEBP
++ else if (client_event->window == webpW) WEBPDialog(0);
++#endif
++
+ else if (client_event->window == pcdW) PCDDialog(0);
+
+ #ifdef HAVE_PIC2
+@@ -664,6 +675,9 @@ int HandleEvent(event, donep)
+ #ifdef HAVE_PNG
+ if (wasPngUp) { PNGDialog(wasPngUp); wasPngUp=0; }
+ #endif
++#ifdef HAVE_WEBP
++ if (wasWebpUp) { WEBPDialog(wasWebpUp); wasWebpUp=0; }
++#endif
+ #ifdef HAVE_PCD
+ if (wasPcdUp) { PCDDialog(wasPcdUp); wasPcdUp=0; }
+ #endif
+@@ -716,6 +730,9 @@ int HandleEvent(event, donep)
+ #ifdef HAVE_PNG
+ if (pngUp) { wasPngUp = pngUp; PNGDialog(0); }
+ #endif
++#ifdef HAVE_WEBP
++ if (webpUp) { wasWebpUp = webpUp; WEBPDialog(0); }
++#endif
+ #ifdef HAVE_PCD
+ if (pcdUp) { wasPcdUp = pcdUp; PCDDialog(0); }
+ #endif
+@@ -1338,6 +1355,10 @@ static void handleButtonEvent(event, don
+ if (PNGCheckEvent (event)) break;
+ #endif
+
++#ifdef HAVE_WEBP
++ if (WEBPCheckEvent(event)) break;
++#endif
++
+ #ifdef HAVE_PCD
+ if (PCDCheckEvent (event)) break; /* event has been processed */
+ #endif
+@@ -1621,6 +1642,10 @@ static void handleKeyEvent(event, donep,
+ if (PNGCheckEvent (event)) break;
+ #endif
+
++#ifdef HAVE_WEBP
++ if (WEBPCheckEvent (event)) break;
++#endif
++
+ if (PCDCheckEvent (event)) break;
+
+ #ifdef HAVE_PIC2
+@@ -2704,6 +2729,10 @@ static void onInterrupt(i)
+ if (pngUp) PNGDialog(0); /* close png window */
+ #endif
+
++#ifdef HAVE_WEBP
++ if (webpUp) WEBPDialog(0); /* close webp window */
++#endif
++
+ if (pcdUp) PCDDialog(0); /* close pcd window */
+
+ #ifdef HAVE_PIC2
Index: pkgsrc/graphics/xv/patches/patch-xvmisc.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xvmisc.c:1.1
--- /dev/null Sun Jul 30 07:55:45 2023
+++ pkgsrc/graphics/xv/patches/patch-xvmisc.c Sun Jul 30 07:55:45 2023
@@ -0,0 +1,29 @@
+$NetBSD: patch-xvmisc.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
+
+- add webp support from forked upstream
+ https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
+
+--- xvmisc.c.orig 2023-07-30 04:38:20.941982982 +0000
++++ xvmisc.c
+@@ -549,6 +549,10 @@ void Quit(i)
+ if (pngW) XDestroyWindow(theDisp, pngW);
+ #endif
+
++#ifdef HAVE_WEBP
++ if (webpW) XDestroyWindow(theDisp, webpW);
++#endif
++
+ #ifdef HAVE_PCD
+ if (pcdW) XDestroyWindow(theDisp, pcdW);
+ #endif
+@@ -770,6 +774,10 @@ static void set_cursors(mainc, otherc)
+ if (pngW) XDefineCursor(theDisp, pngW, otherc);
+ #endif
+
++#ifdef HAVE_WEBP
++ if (webpW) XDefineCursor(theDisp, webpW, otherc);
++#endif
++
+ #ifdef HAVE_PCD
+ if (pcdW) XDefineCursor(theDisp, pcdW, otherc);
+ #endif
Index: pkgsrc/graphics/xv/patches/patch-xvwebp.c
diff -u /dev/null pkgsrc/graphics/xv/patches/patch-xvwebp.c:1.1
--- /dev/null Sun Jul 30 07:55:45 2023
+++ pkgsrc/graphics/xv/patches/patch-xvwebp.c Sun Jul 30 07:55:45 2023
@@ -0,0 +1,431 @@
+$NetBSD: patch-xvwebp.c,v 1.1 2023/07/30 07:55:45 tsutsui Exp $
+
+- add webp support from forked upstream
+ https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
+ - the default quality value is changed to 75 as the original libwebp
+ - the default "page" of quality qDial is changed to 5.0 as jpeg
+ - fix a bug of wrong quality value (almost 0) passed to WebPEncodeRGB()
+
+--- xvwebp.c.orig 2023-07-30 06:56:45.683695531 +0000
++++ xvwebp.c
+@@ -0,0 +1,420 @@
++/*
++ * xvwebp.c - load routine for 'webp' format pictures
++ *
++ * written and submitted by:
++ * Rainer Canavan (xv%canavan.de@localhost)
++ *
++ * LoadWEBP(fname, pinfo)
++ * WriteWEBP(fp, pic, ptype, w,h, rmap,gmap,bmap,numcols, cstyle, comment)
++ */
++
++
++#include "xv.h"
++
++#ifdef HAVE_WEBP
++
++#include <webp/types.h>
++#include <webp/encode.h>
++#include <webp/decode.h>
++
++static char *filename;
++static const char *bname;
++
++static void drawWEBPD PARM((int, int, int, int));
++static void clickWEBPD PARM((int, int));
++static void doCmd PARM((int));
++static void writeWEBP PARM((void));
++static int WriteWEBP PARM((FILE *, byte *, int, int, int,
++ byte *, byte *, byte *));
++
++
++/*** Stuff for WEBP Dialog box ***/
++#define WEBPWIDE 288
++#define WEBPHIGH 185
++
++#define QUALITY 75 /* default quality */
++
++#define DWIDE 86
++#define DHIGH 104
++
++#define P_BOK 0
++#define P_BCANC 1
++#define P_NBUTTS 2
++
++#define BUTTH 24
++
++static DIAL qDial;
++static BUTT pbut[P_NBUTTS];
++static CBUTT FlosslessCB;
++
++
++/*******************************************/
++void CreateWEBPW()
++{
++ webpW = CreateWindow("xv webp", "XVWEBP", NULL,
++ WEBPWIDE, WEBPHIGH, infofg, infobg, 0);
++ if (!webpW) FatalError("can't create WEBP window!");
++
++ XSelectInput(theDisp, webpW, ExposureMask | ButtonPressMask | KeyPressMask);
++
++ DCreate(&qDial, webpW, 12, 25, DWIDE, DHIGH, 0.0,
++ 100.0, QUALITY, 1.0, 5.0,
++ infofg, infobg, hicol, locol, "Quality", NULL);
++
++ CBCreate(&FlosslessCB, webpW, 110, 6+qDial.y+ASCENT+4*LINEHIGH, "Lossless",
++ infofg, infobg, hicol, locol);
++ FlosslessCB.val = 0;
++
++ BTCreate(&pbut[P_BOK], webpW, WEBPWIDE-180-1, WEBPHIGH-10-BUTTH-1, 80, BUTTH,
++ "Ok", infofg, infobg, hicol, locol);
++ BTCreate(&pbut[P_BCANC], webpW, WEBPWIDE-90-1, WEBPHIGH-10-BUTTH-1, 80, BUTTH,
++ "Cancel", infofg, infobg, hicol, locol);
++
++ XMapSubwindows(theDisp, webpW);
++}
++
++
++/*******************************************/
++void WEBPDialog(vis)
++ int vis;
++{
++ if (vis) {
++ CenterMapWindow(webpW, pbut[P_BOK].x + (int) pbut[P_BOK].w/2,
++ pbut[P_BOK].y + (int) pbut[P_BOK].h/2,
++ WEBPWIDE, WEBPHIGH);
++ }
++ else XUnmapWindow(theDisp, webpW);
++ webpUp = vis;
++}
++
++
++/*******************************************/
++int WEBPCheckEvent(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 (!webpUp) 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 == qDial.win)) {}
++
++ else if (e->window == webpW) drawWEBPD(x, y, w, h);
++ else if (e->window == qDial.win) DRedraw(&qDial);
++ 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 == webpW) clickWEBPD(x,y);
++ else if (e->window == qDial.win) DTrack(&qDial, 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 == webpW) {
++ 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 WEBPSaveParams(fname)
++ char *fname;
++{
++ filename = fname;
++}
++
++
++/*******************************************/
++static void drawWEBPD(x, y, w, h)
++ int x, y, w, h;
++{
++ const char *title = "Save WEBP file...";
++
++ char ctitle1[20];
++ const char *ctitle2 = "Quality value determines";
++ const char *ctitle3 = "compression rate: higher";
++ const char *ctitle4 = "quality = bigger file.";
++
++ 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(webpW, 15, 6+ASCENT, title);
++
++ sprintf(ctitle1, "Default = %d", QUALITY);
++ DrawString(webpW, 110, 6+qDial.y+ASCENT, ctitle1);
++ DrawString(webpW, 110, 6+qDial.y+ASCENT+LINEHIGH, ctitle2);
++ DrawString(webpW, 110, 6+qDial.y+ASCENT+2*LINEHIGH, ctitle3);
++ DrawString(webpW, 110, 6+qDial.y+ASCENT+3*LINEHIGH, ctitle4);
++
++ CBRedraw(&FlosslessCB);
++
++ XSetClipMask(theDisp, theGC, None);
++}
++
++
++/*******************************************/
++static void clickWEBPD(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(&FlosslessCB,x,y)) {
++ int oldval = FlosslessCB.val;
++
++ CBTrack(&FlosslessCB);
++
++ if (oldval != FlosslessCB.val)
++ {
++ DSetActive(&qDial, !FlosslessCB.val);
++ DRedraw(&qDial); /* necessary? */
++ }
++ }
++}
++
++
++/*******************************************/
++static void doCmd(cmd)
++ int cmd;
++{
++ switch (cmd) {
++ case P_BOK:
++ {
++ char *fullname;
++
++ writeWEBP();
++ WEBPDialog(0);
++
++ fullname = GetDirFullName();
++ if (!ISPIPE(fullname[0])) {
++ XVCreatedFile(fullname);
++ StickInCtrlList(0);
++ }
++ }
++ break;
++
++ case P_BCANC:
++ WEBPDialog(0);
++ break;
++
++ default:
++ break;
++ }
++}
++
++/*******************************************/
++int LoadWEBP(fname, pinfo)
++ char *fname;
++ PICINFO *pinfo;
++/*******************************************/
++{
++ /* returns '1' on success */
++
++ FILE *fp;
++ int c, w, h;
++ size_t filesize;
++ byte *filebuf, *pic24;
++
++ bname = BaseName(fname);
++
++ pinfo->pic = (byte *) NULL;
++ pinfo->comment = (char *) NULL;
++
++ fp = xv_fopen(fname,"r");
++ if (!fp) {
++ SetISTR(ISTR_WARNING,"%s: %s", bname, "can't open file");
++ return 0;
++ }
++
++ /* compute file length */
++ fseek(fp, 0L, 2);
++ filesize = ftell(fp);
++ fseek(fp, 0L, 0);
++
++ if (filesize < 24) {
++ fclose(fp);
++ SetISTR(ISTR_WARNING,"%s: %s", bname, "file is too short");
++ return 0;
++ }
++
++ /* read in the entire file */
++
++ filebuf = (byte *) calloc((size_t) filesize, (size_t) 1);
++ if (!filebuf) FatalError("couldn't malloc 'file buffer'");
++ c = fread(filebuf, (size_t) 1, (size_t) filesize, fp);
++ if (c != filesize) {
++ SetISTR(ISTR_WARNING,"%s: %s", bname, "file read error");
++ }
++ fclose(fp);
++ pic24 = WebPDecodeRGB(filebuf, (size_t)filesize, &w, &h);
++ free(filebuf);
++ if (pic24 == NULL) {
++ SetISTR(ISTR_WARNING,"%s: %s", bname, "WebP decode failed");
++ return 0;
++ }
++
++ pinfo->pic = pic24;
++ pinfo->type = PIC24;
++ pinfo->w = w;
++ pinfo->h = h;
++ pinfo->normw = pinfo->w; pinfo->normh = pinfo->h;
++ pinfo->frmType = F_WEBP;
++ sprintf(pinfo->fullInfo,"WEBP, RGB. (%ld bytes)", filesize);
++ sprintf(pinfo->shrtInfo,"%dx%d WEBP.", w,h);
++ pinfo->colType = F_FULLCOLOR;
++
++ return 1;
++}
++
++/*******************************************/
++static void writeWEBP()
++{
++ FILE *fp;
++ int w, h, nc, rv, ptype, pfree;
++ byte *inpix, *rmap, *gmap, *bmap;
++
++ fp = OpenOutFile(filename);
++ if (!fp) return;
++
++ bname = BaseName(filename);
++
++ WaitCursor();
++ inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
++
++ rv = WriteWEBP(fp, inpix, ptype, w, h, rmap, gmap, bmap);
++
++ SetCursors(-1);
++
++ if (CloseOutFile(fp, filename, rv) == 0) DirBox(0);
++
++ if (pfree) free(inpix);
++}
++
++
++/*******************************************/
++int WriteWEBP(fp,pic,ptype,w,h,rmap,gmap,bmap)
++ FILE *fp;
++ byte *pic;
++ int ptype, w,h;
++ byte *rmap, *gmap, *bmap;
++
++/*******************************************/
++{
++ int i;
++ byte *xpic;
++ size_t imagesize;
++ size_t outsize;
++ int pfree;
++
++ imagesize = w*h*3;
++ WaitCursor();
++ pfree = 0;
++ if (ptype == PIC8) {
++ byte *last = pic + w*h;
++ register byte *from, *to;
++
++ from = pic;
++
++ if (!(pic = (byte *)malloc(imagesize))) FatalError("out of memory\n");
++ to = pic;
++ pfree = 1; /* Let the modified buffer be released later */
++
++ do {
++ i = *from;
++ *to++ = rmap[i];
++ *to++ = gmap[i];
++ *to++ = bmap[i];
++ } while (++from < last);
++
++ }
++ if (FlosslessCB.val == 0) {
++ outsize = WebPEncodeRGB(pic, w, h, w*3, (float)qDial.val, &xpic);
++ } else {
++ outsize = WebPEncodeLosslessRGB(pic, w, h, w*3, &xpic);
++ }
++ if (pfree == 1) { free(pic); }
++ if (outsize <= 0) {
++ free(xpic);
++ return -1;
++ }
++ fwrite(xpic, outsize, 1, fp);
++ SetCursors(-1);
++ free(xpic);
++ if (ferror(fp)) return -1;
++ return 0;
++}
++
++/*******************************************/
++void
++VersionInfoWEBP() /* GRR 19980605 */
++{
++ int ver;
++ ver = WebPGetDecoderVersion();
++ fprintf(stderr, " Compiled with libwebp; using libwebp %i.%i.%i.\n",
++ (ver >> 16) & 255, (ver >> 8 ) & 255, ver & 255);
++}
++
++#endif
Home |
Main Index |
Thread Index |
Old Index