/***************************************************************** * qrt2fbm.c: FBM Release 1.0 25-Feb-90 Michael Mauldin * * Copyright (C) 1989,1990 by Michael Mauldin. Permission is granted * to use this file in whole or in part for any purpose, educational, * recreational or commercial, provided that this copyright notice * is retained unchanged. This software is available to all free of * charge by anonymous FTP and in the UUNET archives. * * qrt2fbm.c: Convert QRT format (from the QRT ray tracer) * * USAGE * % qrt2fbm -t'title' -c'credits' < qrtfile > fbm * * EDITLOG * LastEditDate = Mon Jun 25 00:40:50 1990 - Michael Mauldin * LastFileName = /usr2/mlm/src/misc/fbm/qrt2fbm.c * * HISTORY * 25-Jun-90 Michael Mauldin (mlm@cs.cmu.edu) Carnegie Mellon * Package for Release 1.0 * * 7-Apr-89 Michael Mauldin (mlm) at Carnegie-Mellon University * Installed, code by Butler Hines. * *****************************************************************/ # include # include "fbm.h" # define USAGE \ "Usage: qrt2fbm [ -t'title' -c'credits' ] < qrtfile > fbm" #ifndef lint static char *fbmid = "$FBM qrt2fbm.c <1.0> 25-Jun-90 (C) 1989,1990 by Michael Mauldin, source \ code available free from MLM@CS.CMU.EDU and from UUNET archives$"; #endif main (argc, argv) char *argv[]; { register int j, k, rowlen; double aspect = 0.56; int rows, cols, line, len, planes=3; FBMHDR hdr; unsigned char *buf; char title[FBM_MAX_TITLE], credits[FBM_MAX_TITLE]; /* Get the options */ while (--argc > 0 && (*++argv)[0] == '-') { while (*++(*argv)) { switch (**argv) { case 't': strncpy (title, *argv+1, FBM_MAX_TITLE); title[FBM_MAX_TITLE-1] = '\0'; CLRARG; break; case 'c': strncpy (credits, *argv+1, FBM_MAX_TITLE); credits[FBM_MAX_TITLE-1] = '\0'; CLRARG; break; default: fprintf (stderr, "%s\n", USAGE); exit (1); } } } cols = getchar(); cols |= (getchar()<<8); rows = getchar(); rows |= (getchar()<<8); rowlen = 2 * ((cols * 8 + 15) / 16); /* Build header */ hdr.rows = rows; hdr.cols = cols; hdr.planes = planes; hdr.bits = 8; hdr.physbits = 8; hdr.rowlen = rowlen; hdr.plnlen = hdr.rowlen * rows; hdr.clrlen = 0; hdr.aspect = aspect; strcpy (hdr.title, title); strcpy (hdr.credits, credits); write_hdr_fbm (&hdr, stdout); len = planes*cols; buf = (unsigned char *) malloc (rows*len); for (j=0; j