home *** CD-ROM | disk | FTP | other *** search
- /* 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.
- */
-
- #include <stdio.h>
- #include "ppm.h"
-
- #define PRT_MAXVAL 255
-
- main( argc, argv )
- int argc;
- char *argv[];
- {
- FILE *ifd;
- pixel *pixelrow;
- register pixel *pP;
- int rows, cols, row;
- register int col;
- pixval maxval;
-
- pm_progname = argv[0];
-
- if ( argc > 2 )
- pm_usage( "[prtfile]" );
-
- if ( argc == 2 )
- ifd = pm_openr( argv[1] );
- else
- ifd = stdin;
-
- fscanf(ifd,"%d %d\n",&cols, &rows);
- ppm_writeppminit( stdout, cols, rows, PRT_MAXVAL );
-
- pixelrow = ppm_allocrow( cols );
-
- for ( row = 0; row < rows; row++ ) {
- for ( col=0, pP = pixelrow; col<cols; col++, pP++ )
- PPM_ASSIGN(*pP,getc(ifd),getc(ifd),getc(ifd));
- ppm_writeppmrow( stdout, pixelrow, cols, PRT_MAXVAL );
- }
-
- pm_close( ifd );
-
- exit( 0 );
- }
-