[comp.lang.postscript] Help! What am I doing wrong here?

tims@teklds.TEK.COM (Tim Stoehr) (11/17/88)

I'm having a problem with my first use of the 'image' operator.

The postscript program below, according to my postcript book, should generate
the following 20 by 20 bitmap, scaled to one inch by one inch.

11111111111111111111:fffff
11111111111111111111:fffff
11111111111111111111:fffff
11111111111111111111:fffff	72 72 scale
11111011111111111111:fbfff	20 20 1 [20 0 0 20 0 0] {<fffff fffff fffff fffff
11111011111111111111:fbfff	fffff f800f fbfff fbfff fbfff fbfff f81ff fbfff
11111011111111111111:fbfff	fbfff fbfff fbfff fbfff fffff fffff fffff fffff>}
11111011111111111111:fbfff	image
11111011111111111111:fbfff	showpage
11111000000111111111:f81ff
11111011111111111111:fbfff
11111011111111111111:fbfff
11111011111111111111:fbfff
11111011111111111111:fbfff
11111000000000001111:f800f
11111111111111111111:fffff
11111111111111111111:fffff
11111111111111111111:fffff
11111111111111111111:fffff
11111111111111111111:fffff

I expected a black upside-down 'F' to be generated, instead I got random
garbage.  Any distribution of blanks in the hex string made no difference.
What am I doing wrong?

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

In article <4181@teklds.TEK.COM> tims@teklds.TEK.COM (Tim Stoehr) writes:
>I'm having a problem with my first use of the 'image' operator.
>72 72 scale
>20 20 1 [20 0 0 20 0 0] {<fffff fffff fffff fffff
>fffff f800f fbfff fbfff fbfff fbfff f81ff fbfff
>fbfff fbfff fbfff fbfff fffff fffff fffff fffff>}
>image
>showpage
>
>I expected a black upside-down 'F' to be generated, instead I got random
>garbage.  Any distribution of blanks in the hex string made no difference.
>What am I doing wrong?

You are describing your string incorrectly.  Read page 24 of the Red Book.

"A string may be described in hex...  by bracketing a sequence of hex
characters...  Each pair of hex digits defines one character of the
string.  ... Spaces, tabs, and newlines are ignored."

if you want some bits in the upper nibble (left half for depth 1) of a byte
you need to specify the lower nibble as zero.

Your example: f81ff fbfff
translates to: f8 1f ff bf ff
not as expected: f8 1f f0 fb ff f0

Here's your upside down F:
%!
72 72 scale
20 20 1 [20 0 0 20 0 0]
{   <fffff0 fffff0 fffff0 fffff0 fffff0 f800f0 fbfff0 fbfff0 fbfff0 fbfff0
     f81ff0 fbfff0 fbfff0 fbfff0 fbfff0 fbfff0 fffff0 fffff0 fffff0 fffff0>
} image
showpage

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

blm@cxsea.UUCP (Brian Matthews) (11/19/88)

Tim Stoehr (tims@teklds.TEK.COM) writes:
|I'm having a problem with my first use of the 'image' operator.

|20 20 1 [20 0 0 20 0 0] { [data] } image

RTFM.  From page 74 of the Postcript Language Reference Manual (the red
book):

"If bits/sample is less than 8 and width is not a multiple of the number
of samples per character, there must be extra samples at the end of each
row to fill up the last character.  The values of the extra samples are
not used; they are present only in order to align the data so that each
row starts on a character boundary."

In your case, bit/samples (1) is less than 8, and the width (20) isn't a
multiple of the number of samples per character (8 / 1 = 8).  Pad each
line to 24 bits.

-- 
Brian L. Matthews  blm@cxsea.UUCP   ...{mnetor,uw-beaver!ssc-vax}!cxsea!blm
+1 206 251 6811    Computer X Inc. - a division of Motorola New Enterprises