Add contrib/pngminim/preader

based on contrib/gregbook/rpng2-x
diff --git a/ANNOUNCE b/ANNOUNCE
index 5109842..7a1d907 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -457,6 +457,8 @@
 version 1.4.0beta60 [May 18, 2009]
   Conditionally compile png_read_finish_row() which is not used by
     progressive readers.
+  Added contrib/pngminim/preader to demonstrate building minimal progressive
+    decoder, based on contrib/gregbook with embedded libpng and zlib.
 
 version 1.4.0betaN [future]
   Build shared libraries with -lz and sometimes -lm.
diff --git a/CHANGES b/CHANGES
index 3674958..a16af78 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2134,6 +2134,8 @@
 version 1.4.0beta60 [May 18, 2009]
   Conditionally compile png_read_finish_row() which is not used by
     progressive readers.
+  Added contrib/pngminim/preader to demonstrate building minimal progressive
+    decoder, based on contrib/gregbook with embedded libpng and zlib.
 
 version 1.4.0betaN [future]
   Build shared libraries with -lz and sometimes -lm.
diff --git a/contrib/pngminim/decoder/pngusr.h b/contrib/pngminim/decoder/pngusr.h
index d0b1220..74b97b8 100644
--- a/contrib/pngminim/decoder/pngusr.h
+++ b/contrib/pngminim/decoder/pngusr.h
@@ -7,6 +7,10 @@
 #ifndef MINRDPNGCONF_H
 #define MINRDPNGCONF_H
 
+#ifdef NJET
+  /* No 16-bit support beyond reading with strip_16 */
+#endif
+
 #define PNG_NO_GLOBAL_ARRAYS
 
 #define PNG_NO_WARNINGS
@@ -40,6 +44,7 @@
 #define PNG_NO_READ_sBIT
 #define PNG_NO_READ_sCAL
 #define PNG_NO_READ_sPLT
+#define PNG_NO_READ_sRGB
 #define PNG_NO_READ_TEXT
 #define PNG_NO_READ_tIME
 #define PNG_NO_READ_UNKNOWN_CHUNKS
@@ -49,7 +54,6 @@
 #define PNG_NO_READ_STRIP_ALPHA
 #define PNG_NO_READ_oFFs
 #define PNG_NO_WARN_UNINITIALIZED_ROW
-#define PNG_NO_READ_PREMULTIPLY_ALPHA
 
 #define PNG_NO_WRITE_SUPPORTED
 
diff --git a/contrib/pngminim/encoder/pngusr.h b/contrib/pngminim/encoder/pngusr.h
index 18989d1..7c1627c 100644
--- a/contrib/pngminim/encoder/pngusr.h
+++ b/contrib/pngminim/encoder/pngusr.h
@@ -33,7 +33,6 @@
 #define PNG_NO_WRITE_bKGD
 #define PNG_NO_WRITE_cHRM
 #define PNG_NO_WRITE_gAMA
-#define PNG_NO_WRITE_sRGB
 #define PNG_NO_WRITE_hIST
 #define PNG_NO_WRITE_iCCP
 #define PNG_NO_WRITE_oFFs
@@ -42,6 +41,7 @@
 #define PNG_NO_WRITE_sBIT
 #define PNG_NO_WRITE_sCAL
 #define PNG_NO_WRITE_sPLT
+#define PNG_NO_WRITE_sRGB
 #define PNG_NO_WRITE_TEXT
 #define PNG_NO_WRITE_tIME
 #define PNG_NO_WRITE_UNKNOWN_CHUNKS
diff --git a/contrib/pngminim/preader/README b/contrib/pngminim/preader/README
new file mode 100644
index 0000000..8a649a1
--- /dev/null
+++ b/contrib/pngminim/preader/README
@@ -0,0 +1,10 @@
+This demonstrates the use of PNG_USER_CONFIG and pngusr.h
+
+To build a minimal read-only progressive decoder with X display, run
+gather.sh to collect needed files from gregbook, libpng, and zlib
+
+Edit makefile.std if required, to find your X library and include files,
+then
+    
+    make -f makefile.std
+ 
diff --git a/contrib/pngminim/preader/gather.sh b/contrib/pngminim/preader/gather.sh
new file mode 100755
index 0000000..8a29a7b
--- /dev/null
+++ b/contrib/pngminim/preader/gather.sh
@@ -0,0 +1,9 @@
+cp ../../gregbook/rpng2-x.c ../../gregbook/readpng2.[ch] .
+cp ../../gregbook/COPYING ../../gregbook/LICENSE .
+cp ../../../*.h .
+cp ../../../*.c .
+rm example.c pnggccrd.c pngvcrd.c pngtest.c pngw*.c
+# change the following 2 lines if zlib is somewhere else
+cp ../../../../zlib/*.h .
+cp ../../../../zlib/*.c .
+rm minigzip.c example.c compress.c deflate.c 
diff --git a/contrib/pngminim/preader/makefile.std b/contrib/pngminim/preader/makefile.std
new file mode 100644
index 0000000..74a17a3
--- /dev/null
+++ b/contrib/pngminim/preader/makefile.std
@@ -0,0 +1,60 @@
+# Makefile for PngMinus (rpng2)
+# Linux / Unix
+
+#CC=cc
+CC=gcc
+LD=$(CC)
+
+RM=rm -f
+
+#XINC = -I/usr/include			# old-style, stock X distributions
+#XLIB = -L/usr/lib/X11 -lX11		#  (including SGI IRIX)
+
+#XINC = -I/usr/openwin/include		# Sun workstations (OpenWindows)
+#XLIB = -L/usr/openwin/lib -lX11
+
+XINC = -I/usr/X11R6/include		# new X distributions (X.org, etc.)
+XLIB = -L/usr/X11R6/lib -lX11
+#XLIB = -L/usr/X11R6/lib64 -lX11	# e.g., Red Hat on AMD64
+
+#XINC = -I/usr/local/include   		# FreeBSD
+#XLIB = -L/usr/local/lib -lX11
+
+#LIBS = $(XLIB)
+LIBS = $(XLIB) -lm                      #platforms that need libm
+
+CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP \
+       -DdeflateParams\(a,b,c\)=Z_OK -I. $(XINC) -O1
+
+C=.c
+O=.o
+L=.a
+E=
+
+ZOBJS  = adler32$(O) crc32$(O) gzio$(O) \
+	 infback$(O) inffast$(O) inflate$(O) inftrees$(O) \
+	 trees$(O) uncompr$(O) zutil$(O)
+
+OBJS  = rpng2-x$(O) readpng2$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
+	pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
+	pngset$(O) pngtrans$(O)  $(ZOBJS)
+
+# implicit make rules -------------------------------------------------------
+
+.c$(O): png.h pngconf.h readpng2.h pngusr.h zlib.h
+	$(CC) -c $(CFLAGS) $<
+
+# dependencies
+
+all: rpng2-x$(E)
+
+rpng2-x$(E): $(OBJS)
+	$(LD) -o rpng2-x$(E) $(OBJS) $(LIBS)
+	strip rpng2-x$(E)
+
+clean:
+	$(RM) rpng2-x$(O)
+	$(RM) rpng2-x$(E)
+	$(RM) $(OBJS)
+
+# End of makefile for rpng2-x
diff --git a/contrib/pngminim/preader/pngusr.h b/contrib/pngminim/preader/pngusr.h
new file mode 100644
index 0000000..518c0ef
--- /dev/null
+++ b/contrib/pngminim/preader/pngusr.h
@@ -0,0 +1,62 @@
+/* minrdpngconf.h: headers to make a minimal png-read-only library
+ * For conditions of distribution and use, see copyright notice in png.h
+ * Copyright (c) 2007 Glenn Randers-Pehrson
+ * Derived from pngcrush.h, Copyright 1998-2007, Glenn Randers-Pehrson
+ */
+
+#ifndef MINRDPNGCONF_H
+#define MINRDPNGCONF_H
+
+#define PNG_NO_GLOBAL_ARRAYS
+
+#define PNG_NO_WARNINGS
+#define png_warning(s1,s2) ""
+#define png_chunk_warning(s1,s2) ""
+#define PNG_NO_ERROR_TEXT
+#define png_error(s1,s2) png_err(s1)
+#define png_chunk_error(s1,s2) png_err(s1)
+
+#define PNG_NO_ASSEMBLER_CODE
+#define PNG_NO_OPTIMIZED_CODE
+#define PNG_NO_READ_DITHER
+#define PNG_NO_READ_INVERT
+#define PNG_NO_READ_SHIFT
+#define PNG_NO_READ_PACK
+#define PNG_NO_READ_PACKSWAP
+#define PNG_NO_READ_FILLER
+#define PNG_NO_READ_SWAP_ALPHA
+#define PNG_NO_READ_INVERT_ALPHA
+#define PNG_NO_READ_RGB_TO_GRAY
+#define PNG_NO_READ_USER_TRANSFORM
+#define PNG_NO_READ_cHRM
+#define PNG_NO_READ_hIST
+#define PNG_NO_READ_iCCP
+#define PNG_NO_READ_pCAL
+#define PNG_NO_READ_pHYs
+#define PNG_NO_READ_sBIT
+#define PNG_NO_READ_sCAL
+#define PNG_NO_READ_sPLT
+#define PNG_NO_READ_TEXT
+#define PNG_NO_READ_tIME
+#define PNG_NO_READ_UNKNOWN_CHUNKS
+#define PNG_NO_READ_USER_CHUNKS
+#define PNG_NO_READ_EMPTY_PLTE
+#define PNG_NO_READ_OPT_PLTE
+#define PNG_NO_READ_STRIP_ALPHA
+#define PNG_NO_READ_oFFs
+#define PNG_NO_WARN_UNINITIALIZED_ROW
+
+#define PNG_NO_WRITE_SUPPORTED
+
+#define PNG_NO_INFO_IMAGE
+#define PNG_NO_USER_MEM
+#define PNG_NO_FIXED_POINT_SUPPORTED
+#define PNG_NO_MNG_FEATURES
+#define PNG_NO_USER_TRANSFORM_PTR
+#define PNG_NO_HANDLE_AS_UNKNOWN
+#define PNG_NO_CONSOLE_IO
+#define PNG_NO_ZALLOC_ZERO
+#define PNG_NO_ERROR_NUMBERS
+#define PNG_NO_EASY_ACCESS
+
+#endif /* MINRDPNGCONF_H */