OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2489 lines
72 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../xv/xv.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2003 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This patch file is dual-licensed. It is available under the license the
  11. # patched project is licensed under, as long as it is an OpenSource license
  12. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  13. # of the GNU General Public License as published by the Free Software
  14. # Foundation; either version 2 of the License, or (at your option) any later
  15. # version.
  16. # --- SDE-COPYRIGHT-NOTE-END ---
  17. diff -uNr Makefile Makefile
  18. --- ./Makefile Mon Jan 23 21:20:54 1995
  19. +++ ./Makefile Tue Feb 20 17:48:33 2001
  20. @@ -28,10 +28,10 @@
  21. ### Installation locations
  22. -BINDIR = /usr/local/bin
  23. -MANDIR = /usr/local/man/man1
  24. +BINDIR = /usr/bin
  25. +MANDIR = /usr/man/man1
  26. MANSUF = 1
  27. -LIBDIR = /usr/local/lib
  28. +LIBDIR = /usr/lib
  29. buildit: all
  30. @@ -45,26 +45,31 @@
  31. ### if, for whatever reason, you're unable to get the JPEG library to compile
  32. ### on your machine, *COMMENT OUT* the following lines
  33. ###
  34. -JPEG = -DDOJPEG
  35. -JPEGDIR = jpeg
  36. -JPEGINC = -I$(JPEGDIR)
  37. -JPEGLIB = $(JPEGDIR)/libjpeg.a
  38. -$(JPEGDIR)/jconfig.h:
  39. - cd $(JPEGDIR) ; ./configure CC='$(CC)'
  40. -$(JPEGLIB): $(JPEGDIR)/jconfig.h
  41. - cd $(JPEGDIR) ; make
  42. +JPEG = -DDOJPEG
  43. +JPEGLIB = -ljpeg
  44. +
  45. +
  46. +###
  47. +### if, for whatever reason, you're unable to get the PNG library to compile
  48. +### on your machine, *COMMENT OUT* the following lines
  49. +###
  50. +PNG = -DDOPNG
  51. +PNGLIB = -lpng
  52. +
  53. +
  54. +###
  55. +### if, for whatever reason, you're unable to get the PNG library to compile
  56. +### on your machine, *COMMENT OUT* the following lines
  57. +###
  58. +ZLIBLIB = -lz
  59. ###
  60. ### if, for whatever reason, you're unable to get the TIFF library to compile
  61. ### on your machine, *COMMENT OUT* the following lines
  62. ###
  63. -TIFF = -DDOTIFF
  64. -TIFFDIR = tiff
  65. -TIFFINC = -I$(TIFFDIR)
  66. -TIFFLIB = $(TIFFDIR)/libtiff.a
  67. -$(TIFFLIB):
  68. - ( cd $(TIFFDIR) ; make CC='$(CC)' )
  69. +TIFF = -DDOTIFF
  70. +TIFFLIB = -ltiff
  71. ###
  72. @@ -184,11 +189,11 @@
  73. -CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
  74. +CFLAGS = $(CCOPTS) $(JPEG) $(TIFF) $(PDS) \
  75. $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
  76. - $(DXWM) $(MCHN)
  77. + $(DXWM) $(MCHN) $(PNG)
  78. -LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
  79. +LIBS = -lX11 -L/usr/X11/lib $(JPEGLIB) $(TIFFLIB) $(PNGLIB) $(ZLIBLIB) -lm
  80. OBJS = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \
  81. xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \
  82. @@ -196,7 +201,7 @@
  83. xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \
  84. xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \
  85. xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \
  86. - xvxwd.o xvfits.o
  87. + xvxwd.o xvfits.o xvpng.o
  88. MISC = README INSTALL CHANGELOG IDEAS
  89. @@ -206,10 +211,10 @@
  90. -all: $(JPEGLIB) $(TIFFLIB) xv bggen vdcomp xcmap xvpictoppm
  91. +all: xv bggen vdcomp xcmap xvpictoppm
  92. -xv: $(OBJS) $(JPEGLIB) $(TIFFLIB)
  93. +xv: $(OBJS)
  94. $(CC) -o xv $(CFLAGS) $(OBJS) $(LIBS)
  95. bggen: bggen.c
  96. @@ -267,7 +272,7 @@
  97. xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds
  98. xvbrowse.o: bits/br_ps bits/br_iff bits/br_targa bits/br_xpm
  99. xvbrowse.o: bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm
  100. -xvbrowse.o: bits/br_xwd
  101. +xvbrowse.o: bits/br_xwd bits/br_png
  102. xvbutt.o: bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top
  103. xvbutt.o: bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body
  104. diff -uNr Makefile.std Makefile.std
  105. --- ./Makefile.std Tue Jan 24 02:06:26 1995
  106. +++ ./Makefile.std Tue Feb 20 17:04:44 2001
  107. @@ -56,6 +56,25 @@
  108. ###
  109. +### if, for whatever reason, you're unable to get the PNG library to compile
  110. +### on your machine, *COMMENT OUT* the following lines
  111. +###
  112. +PNG = -DDOPNG
  113. +PNGDIR = /usr/local/src/libpng
  114. +PNGINC = -I$(PNGDIR)
  115. +PNGLIB = -L$(PNGDIR) -lpng
  116. +
  117. +
  118. +###
  119. +### if, for whatever reason, you're unable to get the PNG library to compile
  120. +### on your machine, *COMMENT OUT* the following lines
  121. +###
  122. +ZLIBDIR = /usr/local/src/zlib
  123. +ZLIBINC = -I$(ZLIBDIR)
  124. +ZLIBLIB = -L$(ZLIBDIR) -lz
  125. +
  126. +
  127. +###
  128. ### if, for whatever reason, you're unable to get the TIFF library to compile
  129. ### on your machine, *COMMENT OUT* the following lines
  130. ###
  131. @@ -186,9 +205,9 @@
  132. CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINC) $(TIFF) $(TIFFINC) $(PDS) \
  133. $(NODIRENT) $(VPRINTF) $(TIMERS) $(UNIX) $(BSDTYPES) $(RAND) \
  134. - $(DXWM) $(MCHN)
  135. + $(DXWM) $(MCHN) $(PNG) $(PNGINC) $(ZLIBINC)
  136. -LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) -lm
  137. +LIBS = -lX11 $(JPEGLIB) $(TIFFLIB) $(PNGLIB) $(ZLIBLIB) -lm
  138. OBJS = xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \
  139. xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \
  140. @@ -196,7 +215,7 @@
  141. xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \
  142. xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \
  143. xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \
  144. - xvxwd.o xvfits.o
  145. + xvxwd.o xvfits.o xvpng.o
  146. MISC = README INSTALL CHANGELOG IDEAS
  147. @@ -267,7 +286,7 @@
  148. xvbrowse.o: bits/br_pcx bits/br_jfif bits/br_tiff bits/br_pds
  149. xvbrowse.o: bits/br_ps bits/br_iff bits/br_targa bits/br_xpm
  150. xvbrowse.o: bits/br_trash bits/fcurs bits/fccurs bits/fdcurs bits/fcursm
  151. -xvbrowse.o: bits/br_xwd
  152. +xvbrowse.o: bits/br_xwd bits/br_png
  153. xvbutt.o: bits/cboard50 bits/rb_frame bits/rb_frame1 bits/rb_top
  154. xvbutt.o: bits/rb_bot bits/rb_dtop bits/rb_dbot bits/rb_body
  155. diff -uNr bits/br_png bits/br_png
  156. --- ./bits/br_png Thu Jan 1 01:00:00 1970
  157. +++ ./bits/br_png Thu Jun 13 23:32:08 1996
  158. @@ -0,0 +1,28 @@
  159. +#define br_png_width 48
  160. +#define br_png_height 48
  161. +static unsigned char br_png_bits[] = {
  162. + 0xe0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x03, 0x00,
  163. + 0x20, 0x00, 0x00, 0x00, 0x05, 0x00, 0x20, 0x00, 0x00, 0x00, 0x09, 0x00,
  164. + 0x20, 0x00, 0x00, 0x00, 0x11, 0x00, 0x20, 0x00, 0x00, 0x00, 0x21, 0x00,
  165. + 0x20, 0x00, 0x00, 0x00, 0x41, 0x00, 0x20, 0x00, 0x00, 0x00, 0x81, 0x00,
  166. + 0x20, 0x00, 0x00, 0x00, 0x01, 0x01, 0x20, 0x00, 0x00, 0x00, 0xff, 0x03,
  167. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  168. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
  169. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
  170. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  171. + 0x20, 0xf8, 0x19, 0xc3, 0x07, 0x02, 0x20, 0x18, 0x3b, 0x63, 0x0c, 0x02,
  172. + 0x20, 0x18, 0x3b, 0x33, 0x00, 0x02, 0x20, 0x18, 0x5b, 0x33, 0x00, 0x02,
  173. + 0x20, 0xf8, 0x59, 0x33, 0x0f, 0x02, 0x20, 0x18, 0x98, 0x33, 0x0c, 0x02,
  174. + 0x20, 0x18, 0x98, 0x33, 0x0c, 0x02, 0x20, 0x18, 0x18, 0x63, 0x0c, 0x02,
  175. + 0x20, 0x18, 0x18, 0xc3, 0x0b, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  176. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  177. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
  178. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0xff, 0xff, 0xff, 0x3f, 0x02,
  179. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  180. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  181. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  182. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  183. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  184. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02,
  185. + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03,
  186. + };
  187. diff -uNr config.h config.h
  188. --- ./config.h Thu Jan 5 19:49:21 1995
  189. +++ ./config.h Tue Feb 20 17:07:25 2001
  190. @@ -13,13 +13,13 @@
  191. * definition appropriately. (use 'which gunzip' to find if you have gunzip,
  192. * and where it lives)
  193. */
  194. -#undef USE_GUNZIP
  195. +#define USE_GUNZIP
  196. #ifdef USE_GUNZIP
  197. # ifdef VMS
  198. # define GUNZIP "UNCOMPRESS"
  199. # else
  200. -# define GUNZIP "/usr/local/bin/gunzip -q"
  201. +# define GUNZIP "/bin/gunzip -q"
  202. # endif
  203. #endif
  204. @@ -88,9 +88,9 @@
  205. * should not need to be changed
  206. */
  207. -/* #define GS_PATH "/usr/local/bin/gs" */
  208. -/* #define GS_LIB "." */
  209. -/* #define GS_DEV "ppmraw" */
  210. +#define GS_PATH "/usr/bin/gs"
  211. +#define GS_LIB "."
  212. +#define GS_DEV "ppmraw"
  213. /***************************************************************************
  214. diff -uNr xcmap.c xcmap.c
  215. --- ./xcmap.c Tue Jan 3 22:14:52 1995
  216. +++ ./xcmap.c Tue Feb 20 17:04:13 2001
  217. @@ -140,8 +140,13 @@
  218. nxcells = nycells = 8;
  219. else if (dispcells>4)
  220. nxcells = nycells = 4;
  221. - else
  222. + else if (dispcells>2)
  223. nxcells = nycells = 2;
  224. + else
  225. + {
  226. + nxcells = 2;
  227. + nycells = 1;
  228. + }
  229. /**************** Create/Open X Resources ***************/
  230. if ((mfinfo = XLoadQueryFont(theDisp,FONT))==NULL) {
  231. @@ -267,18 +272,25 @@
  232. x=y=w=h=1;
  233. i=XParseGeometry(geom,&x,&y,&w,&h);
  234. - if (i&WidthValue) WIDE = (int) w;
  235. - if (i&HeightValue) HIGH = (int) h;
  236. -
  237. - if (i&XValue || i&YValue) hints.flags = USPosition;
  238. - else hints.flags = PPosition;
  239. -
  240. - hints.flags |= USSize;
  241. -
  242. - if (i&XValue && i&XNegative)
  243. - x = XDisplayWidth(theDisp,theScreen)-WIDE-abs(x);
  244. - if (i&YValue && i&YNegative)
  245. - y = XDisplayHeight(theDisp,theScreen)-HIGH-abs(y);
  246. + if (i&WidthValue)
  247. + {
  248. + WIDE = (int) w;
  249. + hints.flags |= USSize;
  250. + }
  251. + if (i&HeightValue)
  252. + {
  253. + HIGH = (int) h;
  254. + hints.flags |= USSize;
  255. + }
  256. +
  257. + if (i&XValue || i&YValue)
  258. + {
  259. + if (i&XNegative)
  260. + x = XDisplayWidth(theDisp,theScreen)-WIDE-abs(x);
  261. + if (i&YNegative)
  262. + y = XDisplayHeight(theDisp,theScreen)-HIGH-abs(y);
  263. + hints.flags |= USPosition;
  264. + }
  265. hints.x=x; hints.y=y;
  266. hints.width = WIDE; hints.height = HIGH;
  267. diff -uNr xv.c xv.c
  268. --- ./xv.c Thu Jan 19 19:08:43 1995
  269. +++ ./xv.c Tue Feb 20 17:04:44 2001
  270. @@ -277,6 +277,10 @@
  271. tiffW = (Window) NULL; tiffUp = 0;
  272. #endif
  273. +#ifdef HAVE_PNG
  274. + pngW = (Window) NULL; pngUp = 0;
  275. +#endif
  276. +
  277. imap = ctrlmap = gmap = browmap = cmtmap = 0;
  278. ch_offx = ch_offy = p_offx = p_offy = 0;
  279. @@ -782,6 +786,10 @@
  280. XSetTransientForHint(theDisp, tiffW, dirW);
  281. #endif
  282. +#ifdef HAVE_PNG
  283. + CreatePNGW();
  284. + XSetTransientForHint(theDisp, pngW, dirW);
  285. +#endif
  286. LoadFishCursors();
  287. SetCursors(-1);
  288. @@ -2611,6 +2619,11 @@
  289. (magicno[0]=='I' && magicno[1]=='I')) rv = RFT_TIFF;
  290. #endif
  291. +#ifdef HAVE_PNG
  292. + else if (magicno[0]==0x89 && magicno[1]=='P' &&
  293. + magicno[2]=='N' && magicno[3]=='G') rv = RFT_PNG;
  294. +#endif
  295. +
  296. #ifdef HAVE_PDS
  297. else if (strncmp((char *) magicno, "NJPL1I00", (size_t) 8)==0 ||
  298. strncmp((char *) magicno+2,"NJPL1I", (size_t) 6)==0 ||
  299. @@ -2669,6 +2682,10 @@
  300. #ifdef HAVE_TIFF
  301. case RFT_TIFF: rv = LoadTIFF (fname, pinfo); break;
  302. +#endif
  303. +
  304. +#ifdef HAVE_PNG
  305. + case RFT_PNG: rv = LoadPNG (fname, pinfo); break;
  306. #endif
  307. #ifdef HAVE_PDS
  308. diff -uNr xv.h xv.h
  309. --- ./xv.h Mon Jan 23 21:22:23 1995
  310. +++ ./xv.h Tue Feb 20 17:10:11 2001
  311. @@ -8,8 +8,8 @@
  312. #include "config.h"
  313. -#define REVDATE "Version 3.10a Rev: 12/29/94"
  314. -#define VERSTR "3.10a"
  315. +#define REVDATE "Version 3.10a Rev: 12/29/94 (PNG patch 1.2)"
  316. +#define VERSTR "3.10a(PNG)"
  317. /*
  318. * uncomment the following, and modify for your site, but only if you've
  319. @@ -116,7 +116,7 @@
  320. # include <errno.h>
  321. extern int errno; /* SHOULD be in errno.h, but often isn't */
  322. # ifndef __NetBSD__
  323. - extern char *sys_errlist[]; /* this too... */
  324. +// extern char *sys_errlist[]; /* this too... */
  325. # endif
  326. #endif
  327. @@ -327,6 +327,10 @@
  328. #define HAVE_TIFF
  329. #endif
  330. +#ifdef DOPNG
  331. +#define HAVE_PNG
  332. +#endif
  333. +
  334. #ifdef DOPDS
  335. #define HAVE_PDS
  336. #endif
  337. @@ -458,24 +462,31 @@
  338. #define F_TIFINC 0
  339. #endif
  340. +#ifdef HAVE_PNG
  341. +#define F_PNGINC 1
  342. +#else
  343. +#define F_PNGINC 0
  344. +#endif
  345. +
  346. #define F_GIF 0
  347. #define F_JPEG ( 0 + F_JPGINC)
  348. #define F_TIFF ( 0 + F_JPGINC + F_TIFINC)
  349. -#define F_PS ( 1 + F_JPGINC + F_TIFINC)
  350. -#define F_PBMRAW ( 2 + F_JPGINC + F_TIFINC)
  351. -#define F_PBMASCII ( 3 + F_JPGINC + F_TIFINC)
  352. -#define F_XBM ( 4 + F_JPGINC + F_TIFINC)
  353. -#define F_XPM ( 5 + F_JPGINC + F_TIFINC)
  354. -#define F_BMP ( 6 + F_JPGINC + F_TIFINC)
  355. -#define F_SUNRAS ( 7 + F_JPGINC + F_TIFINC)
  356. -#define F_IRIS ( 8 + F_JPGINC + F_TIFINC)
  357. -#define F_TARGA ( 9 + F_JPGINC + F_TIFINC)
  358. -#define F_FITS (10 + F_JPGINC + F_TIFINC)
  359. -#define F_PM (11 + F_JPGINC + F_TIFINC)
  360. -#define F_DELIM1 (12 + F_JPGINC + F_TIFINC) /* ----- */
  361. -#define F_FILELIST (13 + F_JPGINC + F_TIFINC)
  362. -#define F_MAXFMTS (14 + F_JPGINC + F_TIFINC) /* 15, normally */
  363. +#define F_PNG ( 0 + F_JPGINC + F_TIFINC + F_PNGINC)
  364. +#define F_PS ( 1 + F_JPGINC + F_TIFINC + F_PNGINC)
  365. +#define F_PBMRAW ( 2 + F_JPGINC + F_TIFINC + F_PNGINC)
  366. +#define F_PBMASCII ( 3 + F_JPGINC + F_TIFINC + F_PNGINC)
  367. +#define F_XBM ( 4 + F_JPGINC + F_TIFINC + F_PNGINC)
  368. +#define F_XPM ( 5 + F_JPGINC + F_TIFINC + F_PNGINC)
  369. +#define F_BMP ( 6 + F_JPGINC + F_TIFINC + F_PNGINC)
  370. +#define F_SUNRAS ( 7 + F_JPGINC + F_TIFINC + F_PNGINC)
  371. +#define F_IRIS ( 8 + F_JPGINC + F_TIFINC + F_PNGINC)
  372. +#define F_TARGA ( 9 + F_JPGINC + F_TIFINC + F_PNGINC)
  373. +#define F_FITS (10 + F_JPGINC + F_TIFINC + F_PNGINC)
  374. +#define F_PM (11 + F_JPGINC + F_TIFINC + F_PNGINC)
  375. +#define F_DELIM1 (12 + F_JPGINC + F_TIFINC + F_PNGINC) /* ----- */
  376. +#define F_FILELIST (13 + F_JPGINC + F_TIFINC + F_PNGINC)
  377. +#define F_MAXFMTS (14 + F_JPGINC + F_TIFINC + F_PNGINC) /* 17, normally */
  378. @@ -505,6 +516,7 @@
  379. #define RFT_XPM 17
  380. #define RFT_XWD 18
  381. #define RFT_FITS 19
  382. +#define RFT_PNG 20
  383. /* definitions for page up/down, arrow up/down list control */
  384. #define LS_PAGEUP 0
  385. @@ -765,9 +777,10 @@
  386. typedef struct { Window win; /* window ID */
  387. int x,y,w,h; /* window coords in parent */
  388. int active; /* true if can do anything*/
  389. - int min,max; /* min/max values 'pos' can take */
  390. - int val; /* 'value' of dial */
  391. - int page; /* amt val change on pageup/pagedown */
  392. + double min,max; /* min/max values 'pos' can take */
  393. + double val; /* 'value' of dial */
  394. + double inc; /* amt val change on up/down */
  395. + double page; /* amt val change on pageup/pagedown */
  396. char *title; /* title for this guage */
  397. char *units; /* string appended to value */
  398. u_long fg,bg,hi,lo; /* colors */
  399. @@ -1154,6 +1167,13 @@
  400. #endif
  401. +#ifdef HAVE_PNG
  402. +/* stuff used for 'png' box */
  403. +WHERE Window pngW;
  404. +WHERE int pngUp; /* is pngW mapped, or what? */
  405. +#endif
  406. +
  407. +
  408. #undef WHERE
  409. @@ -1465,12 +1485,12 @@
  410. /*************************** XVDIAL.C ***************************/
  411. -void DCreate PARM((DIAL *, Window, int, int, int, int, int,
  412. - int, int, int, u_long, u_long, u_long,
  413. - u_long, char *, char *));
  414. +void DCreate PARM((DIAL *, Window, int, int, int, int, double,
  415. + double, double, double, double, u_long,
  416. + u_long, u_long, u_long, char *, char *));
  417. -void DSetRange PARM((DIAL *, int, int, int, int));
  418. -void DSetVal PARM((DIAL *, int));
  419. +void DSetRange PARM((DIAL *, double,double,double,double,double));
  420. +void DSetVal PARM((DIAL *, double));
  421. void DSetActive PARM((DIAL *, int));
  422. void DRedraw PARM((DIAL *));
  423. int DTrack PARM((DIAL *, int, int));
  424. @@ -1612,6 +1632,13 @@
  425. void TIFFDialog PARM((int));
  426. int TIFFCheckEvent PARM((XEvent *));
  427. void TIFFSaveParams PARM((char *, int));
  428. +
  429. +/**************************** XVPNG.C ***************************/
  430. +int LoadPNG PARM((char *, PICINFO *));
  431. +void CreatePNGW PARM((void));
  432. +void PNGDialog PARM((int));
  433. +int PNGCheckEvent PARM((XEvent *));
  434. +void PNGSaveParams PARM((char *, int));
  435. /**************************** XVPDS.C ***************************/
  436. int LoadPDS PARM((char *, PICINFO *));
  437. diff -uNr xvbrowse.c xvbrowse.c
  438. --- ./xvbrowse.c Thu Jan 19 18:49:17 1995
  439. +++ ./xvbrowse.c Tue Feb 20 17:04:44 2001
  440. @@ -55,6 +55,7 @@
  441. #include "bits/br_xpm"
  442. #include "bits/br_xwd"
  443. #include "bits/br_fits"
  444. +#include "bits/br_png"
  445. #include "bits/br_trash"
  446. #include "bits/fcurs"
  447. @@ -94,7 +95,8 @@
  448. #define BF_XPM 25
  449. #define BF_XWD 26
  450. #define BF_FITS 27
  451. -#define BF_MAX 28 /* # of built-in icons */
  452. +#define BF_PNG 28
  453. +#define BF_MAX 29 /* # of built-in icons */
  454. #define ISLOADABLE(ftyp) (ftyp!=BF_DIR && ftyp!=BF_CHR && ftyp!=BF_BLK && \
  455. ftyp!=BF_SOCK && ftyp!=BF_FIFO)
  456. @@ -524,6 +526,7 @@
  457. bfIcons[BF_XPM] =MakePix1(br->win,br_xpm_bits, br_xpm_width, br_xpm_height);
  458. bfIcons[BF_XWD] =MakePix1(br->win,br_xwd_bits, br_xwd_width, br_xwd_height);
  459. bfIcons[BF_FITS]=MakePix1(br->win,br_fits_bits,br_fits_width,br_fits_height);
  460. + bfIcons[BF_PNG]=MakePix1(br->win,br_png_bits,br_png_width,br_png_height);
  461. /* check that they all got built */
  462. @@ -3020,6 +3023,7 @@
  463. case RFT_XPM: bf->ftype = BF_XPM; break;
  464. case RFT_XWD: bf->ftype = BF_XWD; break;
  465. case RFT_FITS: bf->ftype = BF_FITS; break;
  466. + case RFT_PNG: bf->ftype = BF_PNG; break;
  467. }
  468. }
  469. }
  470. @@ -3567,6 +3571,7 @@
  471. case RFT_XPM: strcat(str,"XPM file"); break;
  472. case RFT_XWD: strcat(str,"XWD file"); break;
  473. case RFT_FITS: strcat(str,"FITS file"); break;
  474. + case RFT_PNG: strcat(str,"PNG file"); break;
  475. default: strcat(str,"file of unknown type"); break;
  476. }
  477. diff -uNr xvdial.c xvdial.c
  478. --- ./xvdial.c Tue Jan 3 22:20:31 1995
  479. +++ ./xvdial.c Tue Feb 20 17:04:44 2001
  480. @@ -41,20 +41,21 @@
  481. /* local functions */
  482. -static int whereInDial PARM((DIAL *, int, int));
  483. -static void drawArrow PARM((DIAL *));
  484. -static void drawValStr PARM((DIAL *));
  485. -static void drawButt PARM((DIAL *, int, int));
  486. -static int computeDialVal PARM((DIAL *, int, int));
  487. -static void dimDial PARM((DIAL *));
  488. +static int whereInDial PARM((DIAL *, int, int));
  489. +static void drawArrow PARM((DIAL *));
  490. +static void drawValStr PARM((DIAL *));
  491. +static void drawButt PARM((DIAL *, int, int));
  492. +static double computeDialVal PARM((DIAL *, int, int));
  493. +static void dimDial PARM((DIAL *));
  494. /***************************************************/
  495. -void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, page,
  496. +void DCreate(dp, parent, x, y, w, h, minv, maxv, curv, inc, page,
  497. fg, bg, hi, lo, title, units)
  498. DIAL *dp;
  499. Window parent;
  500. -int x,y,w,h,minv,maxv,curv,page;
  501. +int x,y,w,h;
  502. +double minv,maxv,curv,inc,page;
  503. unsigned long fg,bg,hi,lo;
  504. char *title, *units;
  505. {
  506. @@ -98,18 +99,18 @@
  507. 1,fg,bg);
  508. if (!dp->win) FatalError("can't create dial window");
  509. - DSetRange(dp, minv, maxv, curv, page);
  510. + DSetRange(dp, minv, maxv, curv, inc, page);
  511. XSelectInput(theDisp, dp->win, ExposureMask | ButtonPressMask);
  512. }
  513. /***************************************************/
  514. -void DSetRange(dp, minv, maxv, curv, page)
  515. -DIAL *dp;
  516. -int minv, maxv, curv, page;
  517. +void DSetRange(dp, minv, maxv, curv, inc, page)
  518. +DIAL *dp;
  519. +double minv, maxv, curv, inc, page;
  520. {
  521. if (maxv<minv) maxv=minv;
  522. - dp->min = minv; dp->max = maxv; dp->page = page;
  523. + dp->min = minv; dp->max = maxv; dp->inc = inc; dp->page = page;
  524. dp->active = (minv < maxv);
  525. DSetVal(dp, curv);
  526. @@ -118,8 +119,8 @@
  527. /***************************************************/
  528. void DSetVal(dp, curv)
  529. -DIAL *dp;
  530. -int curv;
  531. +DIAL *dp;
  532. +double curv;
  533. {
  534. RANGE(curv, dp->min, dp->max); /* make sure curv is in-range */
  535. @@ -129,7 +130,7 @@
  536. XSetForeground(theDisp, theGC, dp->bg);
  537. drawArrow(dp);
  538. - dp->val = curv;
  539. + dp->val = (double)((int)(curv / dp->inc + (curv > 0 ? 0.5 : -0.5))) * dp->inc;
  540. /* draw new arrow and string */
  541. XSetForeground(theDisp, theGC, dp->fg);
  542. @@ -202,7 +203,8 @@
  543. int mx,my;
  544. {
  545. Window rW,cW;
  546. - int rx,ry, x,y, ipos, pos, lit, i, origval;
  547. + int rx, ry, x, y, ipos, pos, lit;
  548. + double origval;
  549. unsigned int mask;
  550. lit = 0;
  551. @@ -224,9 +226,9 @@
  552. if (ipos != INDIAL) {
  553. drawButt(dp, ipos, 1);
  554. switch (ipos) {
  555. - case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+1); break;
  556. + case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->inc); break;
  557. case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page); break;
  558. - case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-1); break;
  559. + case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->inc); break;
  560. case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page); break;
  561. }
  562. if (dp->drawobj != NULL) (dp->drawobj)();
  563. @@ -235,8 +237,9 @@
  564. }
  565. else {
  566. - i = computeDialVal(dp, mx, my);
  567. - DSetVal(dp, i);
  568. + double v;
  569. + v = computeDialVal(dp, mx, my);
  570. + DSetVal(dp, v);
  571. if (dp->drawobj != NULL) (dp->drawobj)();
  572. }
  573. @@ -246,11 +249,11 @@
  574. if (!(mask & Button1Mask)) break; /* button released */
  575. if (ipos == INDIAL) {
  576. - int j;
  577. - i = computeDialVal(dp, x, y);
  578. - j = dp->val;
  579. - DSetVal(dp, i);
  580. - if (j != dp->val) {
  581. + double v, w;
  582. + v = computeDialVal(dp, x, y);
  583. + w = dp->val;
  584. + DSetVal(dp, v);
  585. + if (w != dp->val) {
  586. /* track whatever dial controls */
  587. if (dp->drawobj != NULL) (dp->drawobj)();
  588. }
  589. @@ -266,11 +269,11 @@
  590. if (lit) {
  591. switch (ipos) {
  592. - case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+1);
  593. + case INCW1: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->inc);
  594. break;
  595. case INCW2: if (dp->val < dp->max) DSetVal(dp, dp->val+dp->page);
  596. break;
  597. - case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-1);
  598. + case INCCW1: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->inc);
  599. break;
  600. case INCCW2: if (dp->val > dp->min) DSetVal(dp, dp->val-dp->page);
  601. break;
  602. @@ -320,19 +323,20 @@
  603. static void drawArrow(dp)
  604. DIAL *dp;
  605. {
  606. - int i, rad, cx, cy;
  607. + int rad, cx, cy;
  608. + double v;
  609. XPoint arrow[4];
  610. rad = dp->rad; cx = dp->cx; cy = dp->cy;
  611. /* map pos (range minv..maxv) into degrees (range 240..-60) */
  612. - i = 240 + (-300 * (dp->val - dp->min)) / (dp->max - dp->min);
  613. - arrow[0].x = cx + (int) ((double) rad * .80 * cos(i * DEG2RAD));
  614. - arrow[0].y = cy - (int) ((double) rad * .80 * sin(i * DEG2RAD));
  615. - arrow[1].x = cx + (int) ((double) rad * .33 * cos((i+160) * DEG2RAD));
  616. - arrow[1].y = cy - (int) ((double) rad * .33 * sin((i+160) * DEG2RAD));
  617. - arrow[2].x = cx + (int) ((double) rad * .33 * cos((i-160) * DEG2RAD));
  618. - arrow[2].y = cy - (int) ((double) rad * .33 * sin((i-160) * DEG2RAD));
  619. + v = 240 + (-300 * (dp->val - dp->min)) / (dp->max - dp->min);
  620. + arrow[0].x = cx + (int) ((double) rad * .80 * cos(v * DEG2RAD));
  621. + arrow[0].y = cy - (int) ((double) rad * .80 * sin(v * DEG2RAD));
  622. + arrow[1].x = cx + (int) ((double) rad * .33 * cos((v+160) * DEG2RAD));
  623. + arrow[1].y = cy - (int) ((double) rad * .33 * sin((v+160) * DEG2RAD));
  624. + arrow[2].x = cx + (int) ((double) rad * .33 * cos((v-160) * DEG2RAD));
  625. + arrow[2].y = cy - (int) ((double) rad * .33 * sin((v-160) * DEG2RAD));
  626. arrow[3].x = arrow[0].x;
  627. arrow[3].y = arrow[0].y;
  628. XDrawLines(theDisp, dp->win, theGC, arrow, 4, CoordModeOrigin);
  629. @@ -343,23 +347,37 @@
  630. static void drawValStr(dp)
  631. DIAL *dp;
  632. {
  633. - int i, x1, x2;
  634. + int tot, i, x1, x2;
  635. char foo[60], foo1[60];
  636. /* compute longest string necessary so we can right-align this thing */
  637. - sprintf(foo,"%d",dp->min); x1 = strlen(foo);
  638. - sprintf(foo,"%d",dp->max); x2 = strlen(foo);
  639. + sprintf(foo,"%d",(int)dp->min); x1 = strlen(foo);
  640. + sprintf(foo,"%d",(int)dp->max); x2 = strlen(foo);
  641. if (dp->min < 0 && dp->max > 0) x2++; /* put '+' at beginning */
  642. i = x1; if (x2>x1) i = x2;
  643. if (dp->units) i += strlen(dp->units);
  644. - if (dp->min < 0 && dp->max > 0) sprintf(foo,"%+d", dp->val);
  645. - else sprintf(foo,"%d", dp->val);
  646. + sprintf(foo,"%g",dp->inc); /* space for decimal values */
  647. + tot = i + strlen(foo) - 1; /* Take away the 0 from the beginning */
  648. +
  649. + if (dp->min < 0.0 && dp->max > 0.0) sprintf(foo,"%+g", dp->val);
  650. + else sprintf(foo,"%g", dp->val);
  651. +
  652. + if (dp->inc < 1.0)
  653. + {
  654. + int j;
  655. +
  656. + if (dp->val == (double)((int)dp->val))
  657. + strcat(foo,".");
  658. +
  659. + for (j = strlen(foo); j < tot; j++)
  660. + strcat(foo,"0");
  661. + }
  662. if (dp->units) strcat(foo,dp->units);
  663. foo1[0] = '\0';
  664. if (strlen(foo) < (size_t) i) {
  665. - for (i = i - strlen(foo); i>0; i--) strcat(foo1," ");
  666. + for (i-=strlen(foo);i>0;i--) strcat(foo1," ");
  667. }
  668. strcat(foo1, foo);
  669. @@ -411,12 +429,13 @@
  670. /***************************************************/
  671. -static int computeDialVal(dp, x, y)
  672. +static double computeDialVal(dp, x, y)
  673. DIAL *dp;
  674. int x, y;
  675. {
  676. - int dx, dy, val;
  677. - double angle;
  678. + int dx, dy;
  679. +
  680. + double angle, val;
  681. /* compute dx, dy (distance from cx, cy). Note: +dy is *up* */
  682. dx = x - dp->cx; dy = dp->cy - y;
  683. @@ -436,8 +455,10 @@
  684. if (angle > 270.0) angle -= 360.0;
  685. if (angle < -90.0) angle += 360.0;
  686. - val = (int) ((dp->max - dp->min) * (240.0 - angle) / 300.0) + dp->min;
  687. + val = ((dp->max - dp->min) * (240.0 - angle) / 300.0) + dp->min;
  688. + /* round value to be an even multiple of dp->inc */
  689. + val = (double)((int)(val / dp->inc + 0.5)) * dp->inc;
  690. return val;
  691. }
  692. diff -uNr xvdir.c xvdir.c
  693. --- ./xvdir.c Tue Jan 3 22:21:39 1995
  694. +++ ./xvdir.c Tue Feb 20 17:04:44 2001
  695. @@ -62,6 +62,9 @@
  696. #ifdef HAVE_TIFF
  697. "TIFF",
  698. #endif
  699. +#ifdef HAVE_PNG
  700. + "PNG",
  701. +#endif
  702. "PostScript",
  703. "PBM/PGM/PPM (raw)",
  704. "PBM/PGM/PPM (ascii)",
  705. @@ -1115,6 +1118,15 @@
  706. }
  707. #endif
  708. +#ifdef HAVE_PNG
  709. + else if (fmt == F_PNG) { /* PNG */
  710. + PNGSaveParams(fullname, col);
  711. + PNGDialog(1); /* open PNG Dialog box */
  712. + dbut[S_BOK].lit = 0; BTRedraw(&dbut[S_BOK]);
  713. + return 0; /* always 'succeeds' */
  714. + }
  715. +#endif
  716. +
  717. @@ -1168,7 +1180,8 @@
  718. case F_XPM:
  719. rv = WriteXPM (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
  720. - fullname, picComments);
  721. + fullname, picComments);
  722. + break;
  723. case F_FITS:
  724. rv = WriteFITS (fp, thepic, ptype, w, h, rp, gp, bp, nc, col,
  725. picComments);
  726. @@ -1380,14 +1393,21 @@
  727. (strcmp(lowsuf,"eps" )==0) ||
  728. (strcmp(lowsuf,"rgb" )==0) ||
  729. (strcmp(lowsuf,"tga" )==0) ||
  730. - (strcmp(lowsuf,"xpm" )==0) ||
  731. (strcmp(lowsuf,"fits")==0) ||
  732. (strcmp(lowsuf,"fts" )==0) ||
  733. +#ifdef HAVE_JPEG
  734. (strcmp(lowsuf,"jpg" )==0) ||
  735. (strcmp(lowsuf,"jpeg")==0) ||
  736. (strcmp(lowsuf,"jfif")==0) ||
  737. +#endif
  738. +#ifdef HAVE_TIFF
  739. (strcmp(lowsuf,"tif" )==0) ||
  740. - (strcmp(lowsuf,"tiff")==0)) {
  741. + (strcmp(lowsuf,"tiff")==0) ||
  742. +#endif
  743. +#ifdef HAVE_PNG
  744. + (strcmp(lowsuf,"png" )==0) ||
  745. +#endif
  746. + (strcmp(lowsuf,"xpm" )==0)) {
  747. /* found one. set lowsuf = to the new suffix, and tack on to filename */
  748. @@ -1422,6 +1442,10 @@
  749. #ifdef HAVE_TIFF
  750. case F_TIFF: strcpy(lowsuf,"tif"); break;
  751. +#endif
  752. +
  753. +#ifdef HAVE_PNG
  754. + case F_PNG: strcpy(lowsuf,"png"); break;
  755. #endif
  756. }
  757. diff -uNr xvevent.c xvevent.c
  758. --- ./xvevent.c Tue Jan 24 00:20:24 1995
  759. +++ ./xvevent.c Tue Feb 20 17:04:44 2001
  760. @@ -154,7 +154,7 @@
  761. int *donep;
  762. {
  763. static int wasInfoUp=0, wasCtrlUp=0, wasDirUp=0, wasGamUp=0, wasPsUp=0;
  764. - static int wasJpegUp=0, wasTiffUp=0;
  765. + static int wasJpegUp=0, wasTiffUp=0, wasPngUp=0;
  766. static int mainWKludge=0; /* force first mainW expose after a mainW config
  767. to redraw all of mainW */
  768. @@ -233,6 +233,10 @@
  769. if (TIFFCheckEvent(event)) break; /* event has been processed */
  770. #endif
  771. +#ifdef HAVE_PNG
  772. + if (PNGCheckEvent (event)) break; /* event has been processed */
  773. +#endif
  774. +
  775. if (GamCheckEvent (event)) break; /* event has been processed */
  776. if (BrowseCheckEvent (event, &retval, &done)) break; /* event eaten */
  777. if (TextCheckEvent (event, &retval, &done)) break; /* event eaten */
  778. @@ -359,6 +363,10 @@
  779. else if (client_event->window == tiffW) TIFFDialog(0);
  780. #endif
  781. +#ifdef HAVE_PNG
  782. + else if (client_event->window == pngW) PNGDialog(0);
  783. +#endif
  784. +
  785. else if (client_event->window == mainW) Quit(0);
  786. }
  787. }
  788. @@ -538,6 +546,10 @@
  789. #ifdef HAVE_TIFF
  790. if (wasTiffUp) { TIFFDialog(wasTiffUp); wasTiffUp=0; }
  791. #endif
  792. +
  793. +#ifdef HAVE_PNG
  794. + if (wasPngUp) { PNGDialog(wasJpegUp); wasPngUp=0; }
  795. +#endif
  796. }
  797. }
  798. }
  799. @@ -576,6 +588,10 @@
  800. #ifdef HAVE_TIFF
  801. if (tiffUp) { wasTiffUp = tiffUp; TIFFDialog(0); }
  802. #endif
  803. +
  804. +#ifdef HAVE_PNG
  805. + if (pngUp) { wasPngUp = pngUp; PNGDialog(0); }
  806. +#endif
  807. }
  808. }
  809. }
  810. @@ -1147,6 +1163,10 @@
  811. if (TIFFCheckEvent(event)) break;
  812. #endif
  813. +#ifdef HAVE_PNG
  814. + if (PNGCheckEvent (event)) break;
  815. +#endif
  816. +
  817. if (GamCheckEvent (event)) break;
  818. if (BrowseCheckEvent (event, &retval, &done)) break;
  819. if (TextCheckEvent (event, &retval, &done)) break;
  820. @@ -1366,6 +1386,10 @@
  821. if (TIFFCheckEvent(event)) break;
  822. #endif
  823. +#ifdef HAVE_PNG
  824. + if (PNGCheckEvent (event)) break;
  825. +#endif
  826. +
  827. if (GamCheckEvent (event)) break;
  828. if (BrowseCheckEvent (event, &retval, &done)) break;
  829. if (TextCheckEvent (event, &retval, &done)) break;
  830. @@ -2370,6 +2394,10 @@
  831. #ifdef HAVE_TIFF
  832. if (tiffUp) TIFFDialog(0); /* close tiff window */
  833. +#endif
  834. +
  835. +#ifdef HAVE_PNG
  836. + if (pngUp) PNGDialog(0); /* close png window */
  837. #endif
  838. ClosePopUp();
  839. diff -uNr xvgam.c xvgam.c
  840. --- ./xvgam.c Fri Jan 13 20:51:14 1995
  841. +++ ./xvgam.c Tue Feb 20 17:04:44 2001
  842. @@ -265,11 +265,11 @@
  843. BTCreate(&gbut[G_BRNDCOL], cmapF, 5 + 66 + 67 + 2, 189, 66, BUTTH,
  844. "Random", infofg, infobg, hicol, locol);
  845. - DCreate(&rhDial, cmapF, 5, 215, 66, 100, 0,360,180, 5,
  846. + DCreate(&rhDial, cmapF, 5, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0,
  847. infofg, infobg, hicol, locol, "Hue", NULL);
  848. - DCreate(&gsDial, cmapF, 72, 215, 66, 100, 0,360,180, 5,
  849. + DCreate(&gsDial, cmapF, 72, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0,
  850. infofg, infobg, hicol, locol, "Sat.", NULL);
  851. - DCreate(&bvDial, cmapF, 139, 215, 66, 100, 0,360,180, 5,
  852. + DCreate(&bvDial, cmapF, 139, 215, 66, 100, 0.0, 360.0, 180.0, 1.0, 5.0,
  853. infofg, infobg, hicol, locol, "Value", NULL);
  854. rhDial.drawobj = gsDial.drawobj = bvDial.drawobj = dragEditColor;
  855. @@ -359,7 +359,7 @@
  856. srcHD.drawobj = dstHD.drawobj = whtHD.drawobj = dragHueDial;
  857. - DCreate(&satDial, hsvF, 100, 199, 100, 121, -100, 100, 0, 5,
  858. + DCreate(&satDial, hsvF, 100, 199, 100, 121, -100.0, 100.0, 0.0, 1.0, 5.0,
  859. infofg, infobg,hicol,locol, "Saturation", "%");
  860. hueRB = RBCreate(NULL, hsvF, 7, 153, "1",
  861. @@ -722,7 +722,7 @@
  862. if (whtHD.enabCB.val && whtHD.satval) hsvnonlinear++;
  863. - if (satDial.val != 0) hsvnonlinear++;
  864. + if (satDial.val != 0.0) hsvnonlinear++;
  865. /* check intensity graf */
  866. for (i=0; i<256 && intGraf.func[i]==i; i++);
  867. @@ -1291,14 +1291,14 @@
  868. rgb2hsv(rcmap[editColor], gcmap[editColor], bcmap[editColor], &h, &s, &v);
  869. if (h<0) h = 0;
  870. - DSetVal(&rhDial, (int) h);
  871. - DSetVal(&gsDial, (int) (s*100));
  872. - DSetVal(&bvDial, (int) (v*100));
  873. + DSetVal(&rhDial, h);
  874. + DSetVal(&gsDial, s*100);
  875. + DSetVal(&bvDial, v*100);
  876. }
  877. else {
  878. - DSetVal(&rhDial, rcmap[editColor]);
  879. - DSetVal(&gsDial, gcmap[editColor]);
  880. - DSetVal(&bvDial, bcmap[editColor]);
  881. + DSetVal(&rhDial, (double)rcmap[editColor]);
  882. + DSetVal(&gsDial, (double)gcmap[editColor]);
  883. + DSetVal(&bvDial, (double)bcmap[editColor]);
  884. }
  885. }
  886. @@ -1310,16 +1310,15 @@
  887. if (hsvmode) {
  888. int rv, gv, bv;
  889. - hsv2rgb((double) rhDial.val, ((double) gsDial.val) / 100.0,
  890. - ((double) bvDial.val) / 100.0, &rv, &gv, &bv);
  891. + hsv2rgb(rhDial.val, gsDial.val / 100.0, bvDial.val / 100.0, &rv, &gv, &bv);
  892. rcmap[editColor] = rv;
  893. gcmap[editColor] = gv;
  894. bcmap[editColor] = bv;
  895. }
  896. else {
  897. - rcmap[editColor] = rhDial.val;
  898. - gcmap[editColor] = gsDial.val;
  899. - bcmap[editColor] = bvDial.val;
  900. + rcmap[editColor] = (int)rhDial.val;
  901. + gcmap[editColor] = (int)gsDial.val;
  902. + bcmap[editColor] = (int)bvDial.val;
  903. }
  904. }
  905. @@ -1561,9 +1560,9 @@
  906. gsDial.title = "Green";
  907. bvDial.title = "Blue";
  908. - DSetRange(&rhDial, 0, 255, rcmap[editColor], 16);
  909. - DSetRange(&gsDial, 0, 255, gcmap[editColor], 16);
  910. - DSetRange(&bvDial, 0, 255, bcmap[editColor], 16);
  911. + DSetRange(&rhDial, 0.0, 255.0, (double)rcmap[editColor], 1.0, 16.0);
  912. + DSetRange(&gsDial, 0.0, 255.0, (double)gcmap[editColor], 1.0, 16.0);
  913. + DSetRange(&bvDial, 0.0, 255.0, (double)bcmap[editColor], 1.0, 16.0);
  914. XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial);
  915. XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial);
  916. @@ -1581,9 +1580,9 @@
  917. &h, &s, &v);
  918. if (h<0.0) h = 0.0;
  919. - DSetRange(&rhDial, 0, 360, (int) h, 5);
  920. - DSetRange(&gsDial, 0, 100, (int) (s*100), 5);
  921. - DSetRange(&bvDial, 0, 100, (int) (v*100), 5);
  922. + DSetRange(&rhDial, 0.0, 360.0, h, 1.0, 5.0);
  923. + DSetRange(&gsDial, 0.0, 100.0, s*100, 1.0, 5.0);
  924. + DSetRange(&bvDial, 0.0, 100.0, v*100, 1.0, 5.0);
  925. XClearWindow(theDisp, rhDial.win); DRedraw(&rhDial);
  926. XClearWindow(theDisp, gsDial.win); DRedraw(&gsDial);
  927. @@ -1891,7 +1890,7 @@
  928. }
  929. /* apply satDial value to s */
  930. - s = s + ((double) satDial.val) / 100.0;
  931. + s = s + satDial.val / 100.0;
  932. if (s<0.0) s = 0.0;
  933. if (s>1.0) s = 1.0;
  934. @@ -2007,7 +2006,7 @@
  935. gs->hueRBnum = RBWhich(hueRB);
  936. - gs->satval = satDial.val;
  937. + gs->satval = (int)satDial.val;
  938. GetGrafState(&intGraf,&gs->istate);
  939. GetGrafState(&rGraf, &gs->rstate);
  940. GetGrafState(&gGraf, &gs->gstate);
  941. @@ -2064,8 +2063,8 @@
  942. changed++;
  943. }
  944. - if (gs->satval != satDial.val) {
  945. - DSetVal(&satDial,gs->satval);
  946. + if (gs->satval != (int)satDial.val) {
  947. + DSetVal(&satDial,(double)gs->satval);
  948. changed++;
  949. }
  950. @@ -3200,7 +3199,7 @@
  951. if (whtHD.enabCB.val && whtHD.satval) hsvmod++;
  952. - if (satDial.val != 0) hsvmod++;
  953. + if (satDial.val != 0.0) hsvmod++;
  954. /* check intensity graf */
  955. for (i=0; i<256; i++) {
  956. @@ -3284,7 +3283,7 @@
  957. }
  958. /* apply satDial value to s */
  959. - s = s + satDial.val;
  960. + s = s + (int)satDial.val;
  961. if (s< 0) s = 0;
  962. if (s>100) s = 100;
  963. diff -uNr xvjpeg.c xvjpeg.c
  964. --- ./xvjpeg.c Thu Jan 5 09:17:13 1995
  965. +++ ./xvjpeg.c Tue Feb 20 17:49:14 2001
  966. @@ -12,8 +12,8 @@
  967. #include <setjmp.h>
  968. -#include "jpeglib.h"
  969. -#include "jerror.h"
  970. +#include <jpeglib.h>
  971. +#include <jerror.h>
  972. #define CREATOR_STR "CREATOR: "
  973. @@ -51,11 +51,11 @@
  974. static void clickJD PARM((int, int));
  975. static void doCmd PARM((int));
  976. static void writeJPEG PARM((void));
  977. -METHODDEF void xv_error_exit PARM((j_common_ptr));
  978. -METHODDEF void xv_error_output PARM((j_common_ptr));
  979. -METHODDEF void xv_prog_meter PARM((j_common_ptr));
  980. +METHODDEF(void) xv_error_exit PARM((j_common_ptr));
  981. +METHODDEF(void) xv_error_output PARM((j_common_ptr));
  982. +METHODDEF(void) xv_prog_meter PARM((j_common_ptr));
  983. static unsigned int j_getc PARM((j_decompress_ptr));
  984. -METHODDEF boolean xv_process_comment PARM((j_decompress_ptr));
  985. +METHODDEF(boolean) xv_process_comment PARM((j_decompress_ptr));
  986. static int writeJFIF PARM((FILE *, byte *, int,int,int));
  987. @@ -87,10 +87,10 @@
  988. XSelectInput(theDisp, jpegW, ExposureMask | ButtonPressMask | KeyPressMask);
  989. - DCreate(&qDial, jpegW, 10, 10, 80, 100, 1, 100, 75, 5,
  990. + DCreate(&qDial, jpegW, 10, 10, 80, 100, 1.0, 100.0, 75.0, 1.0, 5.0,
  991. infofg, infobg, hicol, locol, "Quality", "%");
  992. - DCreate(&smDial, jpegW, 120, 10, 80, 100, 0, 100, 0, 5,
  993. + DCreate(&smDial, jpegW, 120, 10, 80, 100, 0.0, 100.0, 0.0, 1.0, 5.0,
  994. infofg, infobg, hicol, locol, "Smoothing", "%");
  995. BTCreate(&jbut[J_BOK], jpegW, JWIDE-180-1, JHIGH-10-BUTTH-1, 80, BUTTH,
  996. @@ -400,7 +400,7 @@
  997. /**************************************************/
  998. -METHODDEF void xv_error_exit(cinfo)
  999. +METHODDEF (void) xv_error_exit(cinfo)
  1000. j_common_ptr cinfo;
  1001. {
  1002. my_error_ptr myerr;
  1003. @@ -412,7 +412,7 @@
  1004. /**************************************************/
  1005. -METHODDEF void xv_error_output(cinfo)
  1006. +METHODDEF (void) xv_error_output(cinfo)
  1007. j_common_ptr cinfo;
  1008. {
  1009. my_error_ptr myerr;
  1010. @@ -426,7 +426,7 @@
  1011. /**************************************************/
  1012. -METHODDEF void xv_prog_meter(cinfo)
  1013. +METHODDEF (void) xv_prog_meter(cinfo)
  1014. j_common_ptr cinfo;
  1015. {
  1016. struct jpeg_progress_mgr *prog;
  1017. @@ -671,7 +671,7 @@
  1018. /**************************************************/
  1019. -METHODDEF boolean xv_process_comment(cinfo)
  1020. +METHODDEF (boolean) xv_process_comment(cinfo)
  1021. j_decompress_ptr cinfo;
  1022. {
  1023. int length, hasnull;
  1024. @@ -759,8 +759,8 @@
  1025. jpeg_set_defaults(&cinfo);
  1026. - jpeg_set_quality(&cinfo, qDial.val, TRUE);
  1027. - cinfo.smoothing_factor = smDial.val;
  1028. + jpeg_set_quality(&cinfo, (int)qDial.val, TRUE);
  1029. + cinfo.smoothing_factor = (int)smDial.val;
  1030. jpeg_start_compress(&cinfo, TRUE);
  1031. @@ -769,7 +769,7 @@
  1032. /*** COMMENT HANDLING ***/
  1033. sprintf(xvcmt, "%sXV %s Quality = %d, Smoothing = %d\n",
  1034. - CREATOR_STR, REVDATE, qDial.val, smDial.val);
  1035. + CREATOR_STR, REVDATE, (int)qDial.val, (int)smDial.val);
  1036. if (picComments) { /* append XV comment */
  1037. char *sp, *sp1; int done;
  1038. diff -uNr xvmisc.c xvmisc.c
  1039. --- ./xvmisc.c Sat Jan 14 00:41:34 1995
  1040. +++ ./xvmisc.c Tue Feb 20 17:04:44 2001
  1041. @@ -520,6 +520,10 @@
  1042. if (tiffW) XDestroyWindow(theDisp, tiffW);
  1043. #endif
  1044. +#ifdef HAVE_PNG
  1045. + if (pngW) XDestroyWindow(theDisp, pngW);
  1046. +#endif
  1047. +
  1048. /* if NOT using stdcmap for images, free stdcmap */
  1049. if (colorMapMode != CM_STDCMAP) {
  1050. int j;
  1051. @@ -715,6 +719,10 @@
  1052. #ifdef HAVE_TIFF
  1053. if (tiffW) XDefineCursor(theDisp, tiffW, otherc);
  1054. +#endif
  1055. +
  1056. +#ifdef HAVE_PNG
  1057. + if (pngW) XDefineCursor(theDisp, pngW, otherc);
  1058. #endif
  1059. }
  1060. diff -uNr xvpng.c xvpng.c
  1061. --- ./xvpng.c Thu Jan 1 01:00:00 1970
  1062. +++ ./xvpng.c Tue Feb 20 17:49:44 2001
  1063. @@ -0,0 +1,965 @@
  1064. +/*
  1065. + * xvpng.c - load and write routines for 'PNG' format pictures
  1066. + *
  1067. + * callable functions
  1068. + *
  1069. + * CreatePNGW()
  1070. + * PNGDialog(vis)
  1071. + * PNGCheckEvent(xev)
  1072. + * PNGSaveParams(fname, col)
  1073. + * LoadPNG(fname, pinfo)
  1074. + */
  1075. +
  1076. +/*#include "copyright.h"*/
  1077. +/* (c) 1995 by Alexander Lehmann <lehmann@mathematik.th-darmstadt.de>
  1078. + * this file is a suplement to xv and is supplied under the same copying
  1079. + * conditions (except the shareware part)
  1080. + * Modified by Andreas Dilger <adilger@enel.ucalgary.ca> to fix
  1081. + * error handling for bad PNGs, add dialogs for interlacing and
  1082. + * compression selection, and upgrade to libpng-0.89
  1083. + * The copyright will be passed on to JB at some future point if he
  1084. + * so desires.
  1085. + */
  1086. +
  1087. +#include "xv.h"
  1088. +
  1089. +#ifdef HAVE_PNG
  1090. +
  1091. +#include <png.h>
  1092. +
  1093. +/*** Stuff for PNG Dialog box ***/
  1094. +#define PWIDE 318
  1095. +#define PHIGH 215
  1096. +
  1097. +#define DISPLAY_GAMMA 2.20 /* Default display gamma */
  1098. +/* Default zlib compression level
  1099. +#define COMPRESSION Z_BEST_COMPRESSION
  1100. +*/
  1101. +#define COMPRESSION 6
  1102. +
  1103. +#define DWIDE 86
  1104. +#define DHIGH 104
  1105. +#define PFX PWIDE-93
  1106. +#define PFY 44
  1107. +#define PFH 20
  1108. +
  1109. +#define P_BOK 0
  1110. +#define P_BCANC 1
  1111. +#define P_NBUTTS 2
  1112. +
  1113. +#define BUTTH 24
  1114. +
  1115. +/*** local functions ***/
  1116. +static void drawPD PARM((int, int, int, int));
  1117. +static void clickPD PARM((int, int));
  1118. +static void doCmd PARM((int));
  1119. +static void writePNG PARM((void));
  1120. +static int WritePNG PARM((FILE *, byte *, int, int, int,
  1121. + byte *, byte *, byte *, int));
  1122. +
  1123. +static void png_xv_error PARM((png_struct *png_ptr, char *message));
  1124. +static void png_xv_warning PARM((png_struct *png_ptr, char *message));
  1125. +
  1126. +/*** local variables ***/
  1127. +static char *filename;
  1128. +static char *fbasename;
  1129. +static int colorType;
  1130. +static int read_anything;
  1131. +static double Display_Gamma = DISPLAY_GAMMA;
  1132. +
  1133. +static DIAL cDial, gDial;
  1134. +static BUTT pbut[P_NBUTTS];
  1135. +static CBUTT interCB;
  1136. +static CBUTT FdefCB, FnoneCB, FsubCB, FupCB, FavgCB, FPaethCB;
  1137. +
  1138. +/**************************************************************************/
  1139. +/* PNG SAVE DIALOG ROUTINES ***********************************************/
  1140. +/**************************************************************************/
  1141. +
  1142. +
  1143. +/*******************************************/
  1144. +void CreatePNGW()
  1145. +{
  1146. + pngW = CreateWindow("xv png", "XVPNG", NULL,
  1147. + PWIDE, PHIGH, infofg, infobg, 0);
  1148. + if (!pngW) FatalError("can't create PNG window!");
  1149. +
  1150. + XSelectInput(theDisp, pngW, ExposureMask | ButtonPressMask | KeyPressMask);
  1151. +
  1152. + DCreate(&cDial, pngW, 12, 25, DWIDE, DHIGH, (double)Z_NO_COMPRESSION,
  1153. + (double)Z_BEST_COMPRESSION, COMPRESSION, 1.0, 2.0,
  1154. + infofg, infobg, hicol, locol, "Compression", NULL);
  1155. +
  1156. + DCreate(&gDial, pngW, DWIDE+27, 25, DWIDE, DHIGH, 1.0, 3.5,DISPLAY_GAMMA,0.01,0.2,
  1157. + infofg, infobg, hicol, locol, "Disp. Gamma", NULL);
  1158. +
  1159. + CBCreate(&interCB, pngW, DWIDE+30, DHIGH+3*LINEHIGH+2, "interlace",
  1160. + infofg, infobg, hicol, locol);
  1161. +
  1162. + CBCreate(&FdefCB, pngW, PFX, PFY, "Default",
  1163. + infofg, infobg, hicol, locol);
  1164. + FdefCB.val = 1;
  1165. +
  1166. + CBCreate(&FnoneCB, pngW, PFX, FdefCB.y + PFH + 4, "none",
  1167. + infofg, infobg, hicol, locol);
  1168. + CBCreate(&FsubCB, pngW, PFX, FnoneCB.y + PFH, "sub",
  1169. + infofg, infobg, hicol, locol);
  1170. + CBCreate(&FupCB, pngW, PFX, FsubCB.y + PFH, "up",
  1171. + infofg, infobg, hicol, locol);
  1172. + CBCreate(&FavgCB, pngW, PFX, FupCB.y + PFH, "average",
  1173. + infofg, infobg, hicol, locol);
  1174. + CBCreate(&FPaethCB, pngW, PFX, FavgCB.y + PFH, "Paeth",
  1175. + infofg, infobg, hicol, locol);
  1176. +
  1177. + FnoneCB.val = FsubCB.val = FupCB.val = FavgCB.val = FPaethCB.val = 1;
  1178. + CBSetActive(&FnoneCB, !FdefCB.val);
  1179. + CBSetActive(&FsubCB, !FdefCB.val);
  1180. + CBSetActive(&FupCB, !FdefCB.val);
  1181. + CBSetActive(&FavgCB, !FdefCB.val);
  1182. + CBSetActive(&FPaethCB, !FdefCB.val);
  1183. +
  1184. + BTCreate(&pbut[P_BOK], pngW, PWIDE-180-1, PHIGH-10-BUTTH-1, 80, BUTTH,
  1185. + "Ok", infofg, infobg, hicol, locol);
  1186. + BTCreate(&pbut[P_BCANC], pngW, PWIDE-90-1, PHIGH-10-BUTTH-1, 80, BUTTH,
  1187. + "Cancel", infofg, infobg, hicol, locol);
  1188. +
  1189. + XMapSubwindows(theDisp, pngW);
  1190. +}
  1191. +
  1192. +
  1193. +/*******************************************/
  1194. +void PNGDialog(vis)
  1195. + int vis;
  1196. +{
  1197. + if (vis) {
  1198. + CenterMapWindow(pngW, pbut[P_BOK].x + (int) pbut[P_BOK].w/2,
  1199. + pbut[P_BOK].y + (int) pbut[P_BOK].h/2,
  1200. + PWIDE, PHIGH);
  1201. + }
  1202. + else XUnmapWindow(theDisp, pngW);
  1203. + pngUp = vis;
  1204. +}
  1205. +
  1206. +
  1207. +/*******************************************/
  1208. +int PNGCheckEvent(xev)
  1209. + XEvent *xev;
  1210. +{
  1211. + /* check event to see if it's for one of our subwindows. If it is,
  1212. + deal accordingly, and return '1'. Otherwise, return '0' */
  1213. +
  1214. + int rv;
  1215. + rv = 1;
  1216. +
  1217. + if (!pngUp) return 0;
  1218. +
  1219. + if (xev->type == Expose) {
  1220. + int x,y,w,h;
  1221. + XExposeEvent *e = (XExposeEvent *) xev;
  1222. + x = e->x; y = e->y; w = e->width; h = e->height;
  1223. +
  1224. + /* throw away excess expose events for 'dumb' windows */
  1225. + if (e->count > 0 && (e->window == cDial.win)) {}
  1226. +
  1227. + else if (e->window == pngW) drawPD(x, y, w, h);
  1228. + else if (e->window == cDial.win) DRedraw(&cDial);
  1229. + else if (e->window == gDial.win) DRedraw(&gDial);
  1230. + else rv = 0;
  1231. + }
  1232. +
  1233. + else if (xev->type == ButtonPress) {
  1234. + XButtonEvent *e = (XButtonEvent *) xev;
  1235. + int x,y;
  1236. + x = e->x; y = e->y;
  1237. +
  1238. + if (e->button == Button1) {
  1239. + if (e->window == pngW) clickPD(x,y);
  1240. + else if (e->window == cDial.win) DTrack(&cDial,x,y);
  1241. + else if (e->window == gDial.win) DTrack(&gDial,x,y);
  1242. + else rv = 0;
  1243. + } /* button1 */
  1244. + else rv = 0;
  1245. + } /* button press */
  1246. +
  1247. + else if (xev->type == KeyPress) {
  1248. + XKeyEvent *e = (XKeyEvent *) xev;
  1249. + char buf[128]; KeySym ks;
  1250. + int stlen;
  1251. +
  1252. + stlen = XLookupString(e,buf,128,&ks,(XComposeStatus *) NULL);
  1253. + buf[stlen] = '\0';
  1254. +
  1255. + RemapKeyCheck(ks, buf, &stlen);
  1256. +
  1257. + if (e->window == pngW) {
  1258. + if (stlen) {
  1259. + if (buf[0] == '\r' || buf[0] == '\n') { /* enter */
  1260. + FakeButtonPress(&pbut[P_BOK]);
  1261. + }
  1262. + else if (buf[0] == '\033') { /* ESC */
  1263. + FakeButtonPress(&pbut[P_BCANC]);
  1264. + }
  1265. + }
  1266. + }
  1267. + else rv = 0;
  1268. + }
  1269. + else rv = 0;
  1270. +
  1271. + if (rv==0 && (xev->type == ButtonPress || xev->type == KeyPress)) {
  1272. + XBell(theDisp, 50);
  1273. + rv = 1; /* eat it */
  1274. + }
  1275. +
  1276. + return rv;
  1277. +}
  1278. +
  1279. +
  1280. +/*******************************************/
  1281. +void PNGSaveParams(fname, col)
  1282. + char *fname;
  1283. + int col;
  1284. +{
  1285. + filename = fname;
  1286. + colorType = col;
  1287. +}
  1288. +
  1289. +
  1290. +/*******************************************/
  1291. +static void drawPD(x, y, w, h)
  1292. + int x, y, w, h;
  1293. +{
  1294. + char *title = "Save PNG file...";
  1295. +
  1296. + char ctitle1[20];
  1297. + char *ctitle2 = "Useful range";
  1298. + char *ctitle3 = "is 2 - 7.";
  1299. + char *ctitle4 = "Uncompressed = 0";
  1300. +
  1301. + char *ftitle = "Row Filters:";
  1302. +
  1303. + char gtitle[20];
  1304. +
  1305. + int i;
  1306. + XRectangle xr;
  1307. +
  1308. + xr.x = x; xr.y = y; xr.width = w; xr.height = h;
  1309. + XSetClipRectangles(theDisp, theGC, 0,0, &xr, 1, Unsorted);
  1310. +
  1311. + XSetForeground(theDisp, theGC, infofg);
  1312. + XSetBackground(theDisp, theGC, infobg);
  1313. +
  1314. + for (i=0; i<P_NBUTTS; i++) BTRedraw(&pbut[i]);
  1315. +
  1316. + DrawString(pngW, 15, 6+ASCENT, title);
  1317. +
  1318. + sprintf(ctitle1, "Default = %d", COMPRESSION);
  1319. + DrawString(pngW, 18, 6+DHIGH+cDial.y+ASCENT, ctitle1);
  1320. + DrawString(pngW, 17, 6+DHIGH+cDial.y+ASCENT+LINEHIGH, ctitle2);
  1321. + DrawString(pngW, 17, 6+DHIGH+cDial.y+ASCENT+2*LINEHIGH, ctitle3);
  1322. + DrawString(pngW, 17, 6+DHIGH+cDial.y+ASCENT+3*LINEHIGH, ctitle4);
  1323. +
  1324. + sprintf(gtitle, "Default = %g", DISPLAY_GAMMA);
  1325. + DrawString(pngW, DWIDE+30, 6+DHIGH+gDial.y+ASCENT, gtitle);
  1326. +
  1327. + ULineString(pngW, FdefCB.x, FdefCB.y-3-DESCENT, ftitle);
  1328. + XDrawRectangle(theDisp, pngW, theGC, FdefCB.x-11, FdefCB.y-LINEHIGH-3,
  1329. + 93, 8*LINEHIGH+15);
  1330. + CBRedraw(&FdefCB);
  1331. + XDrawLine(theDisp, pngW, theGC, FdefCB.x-11, FdefCB.y+LINEHIGH+4,
  1332. + FdefCB.x+82, FdefCB.y+LINEHIGH+4);
  1333. +
  1334. + CBRedraw(&FnoneCB);
  1335. + CBRedraw(&FupCB);
  1336. + CBRedraw(&FsubCB);
  1337. + CBRedraw(&FavgCB);
  1338. + CBRedraw(&FPaethCB);
  1339. +
  1340. + CBRedraw(&interCB);
  1341. +
  1342. + XSetClipMask(theDisp, theGC, None);
  1343. +}
  1344. +
  1345. +
  1346. +/*******************************************/
  1347. +static void clickPD(x,y)
  1348. + int x,y;
  1349. +{
  1350. + int i;
  1351. + BUTT *bp;
  1352. +
  1353. + /* check BUTTs */
  1354. +
  1355. + for (i=0; i<P_NBUTTS; i++) {
  1356. + bp = &pbut[i];
  1357. + if (PTINRECT(x, y, bp->x, bp->y, bp->w, bp->h)) break;
  1358. + }
  1359. +
  1360. + if (i<P_NBUTTS) { /* found one */
  1361. + if (BTTrack(bp)) doCmd(i);
  1362. + }
  1363. +
  1364. + /* check CBUTTs */
  1365. +
  1366. + else if (CBClick(&FdefCB,x,y)) {
  1367. + int oldval = FdefCB.val;
  1368. +
  1369. + CBTrack(&FdefCB);
  1370. +
  1371. + if (oldval != FdefCB.val)
  1372. + {
  1373. + CBSetActive(&FnoneCB, !FdefCB.val);
  1374. + CBSetActive(&FsubCB, !FdefCB.val);
  1375. + CBSetActive(&FupCB, !FdefCB.val);
  1376. + CBSetActive(&FavgCB, !FdefCB.val);
  1377. + CBSetActive(&FPaethCB, !FdefCB.val);
  1378. +
  1379. + CBRedraw(&FnoneCB);
  1380. + CBRedraw(&FupCB);
  1381. + CBRedraw(&FsubCB);
  1382. + CBRedraw(&FavgCB);
  1383. + CBRedraw(&FPaethCB);
  1384. + }
  1385. + }
  1386. + else if (CBClick(&FnoneCB,x,y)) CBTrack(&FnoneCB);
  1387. + else if (CBClick(&FsubCB,x,y)) CBTrack(&FsubCB);
  1388. + else if (CBClick(&FupCB,x,y)) CBTrack(&FupCB);
  1389. + else if (CBClick(&FavgCB,x,y)) CBTrack(&FavgCB);
  1390. + else if (CBClick(&FPaethCB,x,y)) CBTrack(&FPaethCB);
  1391. + else if (CBClick(&interCB,x,y)) CBTrack(&interCB);
  1392. +}
  1393. +
  1394. +
  1395. +/*******************************************/
  1396. +static void doCmd(cmd)
  1397. + int cmd;
  1398. +{
  1399. + switch (cmd) {
  1400. + case P_BOK: {
  1401. + char *fullname;
  1402. +
  1403. + writePNG();
  1404. + PNGDialog(0);
  1405. +
  1406. + fullname = GetDirFullName();
  1407. + if (!ISPIPE(fullname[0])) {
  1408. + XVCreatedFile(fullname);
  1409. + StickInCtrlList(0);
  1410. + }
  1411. + }
  1412. + break;
  1413. +
  1414. + case P_BCANC: PNGDialog(0); break;
  1415. +
  1416. + default: break;
  1417. + }
  1418. +}
  1419. +
  1420. +
  1421. +/*******************************************/
  1422. +static void writePNG()
  1423. +{
  1424. + FILE *fp;
  1425. + int w, h, nc, rv, ptype, pfree;
  1426. + byte *inpix, *rmap, *gmap, *bmap;
  1427. +
  1428. + fp = OpenOutFile(filename);
  1429. + if (!fp) return;
  1430. +
  1431. + fbasename = BaseName(filename);
  1432. +
  1433. + WaitCursor();
  1434. + inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
  1435. +
  1436. + rv = WritePNG(fp, inpix, ptype, w, h, rmap, gmap, bmap, nc);
  1437. +
  1438. + SetCursors(-1);
  1439. +
  1440. + if (CloseOutFile(fp, filename, rv) == 0) DirBox(0);
  1441. +
  1442. + if (pfree) free(inpix);
  1443. +}
  1444. +
  1445. +
  1446. +/*******************************************/
  1447. +int WritePNG(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols)
  1448. + FILE *fp;
  1449. + byte *pic;
  1450. + int ptype, w, h;
  1451. + byte *rmap, *gmap, *bmap;
  1452. + int numcols;
  1453. +{
  1454. + png_struct *png_ptr;
  1455. + png_info *info_ptr;
  1456. + png_color palette[256];
  1457. + png_textp text;
  1458. + byte remap[256];
  1459. + int i, filter, linesize = 0, pass;
  1460. + byte *p, *png_line;
  1461. + char software[256];
  1462. + char *savecmnt = NULL;
  1463. +
  1464. + if ((png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
  1465. + png_xv_error, png_xv_warning)) == NULL) {
  1466. + FatalError("malloc failure in WritePNG");
  1467. + }
  1468. +
  1469. + if ((info_ptr = png_create_info_struct(png_ptr)) == NULL)
  1470. + {
  1471. + png_destroy_write_struct(&png_ptr, &info_ptr);
  1472. + FatalError("malloc failure in WritePNG");
  1473. + }
  1474. +
  1475. + if (setjmp(png_ptr->jmpbuf)) {
  1476. + png_destroy_write_struct(&png_ptr, &info_ptr);
  1477. + return -1;
  1478. + }
  1479. +
  1480. + png_init_io(png_ptr, fp);
  1481. +
  1482. + png_set_compression_level(png_ptr, (int)cDial.val);
  1483. +
  1484. + /* Don't bother filtering if we aren't compressing the image */
  1485. + if (FdefCB.val)
  1486. + {
  1487. + if ((int)cDial.val == 0)
  1488. + png_set_filter(png_ptr, 0, PNG_FILTER_NONE);
  1489. + }
  1490. + else
  1491. + {
  1492. + filter = FnoneCB.val ? PNG_FILTER_NONE : 0;
  1493. + filter |= FsubCB.val ? PNG_FILTER_SUB : 0;
  1494. + filter |= FupCB.val ? PNG_FILTER_UP : 0;
  1495. + filter |= FavgCB.val ? PNG_FILTER_AVG : 0;
  1496. + filter |= FPaethCB.val ? PNG_FILTER_PAETH : 0;
  1497. +
  1498. + png_set_filter(png_ptr, 0, filter);
  1499. + }
  1500. +
  1501. + info_ptr->width = w;
  1502. + info_ptr->height = h;
  1503. +
  1504. + info_ptr->interlace_type = interCB.val ? 1 : 0;
  1505. +
  1506. + if (colorType == F_FULLCOLOR || colorType == F_REDUCED) {
  1507. + if(ptype == PIC24) {
  1508. + linesize = 3*w;
  1509. + info_ptr->color_type = PNG_COLOR_TYPE_RGB;
  1510. + info_ptr->bit_depth = 8;
  1511. + } else {
  1512. + linesize = w;
  1513. + info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
  1514. + if(numcols <= 2)
  1515. + info_ptr->bit_depth = 1;
  1516. + else
  1517. + if(numcols <= 4)
  1518. + info_ptr->bit_depth = 2;
  1519. + else
  1520. + if(numcols <= 16)
  1521. + info_ptr->bit_depth = 4;
  1522. + else
  1523. + info_ptr->bit_depth = 8;
  1524. +
  1525. + for(i = 0; i < numcols; i++) {
  1526. + palette[i].red = rmap[i];
  1527. + palette[i].green = gmap[i];
  1528. + palette[i].blue = bmap[i];
  1529. + }
  1530. + info_ptr->num_palette = numcols;
  1531. + info_ptr->palette = palette;
  1532. + info_ptr->valid |= PNG_INFO_PLTE;
  1533. + }
  1534. + }
  1535. +
  1536. + else if(colorType == F_GREYSCALE || colorType == F_BWDITHER) {
  1537. + info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
  1538. + if(colorType == F_BWDITHER) {
  1539. + /* shouldn't happen */
  1540. + if (ptype == PIC24) FatalError("PIC24 and B/W Stipple in WritePNG()");
  1541. +
  1542. + info_ptr->bit_depth = 1;
  1543. + if(MONO(rmap[0], gmap[0], bmap[0]) > MONO(rmap[1], gmap[1], bmap[1])) {
  1544. + remap[0] = 1;
  1545. + remap[1] = 0;
  1546. + }
  1547. + else {
  1548. + remap[0] = 0;
  1549. + remap[1] = 1;
  1550. + }
  1551. + linesize = w;
  1552. + }
  1553. + else {
  1554. + if(ptype == PIC24) {
  1555. + linesize = w*3;
  1556. + info_ptr->bit_depth = 8;
  1557. + }
  1558. + else {
  1559. + int low_presc;
  1560. +
  1561. + linesize = w;
  1562. +
  1563. + for(i = 0; i < numcols; i++)
  1564. + remap[i] = MONO(rmap[i], gmap[i], bmap[i]);
  1565. +
  1566. + for(; i < 256; i++)
  1567. + remap[i]=0;
  1568. +
  1569. + info_ptr->bit_depth = 8;
  1570. +
  1571. + /* Note that this fails most of the time because of gamma */
  1572. + /* try to adjust to 4 bit prescision grayscale */
  1573. +
  1574. + low_presc=1;
  1575. +
  1576. + for(i = 0; i < numcols; i++) {
  1577. + if((remap[i] & 0x0f) * 0x11 != remap[i]) {
  1578. + low_presc = 0;
  1579. + break;
  1580. + }
  1581. + }
  1582. +
  1583. + if(low_presc) {
  1584. + for(i = 0; i < numcols; i++) {
  1585. + remap[i] &= 0xf;
  1586. + }
  1587. + info_ptr->bit_depth = 4;
  1588. +
  1589. + /* try to adjust to 2 bit prescision grayscale */
  1590. +
  1591. + for(i = 0; i < numcols; i++) {
  1592. + if((remap[i] & 0x03) * 0x05 != remap[i]) {
  1593. + low_presc = 0;
  1594. + break;
  1595. + }
  1596. + }
  1597. + }
  1598. +
  1599. + if(low_presc) {
  1600. + for(i = 0; i < numcols; i++) {
  1601. + remap[i] &= 3;
  1602. + }
  1603. + info_ptr->bit_depth = 2;
  1604. +
  1605. + /* try to adjust to 1 bit prescision grayscale */
  1606. +
  1607. + for(i = 0; i < numcols; i++) {
  1608. + if((remap[i] & 0x01) * 0x03 != remap[i]) {
  1609. + low_presc = 0;
  1610. + break;
  1611. + }
  1612. + }
  1613. + }
  1614. +
  1615. + if(low_presc) {
  1616. + for(i = 0; i < numcols; i++) {
  1617. + remap[i] &= 1;
  1618. + }
  1619. + info_ptr->bit_depth = 1;
  1620. + }
  1621. + }
  1622. + }
  1623. + }
  1624. +
  1625. + else
  1626. + png_error(png_ptr, "Unknown colorstyle in WritePNG");
  1627. +
  1628. + if ((text = (png_textp)malloc(sizeof(png_text)))) {
  1629. + sprintf(software, "XV %s", REVDATE);
  1630. +
  1631. + text->compression = -1;
  1632. + text->key = "Software";
  1633. + text->text = software;
  1634. + text->text_length = strlen(text->text);
  1635. +
  1636. + info_ptr->max_text = 1;
  1637. + info_ptr->num_text = 1;
  1638. + info_ptr->text = text;
  1639. + }
  1640. +
  1641. + Display_Gamma = gDial.val; /* Save the current gamma for loading */
  1642. +
  1643. + info_ptr->gamma = 1.0/gDial.val;
  1644. + info_ptr->valid |= PNG_INFO_gAMA;
  1645. +
  1646. + png_write_info(png_ptr, info_ptr);
  1647. +
  1648. + if(info_ptr->bit_depth < 8)
  1649. + png_set_packing(png_ptr);
  1650. +
  1651. + pass=png_set_interlace_handling(png_ptr);
  1652. +
  1653. + if((png_line = malloc(linesize)) == NULL)
  1654. + png_error(png_ptr, "cannot allocate temp image line");
  1655. +
  1656. + for(i = 0; i < pass; i++) {
  1657. + int j;
  1658. + p = pic;
  1659. + for(j = 0; j < h; j++) {
  1660. + fflush(stdout);
  1661. + if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
  1662. + int k;
  1663. + for(k = 0; k < w; k++)
  1664. + png_line[k] = ptype==PIC24 ? MONO(p[k*3], p[k*3+1], p[k*3+2]) :
  1665. + remap[p[k]];
  1666. + png_write_row(png_ptr, png_line);
  1667. + } else /* rbg or palette */
  1668. + png_write_row(png_ptr, p);
  1669. + if((j & 0x1f) == 0) WaitCursor();
  1670. + p += linesize;
  1671. + }
  1672. + }
  1673. +
  1674. + free(png_line);
  1675. +
  1676. + if (text)
  1677. + {
  1678. + if (picComments && strlen(picComments) &&
  1679. + (savecmnt = (char *)malloc((strlen(picComments) + 1)*sizeof(char)))) {
  1680. + png_textp tp;
  1681. + char *comment, *key;
  1682. +
  1683. + strcpy(savecmnt, picComments);
  1684. + key = savecmnt;
  1685. + tp = text;
  1686. + info_ptr->num_text = 0;
  1687. +
  1688. + comment = strchr(key, ':');
  1689. +
  1690. + do {
  1691. + /* Allocate a larger structure for comments if necessary */
  1692. + if (info_ptr->num_text >= info_ptr->max_text)
  1693. + {
  1694. + if ((tp =
  1695. + realloc(text, (info_ptr->num_text + 2)*sizeof(png_text))) == NULL)
  1696. + {
  1697. + break;
  1698. + }
  1699. + else
  1700. + {
  1701. + text = tp;
  1702. + tp = &text[info_ptr->num_text];
  1703. + info_ptr->max_text += 2;
  1704. + }
  1705. + }
  1706. +
  1707. + /* See if it looks like a PNG keyword from LoadPNG */
  1708. + if(comment && comment[1] == ':' && comment - key <= 80) {
  1709. + *(comment++) = '\0';
  1710. + *(comment++) = '\0';
  1711. +
  1712. + /* If the comment is the 'Software' chunk XV writes, we remove it,
  1713. + since we have already stored one */
  1714. + if (strcmp(key, "Software") == 0 && strncmp(comment, "XV", 2) == 0) {
  1715. + key = strchr(comment, '\n');
  1716. + if(key)
  1717. + key++; /* skip \n */
  1718. + comment = strchr(key, ':');
  1719. + }
  1720. + /* We have another keyword and/or comment to write out */
  1721. + else {
  1722. + tp->key = key;
  1723. + tp->text = comment;
  1724. +
  1725. + /* We have to find the end of this comment, and the next keyword
  1726. + if there is one */
  1727. + do {
  1728. + key = comment = strchr(comment, ':');
  1729. + } while (key && key[1] != ':');
  1730. +
  1731. + /* It looks like another keyword, go backward to the beginning */
  1732. + if (key) {
  1733. + while(key > tp->text && *key != '\n')
  1734. + key--;
  1735. +
  1736. + if (key > tp->text && comment - key <= 80) {
  1737. + *key = '\0';
  1738. + key++;
  1739. + }
  1740. + }
  1741. +
  1742. + tp->text_length = strlen(tp->text);
  1743. +
  1744. + /* We don't have another keyword, so remove the last newline */
  1745. + if (!key && tp->text[tp->text_length - 1] == '\n')
  1746. + {
  1747. + tp->text[tp->text_length] = '\0';
  1748. + tp->text_length--;
  1749. + }
  1750. +
  1751. + tp->compression = tp->text_length > 640 ? 0 : -1;
  1752. + info_ptr->num_text++;
  1753. + tp++;
  1754. + }
  1755. + }
  1756. + /* It is just a generic comment */
  1757. + else {
  1758. + tp->key = "Comment";
  1759. + tp->text = key;
  1760. + tp->text_length = strlen(tp->text);
  1761. + tp->compression = tp->text_length > 750 ? 0 : -1;
  1762. + info_ptr->num_text++;
  1763. + key = NULL;
  1764. + }
  1765. + } while (key && *key);
  1766. + }
  1767. + else
  1768. + {
  1769. + info_ptr->num_text = 0;
  1770. + }
  1771. + }
  1772. + info_ptr->text = text;
  1773. +
  1774. + png_convert_from_time_t(&(info_ptr->mod_time), time(NULL));
  1775. + info_ptr->valid |= PNG_INFO_tIME;
  1776. +
  1777. + png_write_end(png_ptr, info_ptr);
  1778. + png_destroy_write_struct(&png_ptr, &info_ptr);
  1779. +
  1780. + if (text)
  1781. + {
  1782. + free(text);
  1783. + if (savecmnt)
  1784. + free(savecmnt);
  1785. + }
  1786. +
  1787. + return 0;
  1788. +}
  1789. +
  1790. +
  1791. +/*******************************************/
  1792. +int LoadPNG(fname, pinfo)
  1793. + char *fname;
  1794. + PICINFO *pinfo;
  1795. +/*******************************************/
  1796. +{
  1797. + /* returns '1' on success */
  1798. +
  1799. + FILE *fp;
  1800. + png_struct *png_ptr;
  1801. + png_info *info_ptr;
  1802. + png_color_16 my_background;
  1803. + int i,j;
  1804. + int linesize;
  1805. + int filesize;
  1806. + int pass;
  1807. + size_t commentsize;
  1808. +
  1809. + fbasename = BaseName(fname);
  1810. +
  1811. + pinfo->pic = (byte *) NULL;
  1812. + pinfo->comment = (char *) NULL;
  1813. +
  1814. + read_anything=0;
  1815. +
  1816. + /* open the file */
  1817. + fp = xv_fopen(fname,"r");
  1818. + if (!fp)
  1819. + {
  1820. + SetISTR(ISTR_WARNING,"%s: can't open file", fname);
  1821. + return 0;
  1822. + }
  1823. +
  1824. + /* find the size of the file */
  1825. + fseek(fp, 0L, 2);
  1826. + filesize = ftell(fp);
  1827. + fseek(fp, 0L, 0);
  1828. +
  1829. + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
  1830. + png_xv_error, png_xv_warning);
  1831. + if(!png_ptr) {
  1832. + fclose(fp);
  1833. + FatalError("malloc failure in LoadPNG");
  1834. + }
  1835. +
  1836. + info_ptr = png_create_info_struct(png_ptr);
  1837. +
  1838. + if(!info_ptr) {
  1839. + fclose(fp);
  1840. + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
  1841. + FatalError("malloc failure in LoadPNG");
  1842. + }
  1843. +
  1844. + if(setjmp(png_ptr->jmpbuf)) {
  1845. + fclose(fp);
  1846. + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
  1847. + if(!read_anything) {
  1848. + if(pinfo->pic) {
  1849. + free(pinfo->pic);
  1850. + pinfo->pic = NULL;
  1851. + }
  1852. + if(pinfo->comment) {
  1853. + free(pinfo->comment);
  1854. + pinfo->comment = NULL;
  1855. + }
  1856. + }
  1857. + return read_anything;
  1858. + }
  1859. +
  1860. + png_init_io(png_ptr, fp);
  1861. + png_read_info(png_ptr, info_ptr);
  1862. +
  1863. + pinfo->w = pinfo->normw = info_ptr->width;
  1864. + pinfo->h = pinfo->normh = info_ptr->height;
  1865. +
  1866. + pinfo->frmType = F_PNG;
  1867. +
  1868. + sprintf(pinfo->fullInfo, "PNG, %d bit ",
  1869. + info_ptr->bit_depth * info_ptr->channels);
  1870. +
  1871. + switch(info_ptr->color_type) {
  1872. + case PNG_COLOR_TYPE_PALETTE:
  1873. + strcat(pinfo->fullInfo, "palette color");
  1874. + break;
  1875. +
  1876. + case PNG_COLOR_TYPE_GRAY:
  1877. + strcat(pinfo->fullInfo, "grayscale");
  1878. + break;
  1879. +
  1880. + case PNG_COLOR_TYPE_GRAY_ALPHA:
  1881. + strcat(pinfo->fullInfo, "grayscale+alpha");
  1882. + break;
  1883. +
  1884. + case PNG_COLOR_TYPE_RGB:
  1885. + strcat(pinfo->fullInfo, "truecolor");
  1886. + break;
  1887. +
  1888. + case PNG_COLOR_TYPE_RGB_ALPHA:
  1889. + strcat(pinfo->fullInfo, "truecolor+alpha");
  1890. + break;
  1891. + }
  1892. +
  1893. + sprintf(pinfo->fullInfo + strlen(pinfo->fullInfo),
  1894. + ", %sinterlaced. (%d bytes)",
  1895. + info_ptr->interlace_type ? "" : "non-", filesize);
  1896. +
  1897. + sprintf(pinfo->shrtInfo, "%dx%d PNG", info_ptr->width, info_ptr->height);
  1898. +
  1899. + if (info_ptr->bit_depth < 8)
  1900. + png_set_packing(png_ptr);
  1901. +
  1902. + if (info_ptr->valid & PNG_INFO_gAMA)
  1903. + png_set_gamma(png_ptr, Display_Gamma, info_ptr->gamma);
  1904. + else
  1905. + png_set_gamma(png_ptr, Display_Gamma, 0.45);
  1906. +
  1907. + if (info_ptr->valid & PNG_INFO_bKGD)
  1908. + png_set_background(png_ptr, &info_ptr->background,
  1909. + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
  1910. + else {
  1911. + my_background.red = my_background.green = my_background.blue =
  1912. + my_background.gray = 0;
  1913. + png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN,
  1914. + 0, Display_Gamma);
  1915. + }
  1916. +
  1917. + if (info_ptr->bit_depth == 16)
  1918. + png_set_strip_16(png_ptr);
  1919. +
  1920. + if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
  1921. + info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
  1922. + {
  1923. + if (info_ptr->bit_depth == 1)
  1924. + pinfo->colType = F_BWDITHER;
  1925. + else
  1926. + pinfo->colType = F_GREYSCALE;
  1927. + png_set_expand(png_ptr);
  1928. + }
  1929. +
  1930. + pass=png_set_interlace_handling(png_ptr);
  1931. +
  1932. + png_read_update_info(png_ptr, info_ptr);
  1933. +
  1934. + if(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
  1935. + info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
  1936. + linesize = pinfo->w * 3;
  1937. + pinfo->colType = F_FULLCOLOR;
  1938. + pinfo->type = PIC24;
  1939. + } else {
  1940. + linesize = pinfo->w;
  1941. + pinfo->type = PIC8;
  1942. + if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
  1943. + info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
  1944. + for(i = 0; i < 256; i++)
  1945. + pinfo->r[i] = pinfo->g[i] = pinfo->b[i] = i;
  1946. + } else {
  1947. + pinfo->colType = F_FULLCOLOR;
  1948. + for(i = 0; i < info_ptr->num_palette; i++) {
  1949. + pinfo->r[i] = info_ptr->palette[i].red;
  1950. + pinfo->g[i] = info_ptr->palette[i].green;
  1951. + pinfo->b[i] = info_ptr->palette[i].blue;
  1952. + }
  1953. + }
  1954. + }
  1955. + pinfo->pic = calloc((size_t)(linesize*pinfo->h), (size_t)1);
  1956. +
  1957. + if(!pinfo->pic) {
  1958. + png_error(png_ptr, "can't allocate space for PNG image");
  1959. + }
  1960. +
  1961. + png_start_read_image(png_ptr);
  1962. +
  1963. + for(i = 0; i < pass; i++) {
  1964. + byte *p = pinfo->pic;
  1965. + for(j = 0; j < pinfo->h; j++) {
  1966. + png_read_row(png_ptr, p, NULL);
  1967. + read_anything = 1;
  1968. + if((j & 0x1f) == 0) WaitCursor();
  1969. + p += linesize;
  1970. + }
  1971. + }
  1972. +
  1973. + png_read_end(png_ptr, info_ptr);
  1974. +
  1975. + if(info_ptr->num_text > 0) {
  1976. + commentsize = 1;
  1977. +
  1978. + for(i = 0; i < info_ptr->num_text; i++)
  1979. + commentsize += strlen(info_ptr->text[i].key) + 1 +
  1980. + info_ptr->text[i].text_length + 2;
  1981. +
  1982. + if((pinfo->comment = malloc(commentsize)) == NULL) {
  1983. + png_warning(png_ptr,"can't allocate comment string");
  1984. + }
  1985. + else {
  1986. + pinfo->comment[0] = '\0';
  1987. + for(i = 0; i < info_ptr->num_text; i++) {
  1988. + strcat(pinfo->comment, info_ptr->text[i].key);
  1989. + strcat(pinfo->comment, "::");
  1990. + strcat(pinfo->comment, info_ptr->text[i].text);
  1991. + strcat(pinfo->comment, "\n");
  1992. + }
  1993. + }
  1994. + }
  1995. +
  1996. + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
  1997. +
  1998. + fclose(fp);
  1999. +
  2000. + return 1;
  2001. +}
  2002. +
  2003. +
  2004. +/*******************************************/
  2005. +static void
  2006. +png_xv_error(png_ptr, message)
  2007. + png_struct *png_ptr;
  2008. + char *message;
  2009. +{
  2010. + SetISTR(ISTR_WARNING,"%s: libpng error: %s", fbasename, message);
  2011. +
  2012. + longjmp(png_ptr->jmpbuf, 1);
  2013. +}
  2014. +
  2015. +
  2016. +/*******************************************/
  2017. +static void
  2018. +png_xv_warning(png_ptr, message)
  2019. + png_struct *png_ptr;
  2020. + char *message;
  2021. +{
  2022. + if (!png_ptr)
  2023. + return;
  2024. +
  2025. + SetISTR(ISTR_WARNING,"%s: libpng warning: %s", fbasename, message);
  2026. +}
  2027. +
  2028. +#endif
  2029. diff -uNr xvpopup.c xvpopup.c
  2030. --- ./xvpopup.c Thu Jan 19 19:09:31 1995
  2031. +++ ./xvpopup.c Tue Feb 20 17:04:44 2001
  2032. @@ -200,14 +200,14 @@
  2033. if (!padHaveDooDads) {
  2034. DCreate(&padWDial, popW, 16, puhigh-16-100-1,75,100,
  2035. - 1, 2048, pWIDE, 10,
  2036. + 1.0, 2048.0, (double)pWIDE, 1.0, 10.0,
  2037. infofg, infobg, hicol, locol, "Width", NULL);
  2038. DCreate(&padHDial, popW, 16+1+75, puhigh-16-100-1,75,100,
  2039. - 1, 2048, pHIGH, 10,
  2040. + 1.0, 2048.0, (double)pHIGH, 1.0, 10.0,
  2041. infofg, infobg, hicol, locol, "Height", NULL);
  2042. DCreate(&padODial, popW, 16+1+75+75+9, puhigh-16-100-1,75,100,
  2043. - 0, 100, 100, 10,
  2044. + 0.0, 100.0, 100.0, 1.0, 10.0,
  2045. infofg, infobg, hicol, locol, "Opaque", NULL);
  2046. MBCreate(&padMthdMB, popW, 100-2+44, 10, 140, 19, NULL,
  2047. @@ -258,9 +258,9 @@
  2048. else if (poptyp == ISPAD) {
  2049. BTSetActive(&bts[0], (int) strlen(gsBuf));
  2050. i = pWIDE * 3; RANGE(i,2048,9999);
  2051. - DSetRange(&padWDial, 1, i, padWDial.val, 10);
  2052. + DSetRange(&padWDial, 1.0, (double)i, padWDial.val, 1.0, 10.0);
  2053. i = pHIGH * 3; RANGE(i,2048,9999);
  2054. - DSetRange(&padHDial, 1, i, padHDial.val, 10);
  2055. + DSetRange(&padHDial, 1.0, (double)i, padHDial.val, 1.0, 10.0);
  2056. DSetActive(&padWDial, (padMode!=PAD_LOAD)); /* DSetRange activates dial */
  2057. DSetActive(&padHDial, (padMode!=PAD_LOAD));
  2058. @@ -465,9 +465,9 @@
  2059. changedGSBuf(); /* careful! popW doesn't exist yet! */
  2060. if (padHaveDooDads) {
  2061. - oldW = padWDial.val;
  2062. - oldH = padHDial.val;
  2063. - oldO = padODial.val;
  2064. + oldW = (int)padWDial.val;
  2065. + oldH = (int)padHDial.val;
  2066. + oldO = (int)padODial.val;
  2067. }
  2068. else { oldW = pWIDE; oldH = pHIGH; oldO = 100; }
  2069. @@ -486,9 +486,9 @@
  2070. }
  2071. if (rv == 1) { /* cancelled: restore normal values */
  2072. - DSetVal(&padWDial, oldW);
  2073. - DSetVal(&padHDial, oldH);
  2074. - DSetVal(&padODial, oldO);
  2075. + DSetVal(&padWDial, (double)oldW);
  2076. + DSetVal(&padHDial, (double)oldH);
  2077. + DSetVal(&padODial, (double)oldO);
  2078. }
  2079. XUnmapWindow(theDisp, padWDial.win);
  2080. @@ -498,9 +498,9 @@
  2081. /* load up return values */
  2082. *pMode = padMode;
  2083. *pStr = padBuf;
  2084. - *pWide = padWDial.val;
  2085. - *pHigh = padHDial.val;
  2086. - *pOpaque = padODial.val;
  2087. + *pWide = (int)padWDial.val;
  2088. + *pHigh = (int)padHDial.val;
  2089. + *pOpaque = (int)padODial.val;
  2090. *pOmode = padOMode;
  2091. return rv;
  2092. @@ -972,8 +972,8 @@
  2093. else if (popUp == ISPAD) {
  2094. if (PTINRECT(x, y, padDButt.x, padDButt.y, padDButt.w, padDButt.h)) {
  2095. if (BTTrack(&padDButt)) {
  2096. - DSetVal(&padWDial, pWIDE);
  2097. - DSetVal(&padHDial, pHIGH);
  2098. + DSetVal(&padWDial, (double)pWIDE);
  2099. + DSetVal(&padHDial, (double)pHIGH);
  2100. }
  2101. }
  2102. diff -uNr xvps.c xvps.c
  2103. --- ./xvps.c Thu Dec 22 23:34:42 1994
  2104. +++ ./xvps.c Tue Feb 20 17:04:44 2001
  2105. @@ -139,9 +139,9 @@
  2106. CBCreate(&encapsCB, psW, 240, 7, "preview", infofg, infobg, hicol, locol);
  2107. CBCreate(&pscompCB, psW, 331, 7, "compress", infofg, infobg, hicol, locol);
  2108. - DCreate(&xsDial, psW, 240, 30, 80, 100, 10, 800, 100, 5,
  2109. + DCreate(&xsDial, psW, 240, 30, 80, 100, 10.0, 800.0, 100.0, 0.5, 5.0,
  2110. infofg, infobg, hicol, locol, "Width", "%");
  2111. - DCreate(&ysDial, psW, 331, 30, 80, 100, 10, 800, 100, 5,
  2112. + DCreate(&ysDial, psW, 331, 30, 80, 100, 10.0, 800.0, 100.0, 0.5, 5.0,
  2113. infofg, infobg, hicol, locol, "Height", "%");
  2114. xsDial.drawobj = changedScale;
  2115. ysDial.drawobj = changedScale;
  2116. @@ -236,10 +236,10 @@
  2117. if (rd_int("psres")) { /* xv.psres: default paper resolution */
  2118. if (def_int >= 10 && def_int <= 720) {
  2119. - int i = (int) ((PIX2INCH * 100) / def_int);
  2120. + double v = (PIX2INCH * 100) / def_int;
  2121. - DSetVal(&xsDial, i);
  2122. - DSetVal(&ysDial, i);
  2123. + DSetVal(&xsDial, v);
  2124. + DSetVal(&ysDial, v);
  2125. }
  2126. }
  2127. @@ -836,7 +836,7 @@
  2128. if (scx < scy) { sz_iny = h * scx; }
  2129. else { sz_inx = w * scy; }
  2130. - DSetVal(&xsDial, (int) ((100 * (sz_inx * PIX2INCH) / w) + .5));
  2131. + DSetVal(&xsDial, 100 * (sz_inx * PIX2INCH) / w);
  2132. DSetVal(&ysDial, xsDial.val);
  2133. sz_inx = (double) w / PIX2INCH * (xsDial.val / 100.0);
  2134. diff -uNr xvtiff.c xvtiff.c
  2135. --- ./xvtiff.c Fri Jan 13 20:53:34 1995
  2136. +++ ./xvtiff.c Tue Feb 20 17:50:02 2001
  2137. @@ -12,7 +12,7 @@
  2138. #ifdef HAVE_TIFF
  2139. -#include "tiffio.h" /* has to be after xv.h, as it needs varargs/stdarg */
  2140. +#include <tiffio.h> /* has to be after xv.h, as it needs varargs/stdarg */
  2141. static byte *loadPalette PARM((TIFF *, uint32, uint32, int, int, PICINFO *));
  2142. @@ -186,7 +186,7 @@
  2143. break;
  2144. }
  2145. - sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
  2146. + sprintf(pinfo->shrtInfo, "%lux%lu TIFF.",w,h);
  2147. pic8 = (byte *) malloc((size_t) w*h);
  2148. if (!pic8) FatalError("loadPalette() - couldn't malloc 'pic8'");
  2149. @@ -214,7 +214,7 @@
  2150. "???"),
  2151. filesize);
  2152. - sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
  2153. + sprintf(pinfo->shrtInfo, "%lux%lu TIFF.",w,h);
  2154. /* allocate 24-bit image */
  2155. pic24 = (byte *) malloc((size_t) w*h*3);
  2156. @@ -301,10 +301,10 @@
  2157. static byte **BWmap;
  2158. static byte **PALmap;
  2159. -typedef void (*tileContigRoutine) PARM((byte*, u_char*, RGBvalue*,
  2160. +typedef void (*xvtileContigRoutine) PARM((byte*, u_char*, RGBvalue*,
  2161. uint32, uint32, int, int));
  2162. -typedef void (*tileSeparateRoutine) PARM((byte*, u_char*, u_char*, u_char*,
  2163. +typedef void (*xvtileSeparateRoutine) PARM((byte*, u_char*, u_char*, u_char*,
  2164. RGBvalue*, uint32, uint32, int, int));
  2165. @@ -366,8 +366,8 @@
  2166. static void putcontig8bitYCbCrtile PARM((byte *, u_char *, RGBvalue *,
  2167. uint32, uint32, int, int));
  2168. -static tileContigRoutine pickTileContigCase PARM((RGBvalue *));
  2169. -static tileSeparateRoutine pickTileSeparateCase PARM((RGBvalue *));
  2170. +static xvtileContigRoutine pickTileContigCase PARM((RGBvalue *));
  2171. +static xvtileSeparateRoutine pickTileSeparateCase PARM((RGBvalue *));
  2172. /*******************************************/
  2173. @@ -641,7 +641,7 @@
  2174. u_char *buf;
  2175. int fromskew, toskew;
  2176. u_int nrow;
  2177. - tileContigRoutine put;
  2178. + xvtileContigRoutine put;
  2179. put = pickTileContigCase(Map);
  2180. if (put == 0) return (0);
  2181. @@ -708,7 +708,7 @@
  2182. int tilesize;
  2183. int fromskew, toskew;
  2184. u_int nrow;
  2185. - tileSeparateRoutine put;
  2186. + xvtileSeparateRoutine put;
  2187. put = pickTileSeparateCase(Map);
  2188. if (put == 0) return (0);
  2189. @@ -779,7 +779,7 @@
  2190. {
  2191. uint32 row, y, nrow;
  2192. u_char *buf;
  2193. - tileContigRoutine put;
  2194. + xvtileContigRoutine put;
  2195. uint32 rowsperstrip;
  2196. uint32 imagewidth;
  2197. int scanline;
  2198. @@ -832,7 +832,7 @@
  2199. u_char *r, *g, *b;
  2200. uint32 row, y, nrow;
  2201. int scanline;
  2202. - tileSeparateRoutine put;
  2203. + xvtileSeparateRoutine put;
  2204. uint32 rowsperstrip;
  2205. uint32 imagewidth;
  2206. u_int stripsize;
  2207. @@ -1065,7 +1065,7 @@
  2208. int fromskew, toskew;
  2209. {
  2210. while (h-- > 0) {
  2211. - UNROLL8(w,0, *cp++ = PALmap[*pp++][0]);
  2212. + UNROLL8(w,, *cp++ = PALmap[*pp++][0]);
  2213. cp += toskew;
  2214. pp += fromskew;
  2215. }
  2216. @@ -1262,7 +1262,7 @@
  2217. }
  2218. } else {
  2219. while (h-- > 0) {
  2220. - UNROLL8(w,0,
  2221. + UNROLL8(w,,
  2222. *cp++ = pp[0];
  2223. *cp++ = pp[1];
  2224. *cp++ = pp[2];
  2225. @@ -1335,7 +1335,7 @@
  2226. }
  2227. } else {
  2228. while (h-- > 0) {
  2229. - UNROLL8(w,0,
  2230. + UNROLL8(w,,
  2231. *cp++ = *r++;
  2232. *cp++ = *g++;
  2233. *cp++ = *b++;
  2234. @@ -1489,16 +1489,16 @@
  2235. /*
  2236. * Select the appropriate conversion routine for packed data.
  2237. */
  2238. -static tileContigRoutine pickTileContigCase(Map)
  2239. +static xvtileContigRoutine pickTileContigCase(Map)
  2240. RGBvalue* Map;
  2241. {
  2242. - tileContigRoutine put = 0;
  2243. + xvtileContigRoutine put = 0;
  2244. switch (photometric) {
  2245. case PHOTOMETRIC_RGB:
  2246. switch (bitspersample) {
  2247. - case 8: put = (tileContigRoutine) putRGBcontig8bittile; break;
  2248. - case 16: put = (tileContigRoutine) putRGBcontig16bittile; break;
  2249. + case 8: put = putRGBcontig8bittile; break;
  2250. + case 16: put = (xvtileContigRoutine)putRGBcontig16bittile; break;
  2251. }
  2252. break;
  2253. @@ -1540,16 +1540,16 @@
  2254. * NB: we assume that unpacked single channel data is directed
  2255. * to the "packed routines.
  2256. */
  2257. -static tileSeparateRoutine pickTileSeparateCase(Map)
  2258. +static xvtileSeparateRoutine pickTileSeparateCase(Map)
  2259. RGBvalue* Map;
  2260. {
  2261. - tileSeparateRoutine put = 0;
  2262. + xvtileSeparateRoutine put = 0;
  2263. switch (photometric) {
  2264. case PHOTOMETRIC_RGB:
  2265. switch (bitspersample) {
  2266. - case 8: put = (tileSeparateRoutine) putRGBseparate8bittile; break;
  2267. - case 16: put = (tileSeparateRoutine) putRGBseparate16bittile; break;
  2268. + case 8: put = (xvtileSeparateRoutine) putRGBseparate8bittile; break;
  2269. + case 16: put = (xvtileSeparateRoutine) putRGBseparate16bittile; break;
  2270. }
  2271. break;
  2272. }
  2273. diff -uNr xvtiffwr.c xvtiffwr.c
  2274. --- ./xvtiffwr.c Tue Jan 3 22:28:13 1995
  2275. +++ ./xvtiffwr.c Tue Feb 20 17:50:12 2001
  2276. @@ -9,7 +9,7 @@
  2277. #ifdef HAVE_TIFF
  2278. -#include "tiffio.h" /* has to be after xv.h, as it needs varargs/stdarg */
  2279. +#include <tiffio.h> /* has to be after xv.h, as it needs varargs/stdarg */
  2280. #define ALLOW_JPEG 0 /* set to '1' to allow 'JPEG' choice in dialog box */