Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!vsi1!wyse!mips!koblas From: koblas@mips.COM (David Koblas) Newsgroups: comp.graphics Subject: Raytrace to Impress/Postscript converter Message-ID: <3367@giant.mips.COM> Date: 18 Sep 88 22:27:11 GMT Reply-To: koblas@mips.COM (David Koblas) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 361 Contained is a shar for converting MRGB pictures to either impress or postscript depending on your needs (black and white). [I'm looking for versatec plotter routines, if you have some I'd be interested] #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'Makefile' <<'END_OF_FILE' X all: prpress prpost X prpress: toprinter.c X $(CC) $(CFLAGS) -DIMPRESS -o $@ $? X prpost: toprinter.c X $(CC) $(CFLAGS) -DPOSTSCRIPT -o $@ $? X clean: X rm -f prpress prpost END_OF_FILE if test 170 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(935 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' X This shar contained programs to print MRGB imageformats, onto either impress or postscript. Man page is not included, command line options are: X X -x arg (postscript only) set x printed size to arg inches. X -y arg (postscript only) set y printed size to arg inches. X -S arg (postscript only) set x and y printed size to arg inches. X X -p arg (impress only) set magnifcation factor (pixel size) to arg. X X -i arg input from file 'arg' otherwise stdin is used. X -r disply only red component. X -g disply only green component. X -b disply only blue component. X -c display a "rgb" picture (default). X The one item that I'm looking for is printing routines for a versatec plotter, if you have some or know where I might be able to find some I'd be greatly interested. X XFeedback is welcome - send bug reports, enhancements, to the address below: X X David Koblas X koblas@mips.com koblas@uoregon.edu X { ames, decwrl, pyramid, wyse }!mips!koblas END_OF_FILE if test 935 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'toprinter.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'toprinter.c'\" else echo shar: Extracting \"'toprinter.c'\" \(7319 characters\) sed "s/^X//" >'toprinter.c' <<'END_OF_FILE' X/* +------------------------------------------------------------------+ */ X/* | Copyright 1988, David Koblas. | */ X/* | You may copy this file in whole or in part as long as you | */ X/* | don't try to make money off it, or pretend that you wrote it. | */ X/* +------------------------------------------------------------------+ */ X X#include X X#define R 0x01 X#define G 0x02 X#define B 0x04 X#define ALL 0x08 X X#ifdef IMPRESS X#define GREYMAX (4) X#define BITBLK (32) /* defined by impress (32 x 32 bits) */ X#define RPIXMAX (2*456) /* (RPIXMAX*GREYMAX)/BITBLK must be integrel */ X#define BLKMAX ((RPIXMAX * GREYMAX)/BITBLK) X unsigned char scanline[RPIXMAX][RPIXMAX]; /* buffer for linework */ unsigned char bitmap[BLKMAX][BLKMAX][BITBLK][GREYMAX]; X#endif X X#define RGB_TO_VAL(r,g,b) ((int)(((double)(r)*0.4)+ \ X ((double)(g)*0.4)+ \ X ((double)(b)*0.2))) X#define VAL(x,y,i) ((i<3) ? data[(x+(xsize*y))*3+i] :\ X RGB_TO_VAL(data[(x+(xsize*y))*3+0],\ X data[(x+(xsize*y))*3+1],\ X data[(x+(xsize*y))*3+2])) X X#if !defined(POSTSCRIPT) && !defined(IMPRESS) XEither POSTSCRIPT or IMPRESS needs to be defined! X#endif X X#ifdef POSTSCRIPT X#define OPTSTR "x:y:i:S:rgbc" X#endif X#ifdef IMPRESS X#define OPTSTR "p:i:rgbc" X#endif X char *Progname; X usage() X{ X int i; X X fprintf(stderr,"usage: %s \n",Progname); X for (i=0;i>8)&0x7f); X putchar( ((int)(xpos)) &0xff); X putchar(137); /* SET-ABS-V */ X putchar((((int)(ypos))>>8)&0x7f); X putchar( ((int)(ypos)) &0xff); X putchar(236); /* MAGNIFICATION */ X putchar((pixel-1)&0xff); X X putchar(235); /* BITMAP */ X putchar(15); /* OPERATION (OR) */ X putchar(1+(int)((xsize*(GREYMAX))/BITBLK)); /* width */ X putchar(1+(int)((ysize*(GREYMAX))/BITBLK)); /* heighth */ X X for (x=0;x255) v=255; X scanline[y][x] = v; X } X } X X dobits(xsize,ysize); X putchar(219); /* SHOWPAGE */ X#endif X } while (i++<4); X} X X#ifdef IMPRESS X/* X** Thanks to Jeff Eaton for these routies. X*/ unsigned char greys[17][GREYMAX] = { X { 0xf, 0xf, 0xf, 0xf }, /* 1111 1111 1111 1111 */ X { 0xf, 0xf, 0xf, 0x7 }, /* 1111 1111 1111 0111 */ X { 0xf, 0xd, 0xf, 0x7 }, /* 1111 1101 1111 0111 */ X { 0xf, 0xd, 0xf, 0x5 }, /* 1111 1101 1111 0101 */ X { 0xf, 0x5, 0xf, 0x5 }, /* 1111 0101 1111 0101 */ X { 0xf, 0x5, 0xb, 0x5 }, /* 1111 0101 1011 0101 */ X { 0xe, 0x5, 0xb, 0x5 }, /* 1110 0101 1011 0101 */ X { 0xe, 0x5, 0xa, 0x5 }, /* 1110 0101 1010 0101 */ X { 0xa, 0x5, 0xa, 0x5 }, /* 1010 0101 1010 0101 */ X { 0xa, 0x5, 0xa, 0x1 }, /* 1010 0101 1010 0001 */ X { 0xa, 0x4, 0xa, 0x1 }, /* 1010 0100 1010 0001 */ X { 0xa, 0x4, 0xa, 0x0 }, /* 1010 0100 1010 0000 */ X { 0xa, 0x0, 0xa, 0x0 }, /* 1010 0000 1010 0000 */ X { 0xa, 0x0, 0x2, 0x0 }, /* 1010 0000 0010 0000 */ X { 0x8, 0x0, 0x2, 0x0 }, /* 1000 0000 0010 0000 */ X { 0x8, 0x0, 0x0, 0x0 }, /* 1000 0000 0000 0000 */ X { 0x0, 0x0, 0x0, 0x0 }, /* 0000 0000 0000 0000 */ X}; X int dither[4][4] = { X { 00, 8, 02, 10 }, X { 12, 04, 14, 06 }, X { 03, 11, 01, 9 }, X { 15, 07, 13, 05 }, X}; X dobits(width,height) int width,height; X{ X register int row, col, lev, val1, val2, val; X X for (row = 0; row < height; row++) { X for (col = 0; col < width; col += 2) { X val1 = scanline[row][col]; X if (val1%16 > dither[row%4][col%4]) X val1 = val1/16 + 1; X else X val1 = val1/16; X val2 = scanline[row][col+1]; X if (val2%16 > dither[row%4][(col+1)%4]) X val2 = val2/16 + 1; X else X val2 = val2/16; X for (lev = 0; lev < 4; lev++) { X val = greys[val2][lev]|(greys[val1][lev] << 4); X bitmap[row/8][col/8][(row%8)*4+lev][(col%8)/2] = val; X } X } X } X for (; row < RPIXMAX; row++) { X for (; col < RPIXMAX; col++) { X for (lev = 0; lev < 4; lev++) { X bitmap[row/8][col/8][(row%8)*4+lev][(col%8)/2] = 0; X } X } X } X for (val1 = 0; val1 <= (int)((height*GREYMAX)/BITBLK); val1++) { X for (lev = 0; lev <= (int)((width*GREYMAX)/BITBLK); lev++) { X for (row = 0; row < BITBLK; row++) { X for (col = 0; col < GREYMAX; col++) { X putchar(bitmap[val1][lev][row][col]); X } X } X } X } X} X#endif /* IMPRESS */ END_OF_FILE if test 7319 -ne `wc -c <'toprinter.c'`; then echo shar: \"'toprinter.c'\" unpacked with wrong size! fi # end of 'toprinter.c' fi echo shar: End of shell archive. exit 0 -- name : David Koblas place: MIPS Computers Systems phone: 408-991-0287 uucp : {ames,decwrl,pyramid,wyse}!mips!koblas quote: I've began to wonder if X11 is really a competition to see who can create the largest copyright that says, "It's free."