Article View: comp.lang.postscript
Article #7602Re: Does 'prpost' really work?
From: +Lugo F.
Date: Sat, 12 Nov 1988 02:39
Date: Sat, 12 Nov 1988 02:39
73 lines
3016 bytes
3016 bytes
>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^)
Technical Details
Message-ID:
<4241@sfsup.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!uwvax!umn-d-ub!nic.MR.NET!hal!cwjcc!tut.cis.ohio-state.edu!osu-cis!att!ulysses!sfsup!cocoReferences:
<1234@leah.Albany.Edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!uwvax!umn-d-ub!nic.MR.NET!hal!cwjcc!tut.cis.ohio-state.edu!osu-cis!att!ulysses!sfsup!coco From: coco@sfsup.UUCP (+Lugo F.) Newsgroups: comp.lang.postscript,comp.graphics Subject: Re: Does 'prpost' really work? Summary: ? Keywords: mtv raytracer, postscript, prpost Message-ID: <4241@sfsup.UUCP> Date: 12 Nov 88 02:39:48 GMT References: <1234@leah.Albany.Edu> Reply-To: coco@attunix.att.com (Felix A. Lugo) Organization: AT&T Bell Laboratories Lines: 73