pixtoppm - convert BRL .pix images to ppm
Steve Hayman
sahayman at iuvax.cs.indiana.edu
Sat Jan 19 03:42:40 AEST 1991
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 <stdio.h>
/*
* convert BRL .pix files to ppm
* zcat file.Z | pixtoppm
*
* A quick hack.
* Steve Hayman
* sahayman at 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);
}
More information about the Alt.sources
mailing list