[comp.lang.postscript] Does 'prpost' really work?

rds95@leah.Albany.Edu (Robert Seals) (11/10/88)

Yo gang - 
A while ago, some kind person posted a program called 'prpost' that
was intended to read a datafile produced by mtv's raytracer and
spit out a postscript program to print it. Well, I got it then and
it didn't work right, and I forgot about it.

It compiles fine, and it runs, but the PS code don't do nuthin. The
header is simple enough, but I don't know enough about doing bitmaps
in PS to know what's wrong.

It was compiled with gcc on a uVax II under Ultrix 1.2, and this is what 
results from a 4x4 (wow!) picture (balls.nff):

%!
save
54 144 translate
504 504 scale
/DataString 4 string def
4 4 8 [ 4 0 0 4 0 0 ] 
{
currentfile DataString readhexstring pop
} bind image
18161c271a092affffffe65a4cffffffbbffffffe80c0affffffd6ffffffe8showpage

Any ideas anybody?

rob

naughton%wind@Sun.COM (Patrick Naughton) (11/11/88)

In article <1234@leah.Albany.Edu> rds95@leah.Albany.Edu (Robert Seals) writes:
>
>%!
>save
>54 144 translate
>504 504 scale
>/DataString 4 string def
>4 4 8 [ 4 0 0 4 0 0 ] 
>{
>currentfile DataString readhexstring pop
>} bind image
>18161c271a092affffffe65a4cffffffbbffffffe80c0affffffd6ffffffe8showpage
>
>Any ideas anybody?
>
>rob

Two things:
 1) There is too much data for a 4x4x8 image.  You should only have 16 bytes
    and you have 31.
 2) Although readhexstring should eat exactly as many bytes as you tell it
    thus leaving the showpage as the next thing in the input stream, I always
    worry when I see things like  ...hex data...ffe8showpage.  Use a newline!

This will display *something*... It should help you debug your mumble2ps
program.

%!
save
54 144 translate
504 504 scale
/DataString 4 string def
4 4 8 [ 4 0 0 4 0 0 ]
{currentfile DataString readhexstring pop} bind image
18 16 1c 27
1a 09 2a ff
ff ff e6 5a
4c ff ff ff

% This is all extra stuff...  
% bb ff ff ff e8 0c 0a ff ff ff d6 ff ff ff e8

showpage


Good luck.

-Patrick

    ______________________________________________________________________
    Patrick J. Naughton				    ARPA: naughton@Sun.COM
    Window Systems Group			    UUCP: ...!sun!naughton
    Sun Microsystems, Inc.			    AT&T: (415) 336 - 1080

valdis@alchemy.mcs.clarkson.edu (& Kletnieks) (11/11/88)

I found a few problems with 'prpost'.  I ended up trashing a good amount of
it and re-writing it to use the infamous 'imageturkey' code from the
Postscript book.  I also had to fix a few places where 'char' should have
been 'unsigned char'.  If anybody's interested, I'll post my fixed copy.

In return, does anybody have a program that converts the mtv raytracer
output into 'Lasergraphics Language' format?  If not, I'll write a filter
myself, but I figured I'd ask first...


				Valdis Kletnieks
				Sr. Systems Programmer
				Clarkson University

coco@sfsup.UUCP (+Lugo F.) (11/12/88)

>Yo gang - 
>A while ago, some kind person posted a program called 'prpost' that
>was intended to read a datafile produced by mtv's raytracer and
>spit out a postscript program to print it. Well, I got it then and
>it didn't work right, and I forgot about it.
>
>It compiles fine, and it runs, but the PS code don't do nuthin. The
>header is simple enough, but I don't know enough about doing bitmaps
>in PS to know what's wrong.
>
>It was compiled with gcc on a uVax II under Ultrix 1.2, and this is what 
>results from a 4x4 (wow!) picture (balls.nff):
>
>%!
>save
>54 144 translate
>504 504 scale
>/DataString 4 string def
>4 4 8 [ 4 0 0 4 0 0 ] 
>{
>currentfile DataString readhexstring pop
>} bind image
>18161c271a092affffffe65a4cffffffbbffffffe80c0affffffd6ffffffe8showpage
>
>Any ideas anybody?
>
>rob

	There are several things that need to be corrected.  Since I don't
	have the source for 'prpost'... well, just follow my lead:
	I assume that you have some knowledge of the C language.

	By now, you already should have noticed that you only need 16 bytes
	of data (4 x 4 x 8bits/pixel).

	Your original data line looks something like this, with the showpage
	operator taken out:
18161c271a092affffffe65a4cffffffbbffffffe80c0affffffd6ffffffe8
	      ^^^^^^^^	  ^^^^^^^^^^^^^^^^    ^^^^^^^^^^^^^^^^
	where it actually should have been:
18161c271a092ae65a4cbbe80c0ad6e8
              ^^    ^^^^    ^^^^
	First notice the following of the latter:
18 16 1c 27 1a 09 2a e6 5a 4c bb e8 0c 0a d6 e8
                     ^^       ^^          ^^ ^^
	All the bytes pointed to by "^^" have bit 7 turned on (i.e. the
	value is greater than 127).  Your compiler, on converting the data
	from char to int when printing (presumably), sign extended the number
	since I assume the program is using the default signed char's.  It
	also appears that your compiler uses 32 bit integers, so it sign
	extends to 32 bits (i.e. ffffffe6, as an example).

	To fix this you can either set all char definitions to unsigned, or
	perform a bitwise AND with 0xff on the number before it actually
	gets output (i.e. 'number & 0xff').
	
	BLAME?  Who knows, compilers, programmer, ...

	Hope this clarifies your problem!

	BTW, try to get that showpage operator on a new line, just to be on
	the safe side.

	  //
--Coco  \X/

__________________________
Felix A. Lugo (coco)
E-MAIL: coco@attunix.att.com
Tel: (201) 522-6057

HAVE YOU HUGGED YOUR AMIGA TODAY!!!! 8^)