'prt' Ray Tracer( output file decoder )
Mike Sullivan
mike at wang.com
Wed Dec 19 01:31:39 AEST 1990
pizzi at esacs.UUCP (Riccardo Pizzi) writes:
>In article <AFOIANI.90Dec6021521 at dante.nmsu.edu> afoiani at nmsu.edu (Anthony Foiani) writes:
>>I just grabbed a copy of 'prt' off of a.s earlier this morning, and
>>got it running with no problems at all. My only problem is what to do
>>with the 1.68MB output file I got. What package[s]/monitors etc. do I
>>need to view them? Feel free to mail if you prefer. If others need
>>the information, I'll gladly post a summary.
Well I downloaded the raytracer as well. The format of the file is fairly
straightforward so I wrote a quick c program to get it into a form I could use.
The file contains a newline termintated string containing the X and Y
dimensions, followed by X * Y * 3 bytes. ( I guessed at the order (RGB))
I then took the three files generated and loaded them into PICLAB a DOS based
program, in raw mode. I was then able to convert it to GIF format.
Here is the program I wrote:
BEGIN------------------8<---------------cut here----------8<----------------
#include <stdio.h>
main(argc, argv)
int argc;
char **argv;
{
char *pixbuf, *r_name, *g_name, *b_name;
FILE *infile, *rfile, *gfile, *bfile;
int x, y, row, col;
if ( argc != 2 )
printf( "Usage: rgbsplit filename" );
if ( (infile = fopen( argv[1], "r" )) == 0 )
{
perror( "rgbsplit" );
exit(1);
}
r_name = (char *) malloc( strlen( argv[1] )+4 );
g_name = (char *) malloc( strlen( argv[1] )+4 );
b_name = (char *) malloc( strlen( argv[1] )+4 );
strcpy( r_name, argv[1] );
strcpy( g_name, argv[1] );
strcpy( b_name, argv[1] );
strcat( r_name, ".r8" );
strcat( g_name, ".g8" );
strcat( b_name, ".b8" );
rfile = fopen( r_name, "w" );
gfile = fopen( g_name, "w" );
bfile = fopen( b_name, "w" );
if ( !( rfile&&gfile&&bfile ) )
{
perror( "rgbfile" );
exit(1);
}
fscanf( infile, "%d %d\n", &x, &y );
if( x <= 0 || x > 2000 )
{
printf("rgbsplit: Error in format\n" );
exit( x );
}
pixbuf = (char *) malloc( x* 3) ;
for ( row = 0 ; row < y ; row++ )
{
fread( pixbuf, 1, 3*x, infile );
for( col = 0 ; col < 3*x ; )
{
fwrite( &pixbuf[col++], 1, 1, rfile );
fwrite( &pixbuf[col++], 1, 1, gfile );
fwrite( &pixbuf[col++], 1, 1, bfile );
}
}
}
END-----------8<----------cut here----------------------8<----------------
--
________________________
/ __ \ | Michael J. Sullivan |ec.lec.tic adj Choosing
| \ \ / /\ |\ | / ` | | Wang Laboratories Inc. |or consisting of what
| \/ \/ /--\ | \| \__T | | mike at WANG.COM |appears to be the best
\________________________/ | |from diverse sources.
More information about the Alt.sources.d
mailing list