[devel] Revised contrib/pngminim to use the "everything off" option
in pngusr.dfa.
This commit is contained in:
parent
cd74549840
commit
e3e8f6bf02
1
ANNOUNCE
1
ANNOUNCE
@ -200,6 +200,7 @@ version 1.5.0beta22 [April 28, 2010]
|
||||
Fixed dependencies of GET_INT_32 - it does not require READ_INT_FUNCTIONS
|
||||
because it has a macro equivalent.
|
||||
Improved the options.awk script; added an "everything off" option.
|
||||
Revised contrib/pngminim to use the "everything off" option in pngusr.dfa.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
|
||||
(subscription required; visit
|
||||
|
1
CHANGES
1
CHANGES
@ -2682,6 +2682,7 @@ version 1.5.0beta22 [April 28, 2010]
|
||||
Fixed dependencies of GET_INT_32 - it does not require READ_INT_FUNCTIONS
|
||||
because it has a macro equivalent.
|
||||
Improved the options.awk script; added an "everything off" option.
|
||||
Revised contrib/pngminim to use the "everything off" option in pngusr.dfa.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
@ -1,9 +1,10 @@
|
||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
||||
This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa
|
||||
|
||||
To build a minimal read-only decoder with embedded libpng and zlib, run
|
||||
The makefile builds a minimal read-only decoder with embedded libpng
|
||||
and zlib.
|
||||
|
||||
gather.sh # to collect needed files from pngminus, libpng, and zlib
|
||||
make
|
||||
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||
on the make command line.
|
||||
|
||||
If you prefer to use the shared libraries, go to contrib/pngminus
|
||||
and build the png2pnm application there.
|
||||
|
@ -1,15 +0,0 @@
|
||||
test -n "${PNGSRC}" || PNGSRC=../../..
|
||||
cp ${PNGSRC}/contrib/pngminus/png2pnm.c pngm2pnm.c
|
||||
cp "${PNGSRC}"/*.h .
|
||||
cp "${PNGSRC}"/*.c .
|
||||
rm example.c pngtest.c pngpread.c pngw*.c
|
||||
rm -f pnglibconf.h
|
||||
test -d scripts || mkdir scripts
|
||||
cp "${PNGSRC}"/scripts/pnglibconf.mak scripts
|
||||
cp "${PNGSRC}"/scripts/pnglibconf.dfa scripts
|
||||
cp "${PNGSRC}"/scripts/options.awk scripts
|
||||
# change the following if zlib is somewhere else
|
||||
test -n "${ZLIBSRC}" || ZLIBSRC="${PNGSRC}"/../zlib
|
||||
cp "${ZLIBSRC}"/*.h .
|
||||
cp "${ZLIBSRC}"/*.c .
|
||||
rm minigzip.c example.c compress.c deflate.c gz*
|
@ -4,24 +4,73 @@
|
||||
#CC=cc
|
||||
CC=gcc
|
||||
LD=$(CC)
|
||||
STRIP=strip
|
||||
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP \
|
||||
-DdeflateParams\(a,b,c\)=Z_OK -I. -O1
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. -O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
L=.a
|
||||
E=
|
||||
|
||||
ZOBJS = adler32$(O) crc32$(O) \
|
||||
infback$(O) inffast$(O) inflate$(O) inftrees$(O) \
|
||||
trees$(O) uncompr$(O) zutil$(O)
|
||||
# Where to find the source code:
|
||||
PNGSRC =../../..
|
||||
ZLIBSRC=$(PNGSRC)/../zlib
|
||||
PROGSRC=$(PNGSRC)/contrib/pngminus
|
||||
|
||||
OBJS = pngm2pnm$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||
# Zlib (minimal inflate requirements - crc32 is used by libpng)
|
||||
# zutil can be eliminated if you provide your own zcalloc and zcfree
|
||||
ZSRCS = adler32$(C) crc32$(C) \
|
||||
inffast$(C) inflate$(C) inftrees$(C) \
|
||||
zutil$(C)
|
||||
|
||||
# Standard headers
|
||||
ZH = zlib.h crc32.h inffast.h inffixed.h \
|
||||
inflate.h inftrees.h zutil.h
|
||||
|
||||
# Machine generated headers
|
||||
ZCONF = zconf.h
|
||||
|
||||
# Headers callers use
|
||||
ZINC = zlib.h $(ZCONF)
|
||||
|
||||
# Headers the Zlib source uses
|
||||
ZHDRS = $(ZH) $(ZCONF)
|
||||
|
||||
ZOBJS = adler32$(O) crc32$(O) \
|
||||
inffast$(O) inflate$(O) inftrees$(O) \
|
||||
zutil$(O)
|
||||
|
||||
# libpng
|
||||
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||
pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \
|
||||
pngset$(C) pngtrans$(C)
|
||||
|
||||
# Standard headres
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
|
||||
# Machine generated headers
|
||||
PNGCONF=pnglibconf.h
|
||||
|
||||
# Headers callers use
|
||||
PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)
|
||||
|
||||
# Headers the PNG library uses
|
||||
PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h
|
||||
|
||||
PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||
pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
|
||||
pngset$(O) pngtrans$(O) $(ZOBJS)
|
||||
pngset$(O) pngtrans$(O)
|
||||
|
||||
PROGSRCS= pngm2pnm$(C)
|
||||
PROGHDRS=
|
||||
PROGDOCS=
|
||||
PROGOBJS= pngm2pnm$(O)
|
||||
|
||||
OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
@ -35,23 +84,63 @@ all: pngm2pnm$(E)
|
||||
|
||||
pngm2pnm$(E): $(OBJS)
|
||||
$(LD) -o pngm2pnm$(E) $(OBJS)
|
||||
strip pngm2pnm$(E)
|
||||
$(STRIP) pngm2pnm$(E)
|
||||
|
||||
pnglibconf.h: scripts/pnglibconf.mak scripts/pnglibconf.dfa \
|
||||
scripts/options.awk pngusr.h
|
||||
|
||||
rm -f pnglibconf.h
|
||||
|
||||
$(MAKE) $(MAKEFLAGS) -f scripts/pnglibconf.mak\
|
||||
CPPFLAGS=-DPNG_USER_CONFIG $@
|
||||
# The DFA_XTRA setting turns all libpng options off then
|
||||
# turns on those required for this minimal build.
|
||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||
# both the build of pnglibconf.h and, subsequently, when
|
||||
# building libpng itself.
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEFLAGS) -f scripts/pnglibconf.mak clean
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) clean
|
||||
$(RM) pngm2pnm$(O)
|
||||
$(RM) pngm2pnm$(E)
|
||||
$(RM) $(OBJS)
|
||||
|
||||
$(OBJS): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h\
|
||||
pnginfo.h pngdebug.h zlib.h
|
||||
# distclean also removes the copied source and headers
|
||||
distclean: clean
|
||||
$(RM) -r scripts # historical reasons
|
||||
$(RM) $(PNGSRCS) $(PNGH)
|
||||
$(RM) $(ZSRCS) $(ZH) $(ZCONF)
|
||||
$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)
|
||||
|
||||
# Header file dependencies:
|
||||
$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
|
||||
$(PNGOBJS): $(PNGHDRS) $(ZINC)
|
||||
$(ZOBJS): $(ZHDRS)
|
||||
|
||||
# Gather the source code from the respective directories
|
||||
$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
|
||||
$(RM) $@
|
||||
$(COPY) $(PNGSRC)/$@ $@
|
||||
|
||||
# No dependency on the ZLIBSRC target so that it only needs
|
||||
# to be specified once.
|
||||
$(ZSRCS) $(ZH):
|
||||
$(RM) $@
|
||||
$(COPY) $(ZLIBSRC)/$@ $@
|
||||
|
||||
# The unconfigured zconf.h varies in name according to the
|
||||
# zlib release
|
||||
$(ZCONF):
|
||||
$(RM) $@
|
||||
@for f in zconf.h.in zconf.in.h zconf.h; do\
|
||||
test -r $(ZLIBSRC)/$$f &&\
|
||||
echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
|
||||
$(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
|
||||
done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1
|
||||
|
||||
pngm2pnm.c: $(PROGSRC)/png2pnm.c
|
||||
$(RM) $@
|
||||
$(COPY) $(PROGSRC)/png2pnm.c $@
|
||||
|
||||
# End of makefile for pngm2pnm
|
||||
|
27
contrib/pngminim/decoder/pngusr.dfa
Normal file
27
contrib/pngminim/decoder/pngusr.dfa
Normal file
@ -0,0 +1,27 @@
|
||||
# pngminim/decoder/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# First all the build options off:
|
||||
everything = off
|
||||
|
||||
# All that is required is some read code. This example switches
|
||||
# on the sequential read code (see ../preader for a progressive
|
||||
# read example).
|
||||
option SEQUENTIAL_READ on
|
||||
|
||||
# You must choose fixed or floating point arithmetic:
|
||||
option FLOATING_POINT on
|
||||
# option FIXED_POINT on
|
||||
|
||||
# Your program will probably need other options. The example
|
||||
# program here, pngm2pnm, requires the following. Take a look
|
||||
# at pnglibconf.h to find out the full set of what has to be
|
||||
# enabled to make the following work.
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option READ_EXPAND on
|
@ -16,64 +16,17 @@
|
||||
/* No 16-bit support beyond reading with strip_16 */
|
||||
#endif
|
||||
|
||||
#define PNG_USER_PRIVATEBUILD "PNG minimal build"
|
||||
#define PNG_USER_DLLFNAME_POSTFIX "MN"
|
||||
/* If pngusr.h is included during the build the following must
|
||||
* be defined either here or in the .dfa file (pngusr.dfa in
|
||||
* this case). To include pngusr.h set -DPNG_USER_CONFIG in
|
||||
* CPPFLAGS
|
||||
*/
|
||||
#define PNG_USER_PRIVATEBUILD "libpng minimal conformant PNG decoder"
|
||||
#define PNG_USER_DLLFNAME_POSTFIX "mr"
|
||||
|
||||
/* List options to turn off features of the build that do not
|
||||
* affect the API (so are not recorded in pnglibconf.h)
|
||||
*/
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_NO_ERROR_TEXT
|
||||
#define PNG_NO_READ_INT_FUNCTIONS
|
||||
|
||||
#define PNG_NO_READ_BGR
|
||||
#define PNG_NO_READ_GAMMA
|
||||
#define PNG_NO_READ_BACKGROUND
|
||||
#define PNG_NO_READ_QUANTIZE
|
||||
#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
|
||||
#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_bKGD
|
||||
#define PNG_NO_READ_cHRM
|
||||
#define PNG_NO_READ_gAMA
|
||||
#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_sRGB
|
||||
#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_WRITE_SUPPORTED
|
||||
|
||||
#define PNG_NO_INFO_IMAGE
|
||||
#define PNG_NO_IO_STATE
|
||||
#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
|
||||
#define PNG_NO_PROGRESSIVE_READ
|
||||
#define PNG_NO_USER_LIMITS
|
||||
#define PNG_NO_SET_USER_LIMITS
|
||||
#define PNG_NO_TIME_RFC1123
|
||||
|
||||
#endif /* MINRDPNGCONF_H */
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
||||
|
||||
To build a minimal write-only decoder with embedded libpng and zlib, run
|
||||
The makefile builds a minimal write-only decoder with embedded libpng
|
||||
and zlib.
|
||||
|
||||
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||
on the make command line.
|
||||
|
||||
gather.sh # to collect needed files from pngminus, libpng, and zlib
|
||||
make
|
||||
|
||||
If you prefer to use the shared libraries, go to contrib/pngminus
|
||||
and build the pnm2png application there.
|
||||
|
@ -1,27 +1,5 @@
|
||||
#include "zlib.h"
|
||||
|
||||
int ZEXPORT inflate(strm, flush)
|
||||
z_streamp strm;
|
||||
int flush;
|
||||
{ return Z_OK ; }
|
||||
|
||||
int ZEXPORT inflateReset(strm)
|
||||
z_streamp strm;
|
||||
{ return Z_OK ; }
|
||||
|
||||
int ZEXPORT inflateEnd(strm)
|
||||
z_streamp strm;
|
||||
{ return Z_STREAM_ERROR ; }
|
||||
|
||||
int ZEXPORT inflateInit_(strm, version, stream_size)
|
||||
z_streamp strm;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{ return Z_OK ; }
|
||||
|
||||
int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
|
||||
z_streamp strm;
|
||||
int windowBits;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{ return Z_STREAM_ERROR ; }
|
||||
|
@ -1,17 +0,0 @@
|
||||
test -n "${PNGSRC}" || PNGSRC=../../..
|
||||
cp ${PNGSRC}/contrib/pngminus/pnm2png.c pnm2pngm.c
|
||||
cp "${PNGSRC}"/*.h .
|
||||
cp "${PNGSRC}"/*.c .
|
||||
rm example.c pngtest.c pngr*.c pngpread.c
|
||||
rm -f pnglibconf.h
|
||||
test -d scripts || mkdir scripts
|
||||
cp "${PNGSRC}"/scripts/pnglibconf.mak scripts
|
||||
cp "${PNGSRC}"/scripts/pnglibconf.dfa scripts
|
||||
cp "${PNGSRC}"/scripts/options.awk scripts
|
||||
# change the following if zlib is somewhere else
|
||||
test -n "${ZLIBSRC}" || ZLIBSRC="${PNGSRC}"/../zlib
|
||||
cp "${ZLIBSRC}"/*.h .
|
||||
cp "${ZLIBSRC}"/*.c .
|
||||
rm inf*.[ch]
|
||||
rm minigzip.c example.c gz*
|
||||
|
@ -4,8 +4,10 @@
|
||||
#CC=cc
|
||||
CC=gcc
|
||||
LD=$(CC)
|
||||
STRIP=strip
|
||||
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZIP -I. -O1
|
||||
|
||||
@ -14,13 +16,62 @@ O=.o
|
||||
L=.a
|
||||
E=
|
||||
|
||||
# Where to find the source code:
|
||||
PNGSRC =../../..
|
||||
ZLIBSRC=$(PNGSRC)/../zlib
|
||||
PROGSRC=$(PNGSRC)/contrib/pngminus
|
||||
|
||||
# Zlib
|
||||
ZSRCS = adler32$(C) compress$(C) crc32$(C) deflate$(C) \
|
||||
trees$(C) zutil$(C)
|
||||
|
||||
# Standard headers
|
||||
#ZH = zlib.h crc32.h deflate.h trees.h zutil.h
|
||||
ZH = zlib.h crc32.h deflate.h trees.h zutil.h
|
||||
|
||||
# Machine generated headers
|
||||
ZCONF = zconf.h
|
||||
|
||||
# Headers callers use
|
||||
ZINC = zlib.h $(ZCONF)
|
||||
|
||||
# Headers the Zlib source uses
|
||||
ZHDRS = $(ZH) $(ZCONF)
|
||||
|
||||
# compress is not required; it is needed to link the zlib
|
||||
# code because deflate defines an unused API function deflateBound
|
||||
# which itself calls compressBound from compress.
|
||||
ZOBJS = adler32$(O) compress$(O) crc32$(O) deflate$(O) \
|
||||
dummy_inflate$(O) \
|
||||
trees$(O) uncompr$(O) zutil$(O)
|
||||
trees$(O) zutil$(O)
|
||||
|
||||
OBJS = pnm2pngm$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||
# libpng
|
||||
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||
pngset$(C) pngtrans$(C) pngwio$(C) pngwrite$(C) \
|
||||
pngwtran$(C) pngwutil$(C)
|
||||
|
||||
# Standard headres
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
|
||||
# Machine generated headers
|
||||
PNGCONF=pnglibconf.h
|
||||
|
||||
# Headers callers use
|
||||
PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)
|
||||
|
||||
# Headers the PNG library uses
|
||||
PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h
|
||||
|
||||
PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||
pngset$(O) pngtrans$(O) pngwio$(O) pngwrite$(O) \
|
||||
pngwtran$(O) pngwutil$(O) $(ZOBJS)
|
||||
pngwtran$(O) pngwutil$(O)
|
||||
|
||||
PROGSRCS= pnm2pngm$(C)
|
||||
PROGHDRS=
|
||||
PROGDOCS=
|
||||
PROGOBJS= pnm2pngm$(O)
|
||||
|
||||
OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
@ -33,18 +84,63 @@ all: pnm2pngm$(E)
|
||||
|
||||
pnm2pngm$(E): $(OBJS)
|
||||
$(LD) -o pnm2pngm$(E) $(OBJS)
|
||||
strip pnm2pngm$(E)
|
||||
$(STRIP) pnm2pngm$(E)
|
||||
|
||||
pnglibconf.h: scripts/pnglibconf.mak scripts/pnglibconf.dfa scripts/options.awk pngusr.h
|
||||
rm -f pnglibconf.h
|
||||
$(MAKE) $(MAKEFLAGS) -f scripts/pnglibconf.mak CPPFLAGS=-DPNG_USER_CONFIG $@
|
||||
# The DFA_XTRA setting turns all libpng options off then
|
||||
# turns on those required for this minimal build.
|
||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||
# both the build of pnglibconf.h and, subsequently, when
|
||||
# building libpng itself.
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEFLAGS) -f scripts/pnglibconf.mak clean
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) clean
|
||||
$(RM) pnm2pngm$(O)
|
||||
$(RM) pnm2pngm$(E)
|
||||
$(RM) $(OBJS)
|
||||
|
||||
$(OBJS): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngusr.h zlib.h
|
||||
# distclean also removes the copied source and headers
|
||||
distclean: clean
|
||||
$(RM) -r scripts # historical reasons
|
||||
$(RM) $(PNGSRCS) $(PNGH)
|
||||
$(RM) $(ZSRCS) $(ZH) $(ZCONF)
|
||||
$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)
|
||||
|
||||
# Header file dependencies:
|
||||
$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
|
||||
$(PNGOBJS): $(PNGHDRS) $(ZINC)
|
||||
$(ZOBJS): $(ZHDRS)
|
||||
|
||||
# Gather the source code from the respective directories
|
||||
$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
|
||||
$(RM) $@
|
||||
$(COPY) $(PNGSRC)/$@ $@
|
||||
|
||||
# No dependency on the ZLIBSRC target so that it only needs
|
||||
# to be specified once.
|
||||
$(ZSRCS) $(ZH):
|
||||
$(RM) $@
|
||||
$(COPY) $(ZLIBSRC)/$@ $@
|
||||
|
||||
# The unconfigured zconf.h varies in name according to the
|
||||
# zlib release
|
||||
$(ZCONF):
|
||||
$(RM) $@
|
||||
@for f in zconf.h.in zconf.in.h zconf.h; do\
|
||||
test -r $(ZLIBSRC)/$$f &&\
|
||||
echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
|
||||
$(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
|
||||
done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1
|
||||
|
||||
pnm2pngm.c: $(PROGSRC)/pnm2png.c
|
||||
$(RM) $@
|
||||
$(COPY) $(PROGSRC)/pnm2png.c $@
|
||||
|
||||
# End of makefile for pnm2pngm
|
||||
|
24
contrib/pngminim/encoder/pngusr.dfa
Normal file
24
contrib/pngminim/encoder/pngusr.dfa
Normal file
@ -0,0 +1,24 @@
|
||||
# pngminim/encoder/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# First all the build options off:
|
||||
everything = off
|
||||
|
||||
# Switch on the write code - this makes a minimalist encoder
|
||||
option WRITE on
|
||||
|
||||
# You must choose fixed or floating point arithmetic:
|
||||
option FLOATING_POINT on
|
||||
# option FIXED_POINT on
|
||||
|
||||
# Your program will probably need other options. The example
|
||||
# program here, pnm2pngm, requires the following. Take a look
|
||||
# at pnglibconf.h to find out the full set of what has to be
|
||||
# enabled to make the following work.
|
||||
option SETJMP on
|
||||
option STDIO on
|
@ -12,64 +12,17 @@
|
||||
#ifndef MINWRPNGCONF_H
|
||||
#define MINWRPNGCONF_H
|
||||
|
||||
#define PNG_USER_PRIVATEBUILD "PNG minimal build"
|
||||
#define PNG_USER_DLLFNAME_POSTFIX "MN"
|
||||
|
||||
#define PNG_NO_READ_SUPPORTED
|
||||
/* If pngusr.h is included during the build the following must
|
||||
* be defined either here or in the .dfa file (pngusr.dfa in
|
||||
* this case). To include pngusr.h set -DPNG_USER_CONFIG in
|
||||
* CPPFLAGS
|
||||
*/
|
||||
#define PNG_USER_PRIVATEBUILD "libpng minimal conformant PNG encoder"
|
||||
#define PNG_USER_DLLFNAME_POSTFIX "me"
|
||||
|
||||
/* List options to turn off features of the build that do not
|
||||
* affect the API (so are not recorded in pnglibconf.h)
|
||||
*/
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_NO_ERROR_TEXT
|
||||
|
||||
#define PNG_NO_WRITE_BACKGROUND
|
||||
#define PNG_NO_WRITE_BGR
|
||||
#define PNG_NO_WRITE_GAMMA
|
||||
#define PNG_NO_WRITE_QUANTIZE
|
||||
#define PNG_NO_WRITE_INVERT
|
||||
#define PNG_NO_WRITE_SHIFT
|
||||
#define PNG_NO_WRITE_PACK
|
||||
#define PNG_NO_WRITE_PACKSWAP
|
||||
#define PNG_NO_WRITE_FILLER
|
||||
#define PNG_NO_WRITE_SWAP
|
||||
#define PNG_NO_WRITE_SWAP_ALPHA
|
||||
#define PNG_NO_WRITE_INVERT_ALPHA
|
||||
#define PNG_NO_WRITE_RGB_TO_GRAY
|
||||
#define PNG_NO_WRITE_USER_TRANSFORM
|
||||
#define PNG_NO_WRITE_bKGD
|
||||
#define PNG_NO_WRITE_cHRM
|
||||
#define PNG_NO_WRITE_gAMA
|
||||
#define PNG_NO_WRITE_hIST
|
||||
#define PNG_NO_WRITE_iCCP
|
||||
#define PNG_NO_WRITE_oFFs
|
||||
#define PNG_NO_WRITE_pCAL
|
||||
#define PNG_NO_WRITE_pHYs
|
||||
#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
|
||||
#define PNG_NO_WRITE_USER_CHUNKS
|
||||
#define PNG_NO_WRITE_EMPTY_PLTE
|
||||
#define PNG_NO_WRITE_OPT_PLTE
|
||||
#define PNG_NO_WRITE_FILTER
|
||||
#define PNG_NO_WRITE_WEIGHTED_FILTER
|
||||
#define PNG_NO_WRITE_INTERLACING_SUPPORTED
|
||||
#define PNG_NO_WRITE_FLUSH
|
||||
|
||||
#define PNG_NO_INFO_IMAGE
|
||||
#define PNG_NO_IO_STATE
|
||||
#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
|
||||
#define PNG_NO_USER_LIMITS
|
||||
#define PNG_NO_SET_USER_LIMITS
|
||||
#define PNG_NO_TIME_RFC1123
|
||||
|
||||
#endif /* MINWRPNGCONF_H */
|
||||
|
@ -1,14 +1,15 @@
|
||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
||||
|
||||
To build a minimal read-only progressive decoder embedded libpng and
|
||||
zlib and with your system's X library, run
|
||||
The makefile builds a minimal read-only progressive decoder with
|
||||
embedded libpng, zlib and your system's X library.
|
||||
|
||||
gather.sh # to collect needed files from gregbook, libpng, and zlib
|
||||
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||
on the make command line.
|
||||
|
||||
Edit makefile if required, to find your X library and include files,
|
||||
then
|
||||
|
||||
make
|
||||
make ZLIBSRC=directory
|
||||
|
||||
If you prefer to use the shared libraries, go to contrib/gregbook
|
||||
and build the rpng2-x application there.
|
||||
|
@ -1,18 +0,0 @@
|
||||
test -n "${PNGSRC}" || PNGSRC=../../..
|
||||
cp "${PNGSRC}"/contrib/gregbook/rpng2-x.c .
|
||||
cp "${PNGSRC}"/contrib/gregbook/readpng2.[ch] .
|
||||
cp "${PNGSRC}"/contrib/gregbook/COPYING .
|
||||
cp "${PNGSRC}"/contrib/gregbook/LICENSE .
|
||||
cp "${PNGSRC}"/*.h .
|
||||
cp "${PNGSRC}"/*.c .
|
||||
rm example.c pngtest.c pngw*.c
|
||||
rm -f pnglibconf.h
|
||||
test -d scripts || mkdir scripts
|
||||
cp "${PNGSRC}"/scripts/pnglibconf.mak scripts
|
||||
cp "${PNGSRC}"/scripts/pnglibconf.dfa scripts
|
||||
cp "${PNGSRC}"/scripts/options.awk scripts
|
||||
# change the following if zlib is somewhere else
|
||||
test -n "${ZLIBSRC}" || ZLIBSRC="${PNGSRC}"/../zlib
|
||||
cp "${ZLIBSRC}"/*.h .
|
||||
cp "${ZLIBSRC}"/*.c .
|
||||
rm minigzip.c example.c compress.c deflate.c gz*
|
@ -4,8 +4,10 @@
|
||||
#CC=cc
|
||||
CC=gcc
|
||||
LD=$(CC)
|
||||
STRIP=strip
|
||||
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
#XINC = -I/usr/include # old-style, stock X distributions
|
||||
#XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX)
|
||||
@ -23,21 +25,68 @@ XLIB = -L/usr/X11R6/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
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. $(XINC) -O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
L=.a
|
||||
E=
|
||||
|
||||
ZOBJS = adler32$(O) crc32$(O) \
|
||||
infback$(O) inffast$(O) inflate$(O) inftrees$(O) \
|
||||
trees$(O) uncompr$(O) zutil$(O)
|
||||
# Where to find the source code:
|
||||
PNGSRC =../../..
|
||||
ZLIBSRC=$(PNGSRC)/../zlib
|
||||
PROGSRC=$(PNGSRC)/contrib/gregbook
|
||||
|
||||
OBJS = rpng2-x$(O) readpng2$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||
# Zlib (minimal inflate requirements - crc32 is used by libpng)
|
||||
# zutil can be eliminated if you provide your own zcalloc and zcfree
|
||||
ZSRCS = adler32$(C) crc32$(C) \
|
||||
inffast$(C) inflate$(C) inftrees$(C) \
|
||||
zutil$(C)
|
||||
|
||||
# Standard headers
|
||||
ZH = zlib.h crc32.h inffast.h inffixed.h \
|
||||
inflate.h inftrees.h zutil.h
|
||||
|
||||
# Machine generated headers
|
||||
ZCONF = zconf.h
|
||||
|
||||
# Headers callers use
|
||||
ZINC = zlib.h $(ZCONF)
|
||||
|
||||
# Headers the Zlib source uses
|
||||
ZHDRS = $(ZH) $(ZCONF)
|
||||
|
||||
ZOBJS = adler32$(O) crc32$(O) \
|
||||
inffast$(O) inflate$(O) inftrees$(O) \
|
||||
zutil$(O)
|
||||
|
||||
# libpng
|
||||
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||
pngpread$(C) pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \
|
||||
pngset$(C) pngtrans$(C)
|
||||
|
||||
# Standard headres
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
|
||||
# Machine generated headers
|
||||
PNGCONF=pnglibconf.h
|
||||
|
||||
# Headers callers use
|
||||
PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)
|
||||
|
||||
# Headers the PNG library uses
|
||||
PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h
|
||||
|
||||
PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||
pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
|
||||
pngset$(O) pngtrans$(O) $(ZOBJS)
|
||||
pngset$(O) pngtrans$(O)
|
||||
|
||||
PROGSRCS= rpng2-x$(C) readpng2$(C)
|
||||
PROGHDRS= readpng2.h
|
||||
PROGDOCS= COPYING LICENSE
|
||||
PROGOBJS= rpng2-x$(O) readpng2$(O)
|
||||
|
||||
OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
@ -46,22 +95,67 @@ OBJS = rpng2-x$(O) readpng2$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||
|
||||
# dependencies
|
||||
|
||||
all: rpng2-x$(E)
|
||||
all: $(PROGDOCS) rpng2-x$(E)
|
||||
|
||||
rpng2-x$(E): $(OBJS)
|
||||
$(LD) -o rpng2-x$(E) $(OBJS) $(LIBS)
|
||||
strip rpng2-x$(E)
|
||||
$(STRIP) rpng2-x$(E)
|
||||
|
||||
pnglibconf.h: scripts/pnglibconf.mak scripts/pnglibconf.dfa scripts/options.awk pngusr.h
|
||||
rm -f pnglibconf.h
|
||||
$(MAKE) $(MAKEFLAGS) -f scripts/pnglibconf.mak CPPFLAGS=-DPNG_USER_CONFIG $@
|
||||
# The DFA_XTRA setting turns all libpng options off then
|
||||
# turns on those required for this minimal build.
|
||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||
# both the build of pnglibconf.h and, subsequently, when
|
||||
# building libpng itself.
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEFLAGS) -f scripts/pnglibconf.mak clean
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) clean
|
||||
$(RM) rpng2-x$(O)
|
||||
$(RM) rpng2-x$(E)
|
||||
$(RM) $(OBJS)
|
||||
|
||||
$(OBJS): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h readpng2.h pngusr.h zlib.h
|
||||
# distclean also removes the copied source and headers
|
||||
distclean: clean
|
||||
$(RM) -r scripts # historical reasons
|
||||
$(RM) $(PNGSRCS) $(PNGH)
|
||||
$(RM) $(ZSRCS) $(ZH) $(ZCONF)
|
||||
$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)
|
||||
|
||||
# Header file dependencies:
|
||||
$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
|
||||
$(PNGOBJS): $(PNGHDRS) $(ZINC)
|
||||
$(ZOBJS): $(ZHDRS)
|
||||
|
||||
# Gather the source code from the respective directories
|
||||
$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
|
||||
$(RM) $@
|
||||
$(COPY) $(PNGSRC)/$@ $@
|
||||
|
||||
# No dependency on the ZLIBSRC target so that it only needs
|
||||
# to be specified once.
|
||||
$(ZSRCS) $(ZH):
|
||||
$(RM) $@
|
||||
$(COPY) $(ZLIBSRC)/$@ $@
|
||||
|
||||
# The unconfigured zconf.h varies in name according to the
|
||||
# zlib release
|
||||
$(ZCONF):
|
||||
$(RM) $@
|
||||
@for f in zconf.h.in zconf.in.h zconf.h; do\
|
||||
test -r $(ZLIBSRC)/$$f &&\
|
||||
echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
|
||||
$(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
|
||||
done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1
|
||||
|
||||
$(PROGSRCS) $(PROGHDRS) $(PROGDOCS): $(PROGSRC)/$@
|
||||
$(RM) $@
|
||||
$(COPY) $(PROGSRC)/$@ $@
|
||||
|
||||
# End of makefile for rpng2-x
|
||||
|
29
contrib/pngminim/preader/pngusr.dfa
Normal file
29
contrib/pngminim/preader/pngusr.dfa
Normal file
@ -0,0 +1,29 @@
|
||||
# pngminim/preader/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# First all the build options off:
|
||||
everything = off
|
||||
|
||||
# Just switch on the progressive read code
|
||||
option PROGRESSIVE_READ on
|
||||
|
||||
# You must choose fixed or floating point arithmetic:
|
||||
option FLOATING_POINT on
|
||||
# option FIXED_POINT on
|
||||
|
||||
# Your program will probably need other options. The example
|
||||
# program here, rpng2-x, requires the following. Take a look
|
||||
# at pnglibconf.h to find out the full set of what has to be
|
||||
# enabled to make the following work.
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option READ_bKGD on
|
||||
option READ_GAMMA on
|
||||
option READ_EXPAND on
|
||||
option READ_16_TO_8 on
|
||||
option READ_GRAY_TO_RGB on
|
@ -12,57 +12,17 @@
|
||||
#ifndef MINPRDPNGCONF_H
|
||||
#define MINPRDPNGCONF_H
|
||||
|
||||
#define PNG_USER_PRIVATEBUILD "PNG minimal build"
|
||||
#define PNG_USER_DLLFNAME_POSTFIX "MN"
|
||||
/* If pngusr.h is included during the build the following must
|
||||
* be defined either here or in the .dfa file (pngusr.dfa in
|
||||
* this case). To include pngusr.h set -DPNG_USER_CONFIG in
|
||||
* CPPFLAGS
|
||||
*/
|
||||
#define PNG_USER_PRIVATEBUILD "libpng minimal conformant PNG progressive reader"
|
||||
#define PNG_USER_DLLFNAME_POSTFIX "mp"
|
||||
|
||||
/* List options to turn off features of the build that do not
|
||||
* affect the API (so are not recorded in pnglibconf.h)
|
||||
*/
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_NO_ERROR_TEXT
|
||||
#define PNG_NO_READ_INT_FUNCTIONS
|
||||
|
||||
#define PNG_NO_READ_BGR
|
||||
#define PNG_NO_READ_QUANTIZE
|
||||
#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
|
||||
#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_WRITE_SUPPORTED
|
||||
|
||||
#define PNG_NO_INFO_IMAGE
|
||||
#define PNG_NO_IO_STATE
|
||||
#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
|
||||
#define PNG_NO_USER_LIMITS
|
||||
#define PNG_NO_SET_USER_LIMITS
|
||||
#define PNG_NO_TIME_RFC1123
|
||||
|
||||
#endif /* MINPRDPNGCONF_H */
|
||||
|
Loading…
Reference in New Issue
Block a user