From: brian@apt.bungi.com (Brian Litzinger) Newsgroups: alt.sources Subject: prt2ppm pixel map converter Message-ID: <1990Dec7.084740.3047@apt.bungi.com> Date: 7 Dec 90 08:47:40 GMT It didn't seem obvious to me how to convert output files of the prt raytracer to ppm format so I adopted one of the existing ppmtoXXX programs to do the job. Hope you find this helpful. If on the other hand you know of some straight forward way to do the same thing with less work I don't really care. -brian <> Brian Litzinger @ APT Technology Inc., San Jose, CA <> brian@apt.bungi.com {apple,sun,pyramid}!daver!apt!brian #!/bin/sh # This is a shell archive (shar 3.47) # made 12/07/1990 08:45 UTC by brian@apt # Source directory /ust/brian/src/pbmplus/ppm # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 1302 -rw-r----- prt2ppm.c # # ============= prt2ppm.c ============== if test -f 'prt2ppm.c' -a X"$1" != X"-c"; then echo 'x - skipping prt2ppm.c (File already exists)' else echo 'x - extracting prt2ppm.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'prt2ppm.c' && /* prt2ppmm.c - convert a prt pixmap to a portable pixmap ** ** Copyright (C) 1989 by Jef Poskanzer. ** Copyright (C) 1990 By Brian E. Litzinger ** ** 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. */ X #include #include "ppm.h" X #define PRT_MAXVAL 255 X main( argc, argv ) int argc; char *argv[]; { X FILE *ifd; X pixel *pixelrow; X register pixel *pP; X int rows, cols, row; X register int col; X pixval maxval; X X pm_progname = argv[0]; X X if ( argc > 2 ) X pm_usage( "[prtfile]" ); X X if ( argc == 2 ) X ifd = pm_openr( argv[1] ); X else X ifd = stdin; X X fscanf(ifd,"%d %d\n",&cols, &rows); X ppm_writeppminit( stdout, cols, rows, PRT_MAXVAL ); X X pixelrow = ppm_allocrow( cols ); X X for ( row = 0; row < rows; row++ ) { X for ( col=0, pP = pixelrow; col