add netpbm port

This commit is contained in:
brad 1999-03-19 01:31:46 +00:00
parent 8bfaa418fd
commit 4b63af8b5c
27 changed files with 3786 additions and 104 deletions

View File

@ -1,23 +1,25 @@
--- pgm/Makefile.orig Fri Jan 28 11:14:02 1994
+++ pgm/Makefile Sat Dec 20 22:51:17 1997
@@ -39,10 +39,10 @@
LIBPGM = libpgm.a
--- pbmplus.h.orig Tue Mar 1 10:46:36 1994
+++ pbmplus.h Mon Jan 11 00:33:32 1999
@@ -119,10 +119,12 @@
#ifndef VMS
#include <unistd.h>
#endif
+#ifndef __OpenBSD__
extern int atoi();
extern void exit();
extern long time();
extern int write();
+#endif /* NetBSD */
#endif
PORTBINARIES = asciitopgm bioradtopgm fstopgm hipstopgm \
- lispmtopgm pbmtopgm pgmbentley pgmenhance pgmhist pgmkernel \
+ lispmtopgm pbmtopgm pgmbentley pgmenhance pgmhist \
pgmnoise pgmnorm pgmoil pgmramp pgmtofs pgmtolispm \
pgmtopbm psidtopgm spottopgm
-MATHBINARIES = pgmcrater pgmedge pgmtexture rawtopgm
+MATHBINARIES = pgmcrater pgmedge pgmtexture rawtopgm pgmkernel
BINARIES = $(PORTBINARIES) $(MATHBINARIES)
/* CONFIGURE: On most BSD systems, malloc() gets declared in stdlib.h, on
@@ -275,5 +277,9 @@
int vfprintf ARGS(( FILE* stream, char* format, va_list args ));
#endif /*NEED_VFPRINTF*/
OBJECTS = asciitopgm.o bioradtopgm.o fstopgm.o hipstopgm.o \
@@ -134,7 +134,6 @@
pgmedge pgmedge.o: pgmedge.c
pgmenhance pgmenhance.o: pgmenhance.c
pgmhist pgmhist.o: pgmhist.c
-pgmkernel pgmkernel.o: pgmkernel.c
pgmnoise pgmnoise.o: pgmnoise.c
pgmnorm pgmnorm.o: pgmnorm.c
pgmoil pgmoil.o: pgmoil.c
+#ifdef __OpenBSD__
+#include <errno.h>
+#define A_STRERROR
+#endif
#endif /*_PBMPLUS_H_*/

View File

@ -1,66 +1,114 @@
*** pnm/Makefile.orig Mon Jan 31 23:47:32 1994
--- pnm/Makefile Thu May 14 12:01:28 1998
***************
*** 60,69 ****
pnmcut pnmdepth pnmenlarge pnmfile pnmflip pnmhistmap \
pnminvert pnmnoraw pnmpad pnmpaste \
pnmtile pnmtoddif pnmtofits pnmtops pnmtorast \
! pnmtosgi pnmtosir pnmtoxwd \
! rasttopnm sgitopnm sirtopnm xwdtopnm zeisstopnm
MATHBINARIES = pnmgamma pnmnlfilt pnmrotate pnmscale pnmshear
! BINARIES = $(PORTBINARIES) $(MATHBINARIES) $(TIFFBINARIES)
SCRIPTS = anytopnm pnmindex pnmmargin pnmsmooth pstopnm
PORTOBJECTS = fitstopnm.o giftopnm.o \
--- 60,70 ----
pnmcut pnmdepth pnmenlarge pnmfile pnmflip pnmhistmap \
pnminvert pnmnoraw pnmpad pnmpaste \
pnmtile pnmtoddif pnmtofits pnmtops pnmtorast \
! pnmtorle pnmtosgi pnmtosir pnmtoxwd \
! rasttopnm rletopnm sgitopnm sirtopnm xwdtopnm zeisstopnm
MATHBINARIES = pnmgamma pnmnlfilt pnmrotate pnmscale pnmshear
! PNGBINARIES = pngtopnm pnmtopng
! BINARIES = $(PORTBINARIES) $(MATHBINARIES) $(PNGBINARIES) $(TIFFBINARIES)
SCRIPTS = anytopnm pnmindex pnmmargin pnmsmooth pstopnm
PORTOBJECTS = fitstopnm.o giftopnm.o \
***************
*** 74,80 ****
pnmtosgi.o pnmtosir.o pnmtoxwd.o \
rasttopnm.o sgitopnm.o sirtopnm.o xwdtopnm.o zeisstopnm.o \
pnmgamma.o pnmnlfilt.o pnmrotate.o pnmscale.o pnmshear.o
! OBJECTS = $(PORTOBJECTS) $(TIFFOBJECTS)
MANUALS1 = $(BINARIES) $(SCRIPTS)
MANUALS3 = libpnm
--- 75,81 ----
pnmtosgi.o pnmtosir.o pnmtoxwd.o \
rasttopnm.o sgitopnm.o sirtopnm.o xwdtopnm.o zeisstopnm.o \
pnmgamma.o pnmnlfilt.o pnmrotate.o pnmscale.o pnmshear.o
! OBJECTS = $(PORTOBJECTS)
MANUALS1 = $(BINARIES) $(SCRIPTS)
MANUALS3 = libpnm
***************
*** 128,134 ****
# Rules for plain programs.
! $(PORTBINARIES) $(TIFFBINARIES): pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM) $(TIFFLIB)
$(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM) $(TIFFLIB)
# Rule for math-dependent programs.
--- 129,141 ----
# Rules for plain programs.
! $(PORTBINARIES): pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
! $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
!
! $(PNGBINARIES): pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
! $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM) -L/usr/local/lib -lpng -lz
!
! $(TIFFBINARIES): pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
$(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM) $(TIFFLIB)
# Rule for math-dependent programs.
--- pbm/Makefile.orig Sat Nov 20 15:59:20 1993
+++ pbm/Makefile Mon Jan 11 00:18:43 1999
@@ -10,28 +10,31 @@
# implied warranty.
# Default values, usually overridden by top-level Makefile.
-CC = cc
+CC = gcc
#CC = gcc -ansi -pedantic -fcombine-regs -fpcc-struct-return
#CFLAGS = -O
-CFLAGS = -g
+CFLAGS = -O2
#CFLAGS = -g -O
TIFFDEF = -DLIBTIFF
#LDFLAGS = -s
LDFLAGS =
-INSTALLBINARIES = /usr/new/pbm
-INSTALLMANUALS1 = /usr/man/man1
+INSTALLBINARIES = $(PREFIX)/bin
+INSTALLMANUALS1 = $(PREFIX)/man/man1
SUFFIXMANUALS1 = 1
-INSTALLMANUALS3 = /usr/man/man3
+INSTALLMANUALS3 = $(PREFIX)/man/man3
SUFFIXMANUALS3 = 3
-INSTALLMANUALS5 = /usr/man/man5
+INSTALLMANUALS5 = $(PREFIX)/man/man5
SUFFIXMANUALS5 = 5
-MANCP = cp
+MANCP = install -c -m 0644
+INSTALLLIBS = $(PREFIX)/lib
+INSTALLDEFS = $(PREFIX)/include
SHELL = /bin/sh
INCLUDE = -I..
ALLCFLAGS = $(CFLAGS) $(TIFFDEF) $(INCLUDE)
LIBPBM = libpbm.a
-DEFPBM = pbm.h ../pbmplus.h
+DEFPBM = pbm.h
+DEFPBMPLUS = ../pbmplus.h
PORTBINARIES = atktopbm brushtopbm cmuwmtopbm g3topbm \
icontopbm gemtopbm macptopbm mgrtopbm \
@@ -67,18 +70,19 @@
MANUALS5 = pbm
-#all: binaries
-all: merge
-#install: install.bin
-install: install.merge
+all: binaries
+#all: merge
+install: install.bin
+#install: install.merge
binaries: $(BINARIES)
install.bin: binaries
cd $(INSTALLBINARIES) ; rm -f $(BINARIES)
- cp $(BINARIES) $(INSTALLBINARIES)
-
+ install -c -s -m 0755 $(BINARIES) $(INSTALLBINARIES)
+ install -c -m 0644 $(LIBPBM) $(INSTALLLIBS)
+ install -c -m 0644 $(DEFPBM) $(INSTALLDEFS)
merge: pbmmerge
pbmmerge: pbmmerge.c $(OBJECTS) $(LIBPBM)
@@ -107,15 +111,15 @@
done
# Rule for plain programs.
-$(PORTBINARIES): $(DEFPBM) $(LIBPBM)
+$(PORTBINARIES): $(DEFPBM) $(DEFPBMPLUS) $(LIBPBM)
$(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPBM)
# Rule for math-dependent programs.
-$(MATHBINARIES): $(DEFPBM) $(LIBPBM)
+$(MATHBINARIES): $(DEFPBM) $(DEFPBMPLUS) $(LIBPBM)
$(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c -lm $(LIBPBM)
# Rule for objects.
-$(OBJECTS): $(DEFPBM)
+$(OBJECTS): $(DEFPBM) $(DEFPBMPLUS)
$(CC) $(ALLCFLAGS) "-Dmain=$*_main" -c $*.c
# And library.
@@ -125,15 +129,15 @@
ar rc $(LIBPBM) libpbm1.o libpbm2.o libpbm3.o libpbm4.o libpbm5.o
-ranlib $(LIBPBM)
-libpbm1.o: $(DEFPBM) ../version.h ../compile.h libpbm.h libpbm1.c
+libpbm1.o: $(DEFPBM) $(DEFPBMPLUS) ../version.h ../compile.h libpbm.h libpbm1.c
$(CC) $(ALLCFLAGS) -c libpbm1.c
-libpbm2.o: $(DEFPBM) libpbm.h libpbm2.c
+libpbm2.o: $(DEFPBM) $(DEFPBMPLUS) libpbm.h libpbm2.c
$(CC) $(ALLCFLAGS) -c libpbm2.c
-libpbm3.o: $(DEFPBM) libpbm.h libpbm3.c
+libpbm3.o: $(DEFPBM) $(DEFPBMPLUS) libpbm.h libpbm3.c
$(CC) $(ALLCFLAGS) -c libpbm3.c
-libpbm4.o: $(DEFPBM) libpbm.h libpbm4.c
+libpbm4.o: $(DEFPBM) $(DEFPBMPLUS) libpbm.h libpbm4.c
$(CC) $(ALLCFLAGS) -c libpbm4.c
-libpbm5.o: $(DEFPBM) pbmfont.h libpbm5.c
+libpbm5.o: $(DEFPBM) $(DEFPBMPLUS) pbmfont.h libpbm5.c
$(CC) $(ALLCFLAGS) -c libpbm5.c
# Other dependencies.
@@ -184,4 +188,4 @@
pbmtoepsi pbmtoepsi.o: pbmtoepsi.c
clean:
- -rm -f *.o *.a *.cat *~ core $(BINARIES) pbmmerge
+ -rm -f *.o *.a *.cat *~ core *.core $(BINARIES) pbmmerge

View File

@ -1,16 +1,11 @@
*** pbmplus.h.orig Thu May 14 11:50:42 1998
--- pbmplus.h Thu May 14 11:51:59 1998
***************
*** 120,128 ****
--- 120,130 ----
#include <unistd.h>
#endif
extern int atoi();
+ #ifndef __OpenBSD__
extern void exit();
extern long time();
extern int write();
+ #endif
#endif
/* CONFIGURE: On most BSD systems, malloc() gets declared in stdlib.h, on
--- pbm/libpbm1.c.orig Mon Jan 10 18:37:22 1994
+++ pbm/libpbm1.c Sun Jan 10 23:48:40 1999
@@ -132,7 +132,7 @@
if ( isupper( c1 ) )
c1 = tolower( c1 );
if ( isupper( c2 ) )
- c1 = tolower( c2 );
+ c2 = tolower( c2 );
if ( c1 != c2 )
return 0;
}

View File

@ -0,0 +1,13 @@
--- pgm/pgmmerge.c.orig Fri Jan 28 11:17:38 1994
+++ pgm/pgmmerge.c Sun Jan 10 23:48:40 1999
@@ -29,6 +29,10 @@
{
++argv;
--argc;
+ if(!*argv) {
+ fprintf(stderr, "Usage: pgmmerge pgm_program_name [args ...]\n");
+ exit(1);
+ }
goto again;
}

View File

@ -0,0 +1,168 @@
--- pnm/Makefile.orig Mon Jan 31 17:47:32 1994
+++ pnm/Makefile Mon Jan 11 00:18:48 1999
@@ -10,27 +10,29 @@
# implied warranty.
# Default values, usually overridden by top-level Makefile.
-#CC = cc
-CC = gcc -ansi -pedantic -fcombine-regs -fpcc-struct-return
+CC = gcc
+#CC = gcc -ansi -pedantic -fcombine-regs -fpcc-struct-return
#CFLAGS = -O
-CFLAGS = -g
+CFLAGS = -O2
#CFLAGS = -g -O
TIFFDEF = -DLIBTIFF
-TIFFINC = -I../libtiff
-TIFFLIB = ../libtiff/libtiff.a
+TIFFINC = -I$(PREFIX)/include
+TIFFLIB = -L$(PREFIX)/lib -ltiff -ljpeg
TIFFBINARIES = tifftopnm pnmtotiff
TIFFOBJECTS = tifftopnm.o pnmtotiff.o
-#LDFLAGS = -s
-LDFLAGS =
-INSTALLBINARIES = /usr/new/pbm
+LDFLAGS = -s
+#LDFLAGS =
+INSTALLBINARIES = $(PREFIX)/bin
INSTALLSCRIPTS = $(INSTALLBINARIES)
-INSTALLMANUALS1 = /usr/man/man1
+INSTALLMANUALS1 = $(PREFIX)/man/man1
SUFFIXMANUALS1 = 1
-INSTALLMANUALS3 = /usr/man/man3
+INSTALLMANUALS3 = $(PREFIX)/man/man3
SUFFIXMANUALS3 = 3
-INSTALLMANUALS5 = /usr/man/man5
+INSTALLMANUALS5 = $(PREFIX)/man/man5
SUFFIXMANUALS5 = 5
-MANCP = cp
+MANCP = install -c -m 0644
+INSTALLLIBS = $(PREFIX)/lib
+INSTALLDEFS = $(PREFIX)/include
PPMDIR = ../ppm
INCLUDEPPM = -I$(PPMDIR)
@@ -54,48 +56,52 @@
INCLUDE = -I.. $(INCLUDEPPM) $(INCLUDEPGM) $(INCLUDEPBM)
ALLCFLAGS = $(CFLAGS) $(INCLUDE) $(TIFFDEF) $(TIFFINC)
LIBPNM = libpnm.a
+DEFPNM = pnm.h
PORTBINARIES = fitstopnm giftopnm \
pnmalias pnmarith pnmcat pnmcomp pnmconvol pnmcrop \
pnmcut pnmdepth pnmenlarge pnmfile pnmflip pnmhistmap \
pnminvert pnmnoraw pnmpad pnmpaste \
pnmtile pnmtoddif pnmtofits pnmtops pnmtorast \
- pnmtosgi pnmtosir pnmtoxwd \
- rasttopnm sgitopnm sirtopnm xwdtopnm zeisstopnm
+ pnmtorle pnmtosgi pnmtosir pnmtoxwd \
+ rasttopnm rletopnm sgitopnm sirtopnm xwdtopnm zeisstopnm \
+ pnmsmooth pnmhisteq
MATHBINARIES = pnmgamma pnmnlfilt pnmrotate pnmscale pnmshear
-BINARIES = $(PORTBINARIES) $(MATHBINARIES) $(TIFFBINARIES)
-SCRIPTS = anytopnm pnmindex pnmmargin pnmsmooth pstopnm
+PNGBINARIES = pngtopnm pnmtopng
+BINARIES = $(PORTBINARIES) $(MATHBINARIES) $(PNGBINARIES) $(TIFFBINARIES)
+SCRIPTS = anytopnm pnmindex pnmmargin pstopnm
PORTOBJECTS = fitstopnm.o giftopnm.o \
pnmalias.o pnmarith.o pnmcat.o pnmcomp.o pnmconvol.o pnmcrop.o \
pnmcut.o pnmdepth.o pnmenlarge.o pnmfile.o pnmflip.o pnmhistmap.o \
- pnminvert.o pnmnoraw.o pnmpad.o pnmpaste.o \
+ pnmhisteq.o pnminvert.o pnmnoraw.o pnmpad.o pnmpaste.o\
pnmtile.o pnmtoddif.o pnmtofits.o pnmtops.o pnmtorast.o \
pnmtosgi.o pnmtosir.o pnmtoxwd.o \
rasttopnm.o sgitopnm.o sirtopnm.o xwdtopnm.o zeisstopnm.o \
+ pnmsmooth.o pnmhisteq.o \
pnmgamma.o pnmnlfilt.o pnmrotate.o pnmscale.o pnmshear.o
-OBJECTS = $(PORTOBJECTS) $(TIFFOBJECTS)
+OBJECTS = $(PORTOBJECTS)
MANUALS1 = $(BINARIES) $(SCRIPTS)
MANUALS3 = libpnm
MANUALS5 = pnm
-#all: binaries
-all: merge
-#install: install.bin
-install: install.merge
+all: binaries
+#all: merge
+install: install.bin
+#install: install.merge
binaries: $(BINARIES)
install.bin: binaries $(SCRIPTS)
cd $(INSTALLBINARIES) ; rm -f $(BINARIES)
- cp $(BINARIES) $(INSTALLBINARIES)
+ install -c -s -m 0755 $(BINARIES) $(INSTALLBINARIES)
cd $(INSTALLSCRIPTS) ; rm -f $(SCRIPTS)
- cp $(SCRIPTS) $(INSTALLSCRIPTS)
- cd $(INSTALLSCRIPTS) ; chmod +x $(SCRIPTS)
-
+ install -c -m 0755 $(SCRIPTS) $(INSTALLSCRIPTS)
+ install -c -m 0644 $(LIBPNM) $(INSTALLLIBS)
+ install -c -m 0644 $(DEFPNM) $(INSTALLDEFS)
merge: pnmmerge
pnmmerge: pnmmerge.c $(OBJECTS) $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
@@ -128,16 +134,22 @@
# Rules for plain programs.
-$(PORTBINARIES) $(TIFFBINARIES): pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM) $(TIFFLIB)
- $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM) $(TIFFLIB)
+$(PORTBINARIES): $(DEFPNM) $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
+ $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
+
+$(PNGBINARIES): $(DEFPNM) $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
+ $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM) -L${LOCALBASE}/lib -lpng -lz -lm
+
+$(TIFFBINARIES): $(DEFPNM) $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
+ $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM) $(TIFFLIB) -lm -lz
# Rule for math-dependent programs.
-$(MATHBINARIES): pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) \
+$(MATHBINARIES): $(DEFPNM) $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPNM) \
$(LIBPPM) $(LIBPGM) $(LIBPBM)
$(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c -lm $(LIBPNM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
# Rule for objects.
-$(OBJECTS): pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM)
+$(OBJECTS): $(DEFPNM) $(DEFPPM) $(DEFPGM) $(DEFPBM)
$(CC) $(ALLCFLAGS) "-Dmain=$*_main" -c $*.c
# And libraries.
@@ -153,15 +165,15 @@
ar rc $(LIBPNM) libpnm1.o libpnm2.o libpnm3.o libpnm4.o
-ranlib $(LIBPNM)
-libpnm1.o: pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) libpnm1.c
+libpnm1.o: $(DEFPNM) $(DEFPPM) $(DEFPGM) $(DEFPBM) libpnm1.c
$(CC) $(ALLCFLAGS) -c libpnm1.c
-libpnm2.o: pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) libpnm2.c $(DEFLIBPPM) \
+libpnm2.o: $(DEFPNM) $(DEFPPM) $(DEFPGM) $(DEFPBM) libpnm2.c $(DEFLIBPPM) \
$(DEFLIBPGM) $(DEFLIBPBM)
$(CC) $(ALLCFLAGS) -c libpnm2.c
-libpnm3.o: pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) libpnm3.c $(DEFLIBPPM) \
+libpnm3.o: $(DEFPNM) $(DEFPPM) $(DEFPGM) $(DEFPBM) libpnm3.c $(DEFLIBPPM) \
$(DEFLIBPGM) $(DEFLIBPBM)
$(CC) $(ALLCFLAGS) -c libpnm3.c
-libpnm4.o: pnm.h $(DEFPPM) $(DEFPGM) $(DEFPBM) rast.h libpnm4.c
+libpnm4.o: $(DEFPNM) $(DEFPPM) $(DEFPGM) $(DEFPBM) rast.h libpnm4.c
$(CC) $(ALLCFLAGS) -c libpnm4.c
# Other dependencies.
@@ -202,6 +214,8 @@
tifftopnm tifftopnm.o: tifftopnm.c
xwdtopnm xwdtopnm.o: xwdtopnm.c x10wd.h x11wd.h
zeisstopnm zeisstopnm.o: zeisstopnm.c
+pnmhisteq pnmhisteq.o: pnmhisteq.c
+pnmsmooth pnmsmooth.o: pnmsmooth.c
clean:
- -rm -f *.o *.a *.cat *~ core $(BINARIES) pnmmerge
+ -rm -f *.o *.a *.cat *~ core *.core $(BINARIES) pnmmerge

View File

@ -0,0 +1,50 @@
--- pnm/anytopnm.orig Mon Oct 4 10:11:29 1993
+++ pnm/anytopnm Sun Jan 10 23:48:40 1999
@@ -53,7 +53,7 @@
;;
*GIF* )
- giftoppm "$file"
+ giftopnm "$file"
break
;;
@@ -82,6 +82,15 @@
break
;;
+ *JPEG* | *JFIF* )
+ djpeg "$file"
+ ;;
+
+ *PNG* )
+ pngtopnm "$file"
+ break
+ ;;
+
* )
# Can't figure out the file type from the magic number,
# try the extension.
@@ -130,7 +139,7 @@
fitstopgm "$file"
;;
*.gif | *.gif.* )
- giftoppm "$file"
+ giftopnm "$file"
;;
*.iff | *.iff.* | *.ilbm | *.ilbm.* )
ilbmtoppm "$file"
@@ -168,6 +177,13 @@
*.ybm | *.ybm.* | *.face | *.face.* )
ybmtopbm "$file"
;;
+ *.JPEG | *.jpeg | *.jpg | *.JPG )
+ djpeg "$file"
+ ;;
+ *.png | *.PNG )
+ pngtopnm "$file"
+ break
+ ;;
* )
echo "$0: unknown file type" 1>&2
exit 1

View File

@ -0,0 +1,11 @@
--- pnm/pnmarith.1.orig Mon Oct 4 10:11:34 1993
+++ pnm/pnmarith.1 Sun Jan 10 23:48:40 1999
@@ -4,7 +4,7 @@
pnmarith - perform arithmetic on two portable anymaps
.SH SYNOPSIS
.B pnmarith
-.BR -add | -subtract | -multiply | -difference
+.BR -add | -subtract | -multiply | -difference | -minimum | -maximum.
.I pnmfile1 pnmfile2
.SH DESCRIPTION
Reads two portable anymaps as input.

View File

@ -0,0 +1,66 @@
--- pnm/pnmarith.c.orig Wed Jan 5 11:04:53 1994
+++ pnm/pnmarith.c Sun Jan 10 23:48:40 1999
@@ -29,7 +29,8 @@
xelval maxval1, maxval2, maxval3;
int argn, rows1, cols1, format1, rows2, cols2, format2, format3, row, col;
char function;
- char* usage = "-add|-subtract|-multiply|-difference pnmfile1 pnmfile2";
+ char* usage =
+"-add|-subtract|-multiply|-difference|-minimum|-maximum pnmfile1 pnmfile2";
pnm_init( &argc, argv );
@@ -48,6 +49,10 @@
function = '*';
else if ( pm_keymatch( argv[argn], "-difference", 2 ) )
function = 'D';
+ else if ( pm_keymatch( argv[argn], "-minimum", 2 ) )
+ function = 'N';
+ else if ( pm_keymatch( argv[argn], "-maximum", 2 ) )
+ function = 'X';
else
pm_usage( usage );
++argn;
@@ -112,7 +117,7 @@
pnm_promoteformatrow(
xelrow2, cols1, maxval2, format2, maxval3, format3 );
- for ( col = 0, x1P = xelrow1, x2P = xelrow2;
+ for ( col = 0, x1P = xelrow1, x2P = xelrow2;
col < cols1; ++col, ++x1P, ++x2P )
{
switch ( PNM_FORMAT_TYPE(format3) )
@@ -153,6 +158,18 @@
b1 = (b1>b2)?(b1-b2):(b2-b1);
break;
+ case 'N':
+ r1 = (r1>r2)?(r2):(r1);
+ g1 = (g1>g2)?(g2):(g1);
+ b1 = (b1>b2)?(b2):(b1);
+ break;
+
+ case 'X':
+ r1 = (r1>r2)?(r1):(r2);
+ g1 = (g1>g2)?(g1):(g2);
+ b1 = (b1>b2)?(b1):(b2);
+ break;
+
default:
pm_error( "can't happen" );
}
@@ -188,6 +205,14 @@
case 'D':
g1 = (g1>g2)?(g1-g2):(g2-g1);
+ break;
+
+ case 'N':
+ g1 = (g1>g2)?(g2):(g1);
+ break;
+
+ case 'X':
+ g1 = (g1>g2)?(g1):(g2);
break;
default:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,164 @@
--- pnm/pnmhisteq.1.orig Sun Jan 10 23:48:41 1999
+++ pnm/pnmhisteq.1 Sun Jan 10 23:48:41 1999
@@ -0,0 +1,161 @@
+.TH pnmhisteq 1 "19 March 1995"
+.IX "pnmhisteq command"
+.IX histogram
+.SH NAME
+pnmhisteq \- histogram equalise a portable anymap
+.SH SYNOPSIS
+.na
+.B pnmhisteq
+'ti 15
+.RB [ \-gray ]
+.RB [ \-rmap
+.IR pgmfile ]
+.RB [ \-wmap
+.IR pgmfile ]
+.RB [ \-verbose ]
+.RI [ pnmfile ]
+.ad
+.SH DESCRIPTION
+.B pnmhisteq
+increases the contrast of a portable graymap or pixmap through the
+technique of
+.IR "histogram equalisation" [1].
+A histogram of the luminance of pixels in the map is computed, from
+which a transfer function is calculated which spreads out intensity levels
+around histogram peaks and compresses them at troughs. This has the
+effect of using the available levels of intensity more efficiently and
+thereby increases the detail visible in the image.
+.PP
+Mathematically, if
+.I N[i]
+is the number of pixels of luminosity
+.I i
+in the image and
+.I T
+is the total number of pixels, luminosity
+.I j
+is replaced by:
+.PP
+.NF
+.vs 9p
+ j
+ ---
+ \\
+ \> N[i] / T
+ \/
+ ---
+ i=0
+.vs
+.FI
+.PP
+If you're processing a related set of images, for example frames of an
+animation, it's generally best to apply the same intensity map to
+every frame, since otherwise you'll get distracting frame-to-frame
+changes in the brightness of objects.
+.BR pnmhisteq 's
+.B \-wmap
+option
+allows you to save, as a portable graymap, the luminosity map computed
+from an image (usually a composite of the images you intend
+to process created with
+.BR pnmcat ).
+Then, you can subsequently process each of the individual images using
+the luminosity map saved in the file, supplied with the
+.B \-rmap
+option.
+.SH OPTIONS
+.TP 10
+.B \-gray
+When processing a pixmap, only gray pixels (those with identical red,
+green, and blue values) are included in the histogram and modified
+in the output image. This is a special purpose option intended
+for images where the actual data are gray scale, with
+colour annotations you don't want modified. Weather
+satellite images that show continent outlines in colour are best
+processed using this option. The option has no effect when the input
+is a graymap.
+.TP
+.BI \-rmap " mapfile"
+Process the image using the luminosity map specified by the portable
+graymap
+.I mapfile.
+The graymap, usually created by an earlier run of
+.B pnmhisteq
+with the
+.B \-wmap
+option, contains a single row with number of columns equal to
+the
+.I maxval
+(greatest intensity) of the image. Each pixel in the image is
+transformed by looking up its luminosity in the corresponding
+column in the map file and changing it to the value
+given by that column.
+.TP
+.BI \-wmap " mapfile"
+Creates a portable graymap,
+.I mapfile,
+containing the luminosity map computed from the histogram of the
+input image. This map file can be read on subsequent runs of
+.B pnmhisteq
+with the
+.B \-rmap
+option, allowing a group of images to be processed with
+an identical map.
+.TP
+.B \-verbose
+Prints the histogram and luminosity map on standard error.
+.PP
+All flags can be abbreviated to their shortest unique prefix.
+.SH BUGS
+Histogram equalisation is effective for increasing the visible detail
+in scientific imagery and in some continuous-tone pictures. It is
+often too drastic, however, for scanned halftone images, where it
+does an excellent job of making halftone artifacts apparent. You
+might want to experiment with
+.BR pgnnorm ,
+.BR ppmnorm ,
+and
+.B pnmgamma
+for more subtle contrast enhancement.
+.PP
+The luminosity map file supplied by the
+.B \-rmap
+option must have the same
+.I maxval
+as the input image. This is always the case when the
+map file was created by the
+.B \-wmap
+option of
+.BR pnmhisteq .
+If this restriction causes a problem, simply adjust the
+.I maxval
+of the map with
+.B pnmdepth
+to agree with the input image.
+.PP
+If the input is a PBM file (on which histogram equalisation is an
+identity operation), the only effect of passing the file through
+.B pnmhisteq
+will be the passage of time.
+.SH "SEE ALSO"
+.PD
+.BR pgmnorm (1),
+.BR pnm (5),
+.BR pnmcat (1),
+.BR pnmdepth (1),
+.BR pnmgamma (1),
+.BR pnmnorm (1)
+.TP 5
+[1]
+Russ, John C. The Image Processing Handbook.
+Boca Raton: CRC Press, 1992. Pages 105-110.
+.ne 10
+.SH AUTHOR
+.ce 2
+Copyright (C) 1995 by John Walker (kelvin@fourmilab.ch).
+WWW home page: http://www.fourmilab.ch/
+.PP
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+without any conditions or restrictions. This software is provided ``as
+is'' without express or implied warranty.

View File

@ -0,0 +1,374 @@
--- pnm/pnmhisteq.c.orig Sun Jan 10 23:48:41 1999
+++ pnm/pnmhisteq.c Sun Jan 10 23:48:41 1999
@@ -0,0 +1,371 @@
+/*
+ pnmhisteq.c
+
+ Equalise histogram for a PGM or PPM file
+
+ Options: -gray: modify gray pixels only; leave colours unchanged
+ -rmap fn: read luminosity map from PGM file fn
+ -wmap wn: write luminosity map to PGM file fn
+ -verbose: print histogram and luminosity map
+
+ Accepts PGM and PPM as input. PBM input is allowed, but histogram
+ equalisation does not modify a PBM file.
+
+ by John Walker (kelvin@fourmilab.ch) -- March MVM.
+ WWW home page: http://www.fourmilab.ch/
+
+ Copyright (C) 1995 by John Walker
+
+ Permission to use, copy, modify, and distribute this software and
+ its documentation for any purpose and without fee is hereby
+ granted, without any conditions or restrictions. This software is
+ provided "as is" without express or implied warranty.
+
+*/
+
+#include "pnm.h"
+
+/* Prototypes */
+
+static void hsv_rgb ARGS((double h, double s, double v,
+ double *r, double *g, double *b));
+static void rgb_hsv ARGS((double r, double g, double b,
+ double *h, double *s, double *v));
+
+/* HSV_RGB -- Convert HSV colour specification to RGB intensities.
+ Hue is specified as a real value from 0 to 360,
+ Saturation and Intensity as reals from 0 to 1. The
+ RGB components are returned as reals from 0 to 1. */
+
+static void hsv_rgb(h, s, v, r, g, b)
+ double h, s, v;
+ double *r, *g, *b;
+{
+ int i;
+ double f, p, q, t;
+
+ if (s == 0) {
+ *r = *g = *b = v;
+ } else {
+ if (h == 360.0) {
+ h = 0;
+ }
+ h /= 60.0;
+
+ i = h;
+ f = h - i;
+ p = v * (1.0 - s);
+ q = v * (1.0 - (s * f));
+ t = v * (1.0 - (s * (1.0 - f)));
+ switch (i) {
+
+ case 0:
+ *r = v;
+ *g = t;
+ *b = p;
+ break;
+
+ case 1:
+ *r = q;
+ *g = v;
+ *b = p;
+ break;
+
+ case 2:
+ *r = p;
+ *g = v;
+ *b = t;
+ break;
+
+ case 3:
+ *r = p;
+ *g = q;
+ *b = v;
+ break;
+
+ case 4:
+ *r = t;
+ *g = p;
+ *b = v;
+ break;
+
+ case 5:
+ *r = v;
+ *g = p;
+ *b = q;
+ break;
+ }
+ }
+}
+
+/* RGB_HSV -- Map R, G, B intensities in the range from 0 to 1 into
+ Hue, Saturation, and Value: Hue from 0 to 360,
+ Saturation from 0 to 1, and Value from 0 to 1.
+ Special case: if Saturation is 0 (it's a grey scale
+ tone), Hue is undefined and is returned as -1.
+
+ This follows Foley & van Dam, section 17.4.4. */
+
+static void rgb_hsv(r, g, b, h, s, v)
+ double r, g, b;
+ double *h, *s, *v;
+{
+ double imax = max(r, max(g, b)),
+ imin = min(r, min(g, b)),
+ rc, gc, bc;
+
+ *v = imax;
+ if (imax != 0) {
+ *s = (imax - imin) / imax;
+ } else {
+ *s = 0;
+ }
+
+ if (*s == 0) {
+ *h = -1;
+ } else {
+ rc = (imax - r) / (imax - imin);
+ gc = (imax - g) / (imax - imin);
+ bc = (imax - b) / (imax - imin);
+ if (r == imax) {
+ *h = bc - gc;
+ } else if (g == imax) {
+ *h = 2.0 + rc - bc;
+ } else {
+ *h = 4.0 + gc - rc;
+ }
+ *h *= 60.0;
+ if (*h < 0.0) {
+ *h += 360.0;
+ }
+ }
+}
+
+int main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ FILE *ifp;
+ int argn = 1, i, j, verbose = 0, mono_only = 0;
+ gray lmin, lmax;
+ gray **lumamap; /* Luminosity map */
+ long *lumahist; /* Histogram of luminosity values */
+ int rows, hist_cols; /* Rows, columns of input image */
+ xelval maxval; /* Maxval of input image */
+ int format; /* Format indicator (PBM/PGM/PPM) */
+ xel** xels; /* Pixel array */
+ unsigned long pixels = 0, pixsum = 0, maxluma = 0;
+ double lscale;
+ xel *grayrow;
+ pixel *pixrow;
+ FILE *rmap = NULL, *wmap = NULL;
+ char *usage = "[-gray] [-verbose] [-rmap pgmfile] [-wmap pgmfile] [pnmfile]";
+
+ pnm_init(&argc, argv);
+
+ /* Check for flags. */
+
+ while (argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0') {
+ if (pm_keymatch(argv[argn], "-gray", 1)) {
+ mono_only = 1;
+ } else if (pm_keymatch(argv[argn], "-verbose", 1)) {
+ verbose = 1;
+ } else if (pm_keymatch(argv[argn], "-rmap", 1)) {
+ if (rmap != NULL) {
+ pm_error("already specified an input map");
+ }
+ argn++;
+ if (argn == argc || strcmp(argv[argn], "-") == 0) {
+ pm_usage(usage);
+ }
+ rmap = pm_openr(argv[argn]);
+ } else if (pm_keymatch(argv[argn], "-wmap", 1)) {
+ if (wmap != NULL) {
+ pm_error("already specified an output map");
+ }
+ argn++;
+ if (argn == argc) {
+ pm_usage(usage);
+ }
+ wmap = pm_openw(argv[argn]);
+ } else {
+ pm_usage(usage);
+ }
+ argn++;
+ }
+
+ if (--argc > argn) {
+ pm_usage(usage);
+ } else if (argc == argn) {
+ ifp = pm_openr(argv[argn]);
+ } else {
+ ifp = stdin;
+ }
+
+ xels = pnm_readpnm(ifp, &hist_cols, &rows, &maxval, &format);
+ pm_close(ifp);
+
+ /* Allocate histogram and luminosity map arrays. If the
+ user has specified an input map file, read it in at
+ this point. */
+
+ lumahist = (long *) pm_allocrow(maxval + 1, sizeof(long));
+ bzero((char *) lumahist, (maxval + 1) * sizeof(long));
+
+ if (rmap == NULL) {
+ lumamap = pgm_allocarray(maxval + 1, 1);
+ } else {
+ int rmcols, rmrows;
+ gray rmmaxv;
+
+ lumamap = pgm_readpgm(rmap, &rmcols, &rmrows, &rmmaxv);
+ if (rmmaxv != maxval) {
+ pm_error("maxval in map file (%d) different from input (%d)",
+ rmmaxv, maxval);
+ }
+ if (rmrows != 1 || rmcols != rmmaxv) {
+ pm_error("map size (%d by %d) wrong; must be (%d by 1)",
+ rmcols, rmrows, maxval);
+ }
+ }
+
+ /* Scan the image and build the luminosity histogram. If
+ the input is a PPM, we calculate the luminosity of each
+ pixel from its RGB components. */
+
+ lmin = maxval;
+ lmax = 0;
+ if (PNM_FORMAT_TYPE(format) == PGM_TYPE ||
+ PNM_FORMAT_TYPE(format) == PBM_TYPE) {
+
+ /* Compute intensity histogram */
+
+ pixels = ((unsigned long) rows) * ((unsigned long) hist_cols);
+ for (i = 0; i < rows; i++) {
+ xel *grayrow = xels[i];
+ for (j = 0; j < hist_cols; j++) {
+ gray l = PNM_GET1(grayrow[j]);
+ lmin = min(lmin, l);
+ lmax = max(lmax, l);
+ lumahist[l]++;
+ }
+ }
+ } else if (PNM_FORMAT_TYPE(format) == PPM_TYPE) {
+ for (i = 0; i < rows; i++) {
+ pixel *pixrow = (pixel *) xels[i];
+
+ for (j = 0; j < hist_cols; j++) {
+ if (!mono_only ||
+ ((PPM_GETR(pixrow[j]) == PPM_GETG(pixrow[j])) &&
+ (PPM_GETR(pixrow[j]) == PPM_GETB(pixrow[j])))) {
+ gray l = (gray) PPM_LUMIN(pixrow[j]);
+ lmin = min(lmin, l);
+ lmax = max(lmax, l);
+ lumahist[l]++;
+ pixels++;
+ }
+ }
+ }
+ } else {
+ pm_error("unknown input format");
+ }
+
+ /* The PGM and PPM branches rejoin here to calculate the
+ luminosity mapping table which gives the histogram-equalised
+ luminosity for each original luminosity. */
+
+ /* Calculate initial histogram equalisation curve. */
+
+ for (i = 0; i <= (int) maxval; i++) {
+
+ /* Yick. If PGM_BIGGRAYS is defined (I thought they were little
+ guys, about four foot, with funny eyes...) the following
+ calculation can overflow a 32 bit long. So, we do it in
+ floating point. Since this happens only maxval times, the
+ inefficiency is trivial compared to the every-pixel code above
+ and below. */
+
+ lumamap[0][i] = (gray) (((((double) pixsum * maxval)) / pixels) + 0.5);
+ if (lumahist[i] > 0) {
+ maxluma = i;
+ }
+ pixsum += lumahist[i];
+ }
+
+ /* Normalise so that the brightest pixels are set to
+ maxval. */
+
+ lscale = ((double) maxval) / ((lumahist[maxluma] > 0) ?
+ ((double) lumamap[0][maxluma]) : ((double) maxval));
+ for (i = 0; i <= (int) maxval; i++) {
+ lumamap[0][i] = (gray)
+ min(((long) maxval), ((long) (lumamap[0][i] * lscale + 0.5)));
+ }
+
+ /* If requested, print the luminosity map and original histogram. */
+
+ if (verbose) {
+ fprintf(stderr,
+ " Luminosity map Number of\n Original New Pixels\n");
+ for (i = 0; i <= (int) maxval; i++) {
+ if (lumahist[i] > 0) {
+ fprintf(stderr,"%6d -> %6d %8d\n", i,
+ lumamap[0][i], lumahist[i]);
+ }
+ }
+ }
+
+ switch (PNM_FORMAT_TYPE(format)) {
+ case PBM_TYPE:
+ case PPM_TYPE:
+ for (i = 0; i < rows; i++) {
+ pixrow = (pixel *) xels[i];
+ for (j = 0; j < hist_cols; j++) {
+ if (!mono_only ||
+ ((PPM_GETR(pixrow[j]) == PPM_GETG(pixrow[j])) &&
+ (PPM_GETR(pixrow[j]) == PPM_GETB(pixrow[j])))) {
+ double r, g, b, h, s, v;
+ int iv;
+
+ r = (double) PPM_GETR(pixrow[j]) / ((double) maxval);
+ g = (double) PPM_GETG(pixrow[j]) / ((double) maxval);
+ b = (double) PPM_GETB(pixrow[j]) / ((double) maxval);
+ rgb_hsv(r, g, b, &h, &s, &v);
+ iv = (int) ((v * maxval) + 0.5);
+
+ if (iv > ((int) maxval)) {
+ iv = maxval;
+ }
+ v = ((double) lumamap[0][iv]) / ((double) maxval);
+ if (v > 1.0) {
+ v = 1.0;
+ }
+ hsv_rgb(h, s, v, &r, &g, &b);
+ PPM_ASSIGN(pixrow[j], (int) (r * maxval),
+ (int) (g * maxval), (int) (b * maxval));
+ }
+ }
+ }
+ break;
+
+ case PGM_TYPE:
+ for (i = 0; i < rows; i++) {
+ grayrow = xels[i];
+ for (j = 0; j < hist_cols; j++) {
+ PNM_ASSIGN1(grayrow[j], lumamap[0][PNM_GET1(grayrow[j])]);
+ }
+ }
+ break;
+ }
+
+ pnm_writepnm(stdout, xels, hist_cols, rows, maxval, format, 0);
+
+ /* If requested, save the map as a PGM file. */
+
+ if (wmap != NULL) {
+ pgm_writepgm(wmap, lumamap, maxval, 1, maxval, 0);
+ fclose(wmap);
+ }
+
+ return 0;
+}

View File

@ -0,0 +1,29 @@
--- pnm/pnmmerge.c.orig Mon Jan 31 12:31:47 1994
+++ pnm/pnmmerge.c Sun Jan 10 23:48:40 1999
@@ -30,6 +30,10 @@
{
++argv;
--argc;
+ if(!*argv) {
+ fprintf(stderr, "Usage: pnmmerge pnm_program_name [args ...]\n");
+ exit(1);
+ }
goto again;
}
@@ -51,6 +55,7 @@
TRY("pnmgamma", pnmgamma_main);
TRY("pnminvert", pnminvert_main);
TRY("pnmhistmap", pnmhistmap_main);
+ TRY("pnmhisteq", pnmhisteq_main);
TRY("pnmnlfilt", pnmnlfilt_main);
TRY("pnmnoraw", pnmnoraw_main);
TRY("pnmpaste", pnmpaste_main);
@@ -76,6 +81,7 @@
#endif /*LIBTIFF*/
TRY("xwdtopnm", xwdtopnm_main);
TRY("zeisstopnm", zeisstopnm_main);
+ TRY("pnmsmooth", pnmsmooth_main);
(void) fprintf(
stderr, "pnmmerge: \"%s\" is an unknown PNM program!\n", cp );

View File

@ -0,0 +1,52 @@
--- pnm/pnmsmooth.1.orig Mon Oct 4 10:11:56 1993
+++ pnm/pnmsmooth.1 Sun Jan 10 23:48:40 1999
@@ -1,25 +1,42 @@
-.TH pnmsmooth 1 "13 January 1991"
+.TH pnmsmooth 1 "4 December 1994"
.IX pnmsmooth
.SH NAME
pnmsmooth - smooth out an image
.SH SYNOPSIS
.B pnmsmooth
+.RB [ -size
+.IR width
+.IR height ]
+.RB [ -dump
+.IR dumpfile ]
.RI [ pnmfile ]
.SH DESCRIPTION
Smooths out an image by replacing each pixel with the
-average of its nine immediate neighbors.
+average of its width X height neighbors.
.IX smoothing
.IX anti-aliasing
-It is implemented as a simple script using
+It is implemented as a C progam that generates a PGM convolution matrix
+and then invokes
.IR pnmconvol .
.IX pnmconvol
+.SH OPTIONS
+.TP
+.B -size width height
+Specifies the size of the convolution matrix.
+Default size is a 3x3 matrix.
+Width and height sizes must be odd.
+Maximum size of convolution matrix is limited by the maximum value for a
+pixel such that (width * height * 2) must not exceed the maximum pixel value.
+.TP
+.B -dump dumpfile
+Generates and saves the convolution file only.
+Use of this option does not invoke pnmconvol.
.SH "SEE ALSO"
pnmconvol(1), pnm(5)
-.SH BUGS
-It's a script.
-Scripts are not portable to non-Unix environments.
-.SH AUTHOR
+.SH AUTHORS
Copyright (C) 1989, 1991 by Jef Poskanzer.
+.br
+Converted from script to C program December 1994 by Mike Burns (burns@chem.psu.edu).
.\" Permission to use, copy, modify, and distribute this software and its
.\" documentation for any purpose and without fee is hereby granted, provided
.\" that the above copyright notice appear in all copies and that both that

View File

@ -0,0 +1,24 @@
--- pnm/pnmsmooth.README.orig Sun Jan 10 23:48:41 1999
+++ pnm/pnmsmooth.README Sun Jan 10 23:48:41 1999
@@ -0,0 +1,21 @@
+README for pnmsmooth.c 2.0
+
+This is a replacement for the pnmsmooth script that is distributed with
+pbmplus/netpbm. This version of pnmsmooth is written as a C program rather
+than a shell script. It accepts command line arguments to specify a size
+other than 3x3 for the convolution matrix and an argument for dumping the
+resultant convolution matrix as a PGM file. By default it uses the same 3x3
+matrix size as the pnmsmooth script and can be used as a direct replacement.
+
+Also included are an updated man page and a patch file to update the Imakefile
+in the pnm directory. You may want to apply the patches by hand if you have
+already modified the Imakefile to add other new programs. You will then
+have to remake the Makefiles and then type 'make all' in the pnm directory.
+
+- Mike
+
+----------------------------------------------------------------------------
+Mike Burns System Administrator
+burns@chem.psu.edu Department of Chemistry
+(814) 863-2123 The Pennsylvania State University
+

View File

@ -0,0 +1,174 @@
--- pnm/pnmsmooth.c.orig Sun Jan 10 23:48:41 1999
+++ pnm/pnmsmooth.c Sun Jan 10 23:48:41 1999
@@ -0,0 +1,171 @@
+/* pnmsmooth.c - smooth out an image by replacing each pixel with the
+** average of its width x height neighbors.
+**
+** Version 2.0 December 5, 1994
+**
+** Copyright (C) 1994 by Mike Burns (burns@chem.psu.edu)
+**
+** Permission to use, copy, modify, and distribute this software and its
+** documentation for any purpose and without fee is hereby granted, provided
+** that the above copyright notice appear in all copies and that both that
+** copyright notice and this permission notice appear in supporting
+** documentation. This software is provided "as is" without express or
+** implied warranty.
+*/
+
+/* Version 2.0 - December 5, 1994
+** ------------------------------
+** Rewrote as a C program that accepts a few options instead of a shell
+** script with no options.
+**
+*/
+
+#include "pnm.h"
+#include <sys/wait.h>
+
+#define TRUE 1
+#define FALSE 0
+
+int
+main( argc, argv )
+ int argc;
+ char* argv[];
+ {
+ FILE *cofp;
+ char *tempfn;
+ char *pnmfn;
+ int argn;
+ int col, row;
+ int format, forceplain;
+ int cols, rows;
+ int newmaxval; /* normally xelval, but want int here */
+ xelval g;
+ xel *outputrow;
+ int pid, status;
+ int DUMPFLAG = FALSE;
+ char *usage = "[-size width height] [-dump dumpfile] [pnmfile]";
+
+ pnm_init( &argc, argv );
+
+ /* set up defaults */
+ cols = 3;
+ rows = 3;
+ format = PGM_FORMAT;
+ forceplain = 1;
+ pnmfn = (char *) 0; /* initialize to NULL just in case */
+
+ argn = 1;
+ while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' )
+ {
+ if ( pm_keymatch( argv[argn], "-size", 2 ) )
+ {
+ ++argn;
+ if ( argn+1 >= argc )
+ {
+ pm_message( "incorrect number of arguments for -size option" );
+ pm_usage( usage );
+ }
+ else if ( argv[argn][0] == '-' || argv[argn+1][0] == '-' )
+ {
+ pm_message( "invalid arguments to -size option: %s %s",
+ argv[argn], argv[argn+1] );
+ pm_usage( usage );
+ }
+ if ( (cols = atoi(argv[argn])) == 0 )
+ pm_error( "invalid width size specification: %s", argv[argn] );
+ ++argn;
+ if ( (rows = atoi(argv[argn])) == 0 )
+ pm_error( "invalid height size specification: %s",argv[argn] );
+ if ( cols % 2 != 1 || rows % 2 != 1 )
+ pm_error( "the convolution matrix must have an odd number of rows and columns" );
+ }
+ else if ( pm_keymatch( argv[argn], "-dump", 2 ) )
+ {
+ ++argn;
+ if ( argn >= argc )
+ {
+ pm_message( "missing argument to -dump option" );
+ pm_usage( usage );
+ }
+ else if ( argv[argn][0] == '-' )
+ {
+ pm_message( "invalid argument to -dump option: %s",
+ argv[argn] );
+ pm_usage( usage );
+ }
+ cofp = pm_openw( argv[argn] );
+ DUMPFLAG = TRUE;
+ }
+ else
+ pm_usage( usage );
+ ++argn;
+ }
+
+ /* Only get file name if given on command line to pass through to
+ ** pnmconvol. If filename is coming from stdin, pnmconvol will read it.
+ */
+ if ( argn < argc )
+ {
+ pnmfn = argv[argn];
+ ++argn;
+ }
+
+ if ( argn != argc )
+ pm_usage( usage );
+
+
+ if ( !DUMPFLAG )
+ {
+ if ( (tempfn = tmpnam((char *) 0)) == NULL )
+ pm_error( "could not create temporary file name" );
+ if ( (cofp = pm_openw(tempfn)) == NULL )
+ pm_error( "could not create temporary convolution file" );
+ }
+
+ /* Generate mean value for all pixels in convolution matrix. */
+ g = rows * cols + 1;
+
+ /* Make sure newmaxval is not larger than PNM_MAXMAXVAL or else
+ ** newmaxval will overrun its defined data size and become garbage.
+ */
+ newmaxval = ( rows * cols ) * 2;
+ if ( newmaxval > PNM_MAXMAXVAL )
+ pm_error( "generated maxval is too large: %d", newmaxval );
+
+ pnm_writepnminit( cofp, cols, rows, newmaxval, format, forceplain );
+ outputrow = pnm_allocrow( cols );
+
+ for ( row = 0; row < rows; ++ row )
+ {
+ for ( col = 0; col < cols; ++col )
+ PNM_ASSIGN1( outputrow[col], g );
+ pnm_writepnmrow( cofp, outputrow, cols, newmaxval, format, forceplain );
+ }
+ pm_close( cofp );
+ pnm_freerow( outputrow );
+
+ /* If we're only going to dump the file, now is the time to stop. */
+ if ( DUMPFLAG )
+ exit( 0 );
+
+ /* fork a child process */
+ if ( (pid = fork()) < 0 )
+ pm_error( "fork" );
+
+ /* child process executes following code */
+ if ( pid == 0 )
+ {
+ /* If pnmfile name is not given on command line, then pnmfn will be
+ ** (char *) 0 and the arglist will terminate there.
+ */
+ execlp( "pnmconvol", "pnmconvol", tempfn, pnmfn, (char *) 0 );
+ pm_error( "error executing pnmconvol command" );
+ }
+
+ /* wait for child to finish */
+ while ( wait(&status) != pid )
+ ;
+
+ unlink( tempfn );
+ exit( 0 );
+ }

View File

@ -0,0 +1,23 @@
--- pnm/pnmsmooth.orig.orig Sun Jan 10 23:48:41 1999
+++ pnm/pnmsmooth.orig Sun Jan 10 23:48:41 1999
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# pnmsmooth - smooth out an image by replacing each xel with the
+# average of its nine immediate neighbors
+
+tmp=/tmp/psm.$$
+rm -f $tmp
+
+cat > $tmp << MOO
+P2
+3 3
+18
+10 10 10
+10 10 10
+10 10 10
+MOO
+
+pnmconvol $tmp ${1+"$@"}
+
+rm -f $tmp

View File

@ -0,0 +1,38 @@
--- pnm/pnmtotiff.c.orig Thu Jan 27 17:59:25 1994
+++ pnm/pnmtotiff.c Sun Jan 10 23:48:40 1999
@@ -196,6 +196,7 @@
samplesperpixel = 1;
bitspersample = pm_maxvaltobits( maxval );
photometric = PHOTOMETRIC_MINISBLACK;
+ i = 8 / bitspersample;
bytesperrow = ( cols + i - 1 ) / i;
}
else
@@ -276,20 +277,20 @@
for ( col = 0, xP = xels[row], tP = buf;
col < cols; ++col, ++xP )
{
- register unsigned char s;
+ register xelval s;
s = PPM_GETR( *xP );
if ( maxval != 255 )
- s = (long) s * 255 / maxval;
- *tP++ = s;
+ s = s * 255 / maxval;
+ *tP++ = (unsigned char)s;
s = PPM_GETG( *xP );
if ( maxval != 255 )
- s = (long) s * 255 / maxval;
- *tP++ = s;
+ s = s * 255 / maxval;
+ *tP++ = (unsigned char)s;
s = PPM_GETB( *xP );
if ( maxval != 255 )
- s = (long) s * 255 / maxval;
- *tP++ = s;
+ s = s * 255 / maxval;
+ *tP++ = (unsigned char)s;
}
}
else

View File

@ -0,0 +1,113 @@
--- pnm/tifftopnm.c.orig Mon Oct 4 10:12:01 1993
+++ pnm/tifftopnm.c Sun Jan 10 23:48:40 1999
@@ -54,7 +54,7 @@
int headerdump;
register u_char sample;
register int bitsleft;
- unsigned short bps, spp, photomet;
+ unsigned short bps, spp, photomet, planarconfig;
unsigned short* redcolormap;
unsigned short* greencolormap;
unsigned short* bluecolormap;
@@ -101,6 +101,13 @@
spp = 1;
if ( ! TIFFGetField( tif, TIFFTAG_PHOTOMETRIC, &photomet ) )
pm_error( "error getting photometric" );
+ if( spp > 1 ){
+ if ( ! TIFFGetField( tif, TIFFTAG_PLANARCONFIG, &planarconfig ) )
+ pm_error( "error getting planarconfig" );
+ }else{
+ planarconfig = PLANARCONFIG_CONTIG;
+ }
+
switch ( spp )
{
@@ -114,6 +121,18 @@
"can only handle 1-channel gray scale or 1- or 3-channel color" );
}
+ switch( planarconfig )
+ {
+ case PLANARCONFIG_CONTIG:
+ break;
+ case PLANARCONFIG_SEPARATE:
+ if( photomet != PHOTOMETRIC_RGB )
+ pm_error( "can only handle separate planes with RGB data" );
+ break;
+ default:
+ pm_error("Unrecongnized PLANARCONFIG tag!\n");
+ }
+
(void) TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &cols );
(void) TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &rows );
@@ -259,20 +278,54 @@
break;
case PHOTOMETRIC_RGB:
- for ( col = 0; col < cols; ++col, ++xP )
- {
- register xelval r, g, b;
-
- NEXTSAMPLE
- r = sample;
- NEXTSAMPLE
- g = sample;
- NEXTSAMPLE
- b = sample;
- if ( spp == 4 )
- NEXTSAMPLE /* skip alpha channel */
- PPM_ASSIGN( *xP, r, g, b );
- }
+ if( planarconfig == PLANARCONFIG_CONTIG ){
+ for ( col = 0; col < cols; ++col, ++xP )
+ {
+ register xelval r, g, b;
+
+ NEXTSAMPLE
+ r = sample;
+ NEXTSAMPLE
+ g = sample;
+ NEXTSAMPLE
+ b = sample;
+ if ( spp == 4 )
+ NEXTSAMPLE /* skip alpha channel */
+ PPM_ASSIGN( *xP, r, g, b );
+ }
+ }else{
+ /* First clear the value and assign the reds */
+ for ( col = 0; col < cols; ++col, ++xP )
+ {
+ NEXTSAMPLE
+ PPM_ASSIGN( *xP, 0, 0, 0 );
+ PPM_PUTR( *xP, sample );
+ }
+
+ /* Next the greens */
+ if ( TIFFReadScanline( tif, buf, row, 1 ) < 0 )
+ pm_error( "bad data read on green line %d", row );
+ xP = xelrow;
+ inP = buf;
+ bitsleft = 8;
+ for ( col = 0; col < cols; ++col, ++xP )
+ {
+ NEXTSAMPLE
+ PPM_PUTG( *xP, sample );
+ }
+
+ /* And finally the blues */
+ if ( TIFFReadScanline( tif, buf, row, 2 ) < 0 )
+ pm_error( "bad data read on green line %d", row );
+ xP = xelrow;
+ inP = buf;
+ bitsleft = 8;
+ for ( col = 0; col < cols; ++col, ++xP )
+ {
+ NEXTSAMPLE
+ PPM_PUTB( *xP, sample );
+ }
+ }
break;
default:

View File

@ -0,0 +1,122 @@
--- ppm/Makefile.orig Mon Jan 31 17:44:34 1994
+++ ppm/Makefile Mon Jan 11 00:18:52 1999
@@ -10,22 +10,24 @@
# implied warranty.
# Default values, usually overridden by top-level Makefile.
-#CC = cc
-CC = gcc -ansi -pedantic -fcombine-regs -fpcc-struct-return
+CC = gcc
+#CC = gcc -ansi -pedantic -fcombine-regs -fpcc-struct-return
#CFLAGS = -O
-CFLAGS = -g
+CFLAGS = -O2
#CFLAGS = -g -O
-#LDFLAGS = -s
-LDFLAGS =
-INSTALLBINARIES = /usr/new/pbm
+LDFLAGS = -s
+#LDFLAGS =
+INSTALLBINARIES = $(PREFIX)/bin
INSTALLSCRIPTS = $(INSTALLBINARIES)
-INSTALLMANUALS1 = /usr/man/mann
+INSTALLMANUALS1 = $(PREFIX)/man/man1
SUFFIXMANUALS1 = 1
-INSTALLMANUALS3 = /usr/man/mann
+INSTALLMANUALS3 = $(PREFIX)/man/man3
SUFFIXMANUALS3 = 3
-INSTALLMANUALS5 = /usr/man/mann
+INSTALLMANUALS5 = $(PREFIX)/man/man5
SUFFIXMANUALS5 = 5
-MANCP = cp
+MANCP = install -c -m 0644
+INSTALLLIBS = $(PREFIX)/lib
+INSTALLDEFS = $(PREFIX)/include
PGMDIR = ../pgm
INCLUDEPGM = -I$(PGMDIR)
@@ -43,6 +45,7 @@
INCLUDE = -I.. $(INCLUDEPGM) $(INCLUDEPBM)
ALLCFLAGS = $(CFLAGS) $(INCLUDE)
LIBPPM = libppm.a
+DEFPPM = ppm.h
PORTBINARIES = bmptoppm gouldtoppm hpcdtoppm ilbmtoppm imgtoppm \
mtvtoppm pcxtoppm pgmtoppm pi1toppm picttoppm \
@@ -85,21 +88,21 @@
MANUALS5 = ppm
-#all: binaries
-all: merge
-#install: install.bin
-install: install.merge
+all: binaries
+#all: merge
+install: install.bin
+#install: install.merge
binaries: $(BINARIES)
install.bin: binaries $(SCRIPTS)
cd $(INSTALLBINARIES) ; rm -f $(BINARIES)
- cp $(BINARIES) $(INSTALLBINARIES)
+ install -c -s -m 0755 $(BINARIES) $(INSTALLBINARIES)
cd $(INSTALLSCRIPTS) ; rm -f $(SCRIPTS)
- cp $(SCRIPTS) $(INSTALLSCRIPTS)
- cd $(INSTALLSCRIPTS) ; chmod +x $(SCRIPTS)
-
+ install -c -m 0755 $(SCRIPTS) $(INSTALLSCRIPTS)
+ install -c -m 0644 $(LIBPPM) $(INSTALLLIBS)
+ install -c -m 0644 $(DEFPPM) $(INSTALLDEFS)
merge: ppmmerge
ppmmerge: ppmmerge.c $(OBJECTS) $(LIBPPM) $(LIBPGM) $(LIBPBM)
@@ -132,15 +135,15 @@
# Rule for plain programs.
-$(PORTBINARIES): ppm.h $(DEFPGM) $(DEFPBM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
+$(PORTBINARIES): $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
$(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPPM) $(LIBPGM) $(LIBPBM)
# Rule for math-dependent programs.
-$(MATHBINARIES): ppm.h $(DEFPGM) $(DEFPBM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
+$(MATHBINARIES): $(DEFPPM) $(DEFPGM) $(DEFPBM) $(LIBPPM) $(LIBPGM) $(LIBPBM)
$(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c -lm $(LIBPPM) $(LIBPGM) $(LIBPBM)
# Rule for objects.
-$(OBJECTS): ppm.h $(DEFPGM) $(DEFPBM)
+$(OBJECTS): $(DEFPPM) $(DEFPGM) $(DEFPBM)
$(CC) $(ALLCFLAGS) "-Dmain=$*_main" -c $*.c
# And libraries.
@@ -155,16 +158,16 @@
libppm5.o bitio.o
-ranlib $(LIBPPM)
-libppm1.o: ppm.h $(DEFPGM) $(DEFPBM) libppm.h libppm1.c
+libppm1.o: $(DEFPPM) $(DEFPGM) $(DEFPBM) libppm.h libppm1.c
$(CC) $(ALLCFLAGS) -c libppm1.c
-libppm2.o: ppm.h $(DEFPGM) $(DEFPBM) libppm.h libppm2.c $(DEFLIBPGM) \
+libppm2.o: $(DEFPPM) $(DEFPGM) $(DEFPBM) libppm.h libppm2.c $(DEFLIBPGM) \
$(DEFLIBPBM)
$(CC) $(ALLCFLAGS) -c libppm2.c
-libppm3.o: ppm.h $(DEFPGM) $(DEFPBM) ppmcmap.h libppm.h libppm3.c
+libppm3.o: $(DEFPPM) $(DEFPGM) $(DEFPBM) ppmcmap.h libppm.h libppm3.c
$(CC) $(ALLCFLAGS) -c libppm3.c
-libppm4.o: ppm.h $(DEFPGM) $(DEFPBM) libppm4.c
+libppm4.o: $(DEFPPM) $(DEFPGM) $(DEFPBM) libppm4.c
$(CC) $(ALLCFLAGS) -c libppm4.c
-libppm5.o: ppm.h $(DEFPGM) $(DEFPBM) ppmdraw.h libppm5.c
+libppm5.o: $(DEFPPM) $(DEFPGM) $(DEFPBM) ppmdraw.h libppm5.c
$(CC) $(ALLCFLAGS) -c libppm5.c
bitio.o: ../pbmplus.h bitio.c
$(CC) $(ALLCFLAGS) -c bitio.c
@@ -235,4 +238,4 @@
yuvsplittoppm yuvsplittoppm.o: yuvsplittoppm.c
clean:
- -rm -f *.o *.a *.cat *~ core $(BINARIES) ppmmerge
+ -rm -f *.o *.a *.cat *~ core *.core $(BINARIES) ppmmerge

View File

@ -0,0 +1,11 @@
--- ppm/ppm.5.orig Mon Oct 4 10:12:19 1993
+++ ppm/ppm.5 Sun Jan 10 23:48:41 1999
@@ -73,7 +73,7 @@
it will automatically fall back on the slower but more general plain
format.
.SH "SEE ALSO"
-giftoppm(1), gouldtoppm(1), ilbmtoppm(1), imgtoppm(1), mtvtoppm(1),
+giftopnm(1), gouldtoppm(1), ilbmtoppm(1), imgtoppm(1), mtvtoppm(1),
pcxtoppm(1), pgmtoppm(1), pi1toppm(1), picttoppm(1), pjtoppm(1), qrttoppm(1),
rawtoppm(1), rgb3toppm(1), sldtoppm(1), spctoppm(1), sputoppm(1), tgatoppm(1),
ximtoppm(1), xpmtoppm(1), yuvtoppm(1),

View File

@ -0,0 +1,13 @@
--- ppm/ppmmerge.c.orig Mon Jan 31 17:44:31 1994
+++ ppm/ppmmerge.c Sun Jan 10 23:48:41 1999
@@ -29,6 +29,10 @@
{
++argv;
--argc;
+ if(!*argv) {
+ fprintf(stderr, "Usage: ppmmerge ppm_program_name [args ...]\n");
+ exit(1);
+ }
goto again;
}

View File

@ -0,0 +1,11 @@
--- ppm/ppmtogif.1.orig Fri Nov 12 10:18:30 1993
+++ ppm/ppmtogif.1 Sun Jan 10 23:48:41 1999
@@ -54,7 +54,7 @@
.PP
All flags can be abbreviated to their shortest unique prefix.
.SH "SEE ALSO"
-giftoppm(1), ppmquant(1), ppm(5)
+giftopnm(1), ppmquant(1), ppm(5)
.SH AUTHOR
Based on GIFENCOD by David Rowley <mgardi@watdcsu.waterloo.edu>.
Lempel-Ziv compression based on "compress".

View File

@ -0,0 +1,11 @@
--- ppm/ppmtoicr.1.orig Mon Oct 4 10:12:38 1993
+++ ppm/ppmtoicr.1 Sun Jan 10 23:48:41 1999
@@ -83,7 +83,7 @@
the displayed image by a factor of 2, and
run-length encode the data:
.nf
- giftoppm giffile | ppmtoicr -w giffile -r -e 2
+ giftopnm giffile | ppmtoicr -w giffile -r -e 2
.fi
.SH BUGS
.PP

View File

@ -0,0 +1,27 @@
--- ppm/ppmtoxpm.1.orig Mon Jan 31 12:49:48 1994
+++ ppm/ppmtoxpm.1 Sun Jan 10 23:48:41 1999
@@ -8,20 +8,20 @@
Produces X11 pixmap (version 3) as output which
can be loaded directly by the XPM library.
.PP
-The \fB-name\fP option allows one to specify the prefix string which is printed
+The \fB-name\f option allows one to specify the prefix string which is printed
in the resulting XPM output. If not specified, will default to the
filename (without extension) of the <ppmfile> argument.
-If \fB-name\fP is not specified and <ppmfile>
+If \fB-name\f is not specified and <ppmfile>
is not specified (i.e. piped input), the prefix string will default to
the string "noname".
.PP
-The \fB-rgb\fP option allows one to specify an X11 rgb text file for the
+The \fB-rgb\f option allows one to specify an X11 rgb text file for the
lookup of color name mnemonics. This rgb text file is typically the
/usr/lib/X11/rgb.txt of the MIT X11 distribution, but any file using the
same format may be used. When specified and
a RGB value from the ppm input matches a RGB value from the <rgb-textfile>,
then the corresponding color name mnemonic is printed in the XPM's colormap.
-If \fB-rgb\fP is not specified, or if the RGB values don't match, then the color
+If \fB-rgb\f is not specified, or if the RGB values don't match, then the color
will be printed with the #RGB, #RRGGBB, #RRRGGGBBB, or #RRRRGGGGBBBB
hexadecimal format.
.PP

View File

@ -0,0 +1,211 @@
--- ppm/ppmtoxpm.c.orig Mon Jan 31 08:44:41 1994
+++ ppm/ppmtoxpm.c Sun Jan 10 23:48:41 1999
@@ -27,11 +27,25 @@
**
** - lowercase conversion of RGB names def'ed out,
** considered harmful.
+**
+** Michael Pall (pall@rz.uni-karlsruhe.de) - 29 Nov 93:
+** - Use the algorithm from xpm-lib for pixel encoding
+** (base 93 not base 28 -> saves a lot of space for colorful xpms)
*/
+#include <stdio.h>
+#include <ctype.h>
#include "ppm.h"
#include "ppmcmap.h"
+#if defined(SYSV) || defined(SVR4)
+#include <string.h>
+#ifndef index
+#define index strchr
+#endif
+#else /* SYSV */
+#include <strings.h>
+#endif /* SYSV */
/* Max number of colors allowed in ppm input. */
#define MAXCOLORS 256
@@ -39,15 +53,19 @@
/* Max number of rgb mnemonics allowed in rgb text file. */
#define MAX_RGBNAMES 1024
-/* Lower bound and upper bound of character-pixels printed in XPM output.
- Be careful, don't want the character '"' in this range. */
-/*#define LOW_CHAR '#' <-- minimum ascii character allowed */
-/*#define HIGH_CHAR '~' <-- maximum ascii character allowed */
-#define LOW_CHAR '`'
-#define HIGH_CHAR 'z'
+#define MAXPRINTABLE 92 /* number of printable ascii chars
+ * minus \ and " for string compat
+ * and ? to avoid ANSI trigraphs. */
+
+static char *printable =
+" .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjklzxcvbnmMNBVCZ\
+ASDFGHJKLPIUYTREWQ!~^/()_`'][{}|";
+
#define max(a,b) ((a) > (b) ? (a) : (b))
+void read_rgb_names(); /* forward reference */
+void gen_cmap(); /* forward reference */
typedef struct { /* rgb values and ascii names (from
* rgb text file) */
@@ -62,17 +80,8 @@
* mnemonic or #rgb value */
} cixel_map;
-
-/* prototypes/forward reference */
-static void read_rgb_names ARGS((char *, rgb_names *, int *));
-static char * gen_numstr ARGS((int, int, int));
-static void gen_cmap ARGS((colorhist_vector, int, pixval, int, rgb_names *, int, cixel_map *, int *));
-
-
pixel **pixels;
-
-int
main(argc, argv)
int argc;
char *argv[];
@@ -88,11 +97,11 @@
/* Used for rgb value -> rgb mnemonic mapping */
int map_rgb_names = 0;
- rgb_names *rgbn; /* rgb_names rgbn[MAX_RGBNAMES]; */
+ rgb_names rgbn[MAX_RGBNAMES];
int rgbn_max;
/* Used for rgb value -> character-pixel string mapping */
- cixel_map *cmap; /* cixel_map cmap[MAXCOLORS]; */
+ cixel_map cmap[MAXCOLORS];
int charspp; /* chars per pixel */
char out_name[100], rgb_fname[100], *cp;
@@ -188,17 +197,9 @@
* If a rgb text file was specified, read in the rgb mnemonics. Does not
* return if fatal error occurs.
*/
- rgbn = (rgb_names *) malloc(MAX_RGBNAMES * sizeof(rgb_names));
- if (rgbn == (rgb_names *) NULL)
- pm_error("out of memory");
-
if (map_rgb_names)
read_rgb_names(rgb_fname, rgbn, &rgbn_max);
- cmap = (cixel_map *)malloc(ncolors * sizeof(cixel_map));
- if (cmap == (cixel_map *) NULL)
- pm_error("out of memory");
-
/* Now generate the character-pixel colormap table. */
gen_cmap(chv, ncolors, maxval, map_rgb_names, rgbn, rgbn_max,
cmap, &charspp);
@@ -231,12 +232,12 @@
/* This routine reads a rgb text file. It stores the rgb values (0->65535)
and the rgb mnemonics (malloc'ed) into the "rgbn" array. Returns the
number of entries stored in "rgbn_max". */
-static
void
read_rgb_names(rgb_fname, rgbn, rgbn_max)
char *rgb_fname;
- rgb_names *rgbn;
- int *rgbn_max;
+ rgb_names rgbn[MAX_RGBNAMES];
+int *rgbn_max;
+
{
FILE *rgbf;
int i, items, red, green, blue;
@@ -303,16 +304,16 @@
} /* read_rgb_names */
/*---------------------------------------------------------------------------*/
-/* Given a number and a base, (base == HIGH_CHAR-LOW_CHAR+1), this routine
+/* Given a number and a base (MAXPRINTABLE), this routine
prints the number into a malloc'ed string and returns it. The length of
the string is specified by "digits". The ascii characters of the printed
- number range from LOW_CHAR to HIGH_CHAR. The string is LOW_CHAR filled,
- (e.g. if LOW_CHAR==0, HIGH_CHAR==1, digits==5, i=3, routine would return
- the malloc'ed string "00011"). */
-static
+ number range from printable[0] to printable[MAXPRINTABLE]. The string is
+ printable[0] filled, (e.g. if printable[0]==0, printable[1]==1,
+ MAXPRINTABLE==2, digits==5, i=3, routine would return the malloc'ed
+ string "00011"). */
char *
-gen_numstr(i, base, digits)
- int i, base, digits;
+gen_numstr(i, digits)
+ int i, digits;
{
char *str, *p;
int d;
@@ -325,9 +326,9 @@
p = str + digits;
*p-- = '\0'; /* nul terminate string */
while (p >= str) {
- d = i % base;
- i /= base;
- *p-- = (char) ((int) LOW_CHAR + d);
+ d = i % MAXPRINTABLE;
+ i /= MAXPRINTABLE;
+ *p-- = printable[d];
}
return str;
@@ -336,7 +337,6 @@
/*---------------------------------------------------------------------------*/
/* This routine generates the character-pixel colormap table. */
-static
void
gen_cmap(chv, ncolors, maxval, map_rgb_names, rgbn, rgbn_max,
cmap, charspp)
@@ -348,16 +348,16 @@
* == unsigned short) */
int map_rgb_names; /* == 1 if mapping rgb values to rgb
* mnemonics */
- rgb_names *rgbn; /* rgb mnemonics from rgb text file */
+ rgb_names rgbn[MAX_RGBNAMES]; /* rgb mnemonics from rgb text file */
int rgbn_max; /* number of rgb mnemonics in table */
/* output: */
-cixel_map *cmap; /* pixel strings and ascii rgb
+cixel_map cmap[MAXCOLORS]; /* pixel strings and ascii rgb
* colors */
int *charspp; /* characters per pixel */
{
- int i, j, base, cpp, mval, red, green, blue, r, g, b, matched;
+ int i, j, cpp, mval, red, green, blue, r, g, b, matched;
char *str;
/*
@@ -365,9 +365,8 @@
* to be forced to link with libm.a, so using a division loop rather
* than a log function.
*/
- base = (int) HIGH_CHAR - (int) LOW_CHAR + 1;
for (cpp = 0, j = ncolors; j; cpp++)
- j /= base;
+ j /= MAXPRINTABLE;
*charspp = cpp;
/*
@@ -392,10 +391,11 @@
/*
* The character-pixel string is simply a printed number in base
- * "base" where the digits of the number range from LOW_CHAR to
- * HIGH_CHAR and the printed length of the number is "cpp".
+ * MAXPRINTABLE where the digits of the number range from
+ * printable[0] .. printable[MAXPRINTABLE-1] and the printed length
+ * of the number is "cpp".
*/
- cmap[i].cixel = gen_numstr(i, base, cpp);
+ cmap[i].cixel = gen_numstr(i, cpp);
/* Fetch the rgb value of the current colormap entry. */
red = PPM_GETR(chv[i].color);

View File

@ -0,0 +1,51 @@
--- ppm/xpmtoppm.c.orig Mon Jan 31 08:42:05 1994
+++ ppm/xpmtoppm.c Sun Jan 10 23:48:41 1999
@@ -30,9 +30,8 @@
#include "ppm.h"
-static void ReadXPMFile ARGS((FILE *stream, int *widthP, int *heightP,
- int *ncolorsP, int *chars_per_pixelP, pixel **colorsP, int **dataP));
-static void getline ARGS((char *line, int size, FILE *stream));
+void ReadXPMFile();
+static void getline();
/* number of xpmColorKeys */
#define NKEYS 5
@@ -46,7 +45,27 @@
"c", /* key #5: color visual */
};
-int
+#ifdef NEED_STRSTR
+/* for systems which do not provide it */
+static char *
+strstr(s1, s2)
+ char *s1, *s2;
+{
+ int ls2 = strlen(s2);
+
+ if (ls2 == 0)
+ return (s1);
+ while (strlen(s1) >= ls2) {
+ if (strncmp(s1, s2, ls2) == 0)
+ return (s1);
+ s1++;
+ }
+ return (0);
+}
+
+#endif
+
+void
main(argc, argv)
int argc;
char *argv[];
@@ -89,7 +108,6 @@
#define MAX_LINE 2048
-static
void
ReadXPMFile(stream, widthP, heightP, ncolorsP,
chars_per_pixelP, colorsP, dataP)

View File

@ -1,4 +1,3 @@
@comment $NetBSD: PLIST,v 1.3 1997/12/31 03:34:57 hubertf Exp $
bin/anytopnm
bin/asciitopgm
bin/atktopbm
@ -89,6 +88,7 @@ bin/pnmenlarge
bin/pnmfile
bin/pnmflip
bin/pnmgamma
bin/pnmhisteq
bin/pnmhistmap
bin/pnmindex
bin/pnminvert
@ -178,6 +178,14 @@ bin/ybmtopbm
bin/yuvsplittoppm
bin/yuvtoppm
bin/zeisstopnm
include/pbm.h
include/pgm.h
include/pnm.h
include/ppm.h
lib/libpbm.a
lib/libpgm.a
lib/libpnm.a
lib/libppm.a
man/man1/anytopnm.1
man/man1/asciitopgm.1
man/man1/atktopbm.1
@ -268,6 +276,7 @@ man/man1/pnmenlarge.1
man/man1/pnmfile.1
man/man1/pnmflip.1
man/man1/pnmgamma.1
man/man1/pnmhisteq.1
man/man1/pnmhistmap.1
man/man1/pnmindex.1
man/man1/pnminvert.1