pixtoppm - convert BRL .pix images to ppm
Steve Hayman
sahayman at iuvax.cs.indiana.edu
Sat Jan 19 03:22:26 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 >
* sahayman at iuvax.cs.indiana.edu 1991 01 18
*
* brl says this about the format:
*
* 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 SIZE (WIDTH * HEIGHT * BYTESPERPIXEL)
char *map;
char *malloc();
main()
{
char buf[512];
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 out the rows in the right order, 'cause the
* input is upside down.
*/
for ( i = 0; i < HEIGHT; i++ ) {
row = map + (HEIGHT - i) * WIDTH * 3;
fwrite(row, 1, WIDTH*3, stdout);
}
exit(0);
}
More information about the Alt.sources
mailing list