Path: utzoo!utgpu!cs.utexas.edu!usc!sdd.hp.com!spool2.mu.edu!news.cs.indiana.edu!sahayman@iuvax.cs.indiana.edu From: sahayman@iuvax.cs.indiana.edu (Steve Hayman) Newsgroups: alt.sources Subject: pixtoppm - convert BRL .pix images to ppm Message-ID: <1991Jan18.114302.14195@news.cs.indiana.edu> Date: 18 Jan 91 16:42:40 GMT Organization: Computer Science Department, Indiana University Lines: 99 Some RGB images of the Iraq war are available from ftp.brl.mil. See "comp.graphics" for details. They're in "BRL-CAD .pix" format - here is a tool that will convert those images to the PPM Portable Pixmap format (part of the PBM toolkit) , so you can view them with tools such as 'xv'. This is a quick hack that I wrote in about 10 minutes so it has no options and no guarantee. But this is "alt.sources". sample use: get the images zcat map-scud-targets.Z | ./pixtoppm >map-scud-targets.ppm xv map-scud-targets.ppm #include /* * convert BRL .pix files to ppm * zcat file.Z | pixtoppm * * A quick hack. * Steve Hayman * sahayman@cs.indiana.edu * Fri Jan 18 11:39:33 EST 1991 * * brl says this: * * These compressed images are in BRL-CAD .pix file format. * They are 24-bits/pixel, 720 by 486 pixels. * * Pixels run left-to-right, from the bottom of the screen to the top. * * Mike @ BRL.MIL */ #define WIDTH 720 #define HEIGHT 486 #define BYTESPERPIXEL 3 #define ROWSIZE (WIDTH * BYTESPERPIXEL) #define SIZE (WIDTH * HEIGHT * BYTESPERPIXEL) char *map; char *malloc(); main() { int i; char *row; /* * magic number */ printf("P6\n"); /* * width height */ printf("%d %d\n", WIDTH, HEIGHT); /* * maximum color component value */ printf("255\n"); fflush(stdout); /* * now gobble up the bytes */ map = malloc( SIZE ); if ( map == NULL ) { perror("malloc"); exit(1); } if ( fread(map, 1, SIZE, stdin) == 0 ) { fprintf(stderr, "Short read\n"); exit(1); } /* * now write them out in the right order, 'cause the * input is upside down. */ for ( i = 0; i < HEIGHT; i++ ) { row = map + (HEIGHT - i) * ROWSIZE; fwrite(row, 1, ROWSIZE, stdout); } exit(0); }