[comp.lang.postscript] Compact data representations?

nowlin@gramian.harvard.edu (Bill Nowlin) (04/27/89)

Is PostScript completely ASCII?

I would like to draw many, many lines in PostScript.  I have a C program which
computes the endpoints of the lines, and its a trivial matter to write them
in the middle of a PostScript file that will do what I want.

However, the resulting PostScript file is huge.  Each of my endpoints is
represented by a 3- or 4-digit ASCII string, and so plotting 900 lines can
result in a file of considerable length.  I abbreviated as much as my
knowledge of PostScript permits, and concatenated line segments into longer
lines wherever possible, but all I could really do was cut the size of the
file in half.  I need to reduce it by an order of magnitude.

Here then is my question.

Does PostScript allow the sending and unpacking of packed data arrays?
What's the easiest way to do this?  Examples appreciated...

Bill Nowlin
nowlin@gramian.harvard.edu

tsf@PROOF.ERGO.CS.CMU.EDU (Timothy Freeman) (05/02/89)

In article <1708@husc6.harvard.edu> nowlin@gramian.harvard.edu (Bill Nowlin) writes:
>I would like to draw many, many lines in PostScript.  ...
>
>However, the resulting PostScript file is huge.  ...
>
>Does PostScript allow the sending and unpacking of packed data arrays?

Well, you could use the same trick that the postscript text-printing
programs use.  If a postscript program reads from its standard input,
the text comes from the file that's being printed.  Your files could
look like this:

/interpreter {...} def
interpreter
... encoded bytes ...

Where the {...} is code that reads the encoded bytes from the standard
input and draws the appropriate lines.  For an example, see the
Postscript cookbook or any of the Postscript text-printing programs.
-- 
Tim Freeman
Arpanet: tsf@cs.cmu.edu
Uucp:    ...!seismo.css.gov!cs.cmu.edu!tsf
-- 

batcheldern@hannah.dec.com (Ned Batchelder, PostScript Eng.) (05/03/89)

In article <4876@pt.cs.cmu.edu> tsf@PROOF.ERGO.CS.CMU.EDU (Timothy Freeman)
writes:
>Well, you could use the same trick that the postscript text-printing
>programs use.  If a postscript program reads from its standard input,
>the text comes from the file that's being printed.  Your files could 
>look like this:
>
>/interpreter {...} def
>interpreter
>... encoded bytes ...

Please, please, remember to explicitly terminate your data.  Do not assume
that you can read to the end-of-file indicator on the standard input.  Not
only won't you be able to if your output is included as a figure, in
another document, but even as a stand-alone file, there may PostScript code
inserted at the end of the job by the spooler (to force out partially
completed sheets when doing 2-up, for example).  All you have to do is
reserve a code in your encoding that means end-of-data, and have the
interpreter function terminate when it reads that code.  It's very simple,
and the industry will thank you.

Ned Batchelder
Digital Equipment Corporation
BatchelderN@Hannah.DEC.com