Thread View: comp.lang.postscript
3 messages
3 total messages
Started by Forrest Clinton Cahoon
Mon, 28 Dec 1992 17:12
problem manipulating binary data in postscript
Author: Forrest Clinton Cahoon
Date: Mon, 28 Dec 1992 17:12
Date: Mon, 28 Dec 1992 17:12
22 lines
1701 bytes
1701 bytes
I'm trying to write some postscript which will color a hexagonal grid, reading the color data from the end of my ps file. I'm reading one byte for each hexagon, then doing some bit-twiddling to get values to call setrgbcolor with before filling the hexagon. I've got a version using "read" which works, but since "read" treats my newline characters as valid binary data, it's not entirely satisfactory. What I want to use is "readhexstring", but since what this reads in is treated as a string rather than an integer, I'm having trouble. I need to convert my one-byte string into an integer having the same binary representation. I don't want "cvi", because this parses a string which represents an integer to us humans, and puts that value on the stack -- cvi would read (1) and put the integer value 1 on the stack, but what I need would take (1) and put the integer value 49 -- the ASCII value of the character 1 -- on the stack. -- | Forrest Cahoon | cahoon@cs.umn.edu |------------------------------| | 850 21st Ave SE |-------------------| Only unbalanced people | | Mpls MN 55414-2514 | | can tip the scales... |
Re: problem manipulating binary data in postscript
Author: Goldman of Chaos
Date: Mon, 28 Dec 1992 17:20
Date: Mon, 28 Dec 1992 17:20
21 lines
1464 bytes
1464 bytes
In article <1992Dec28.171257.27785@news2.cis.umn.edu> cahoon@femto.cs.umn.edu (Forrest Clinton Cahoon) writes:
>I'm trying to write some postscript which will color a hexagonal grid,
>reading the color data from the end of my ps file. I'm reading one
>byte for each hexagon, then doing some bit-twiddling to get values to call
>setrgbcolor with before filling the hexagon.
>
>I've got a version using "read" which works, but since "read" treats my
>newline characters as valid binary data, it's not entirely
>satisfactory.
Cool, please let me know what you come up with. I've been playing
around with multi-colored hex maps; however, I've been building the
hex map one hex at a time. The end result is nice; however, there
must be a better way to go about it.
Matt Goldman
--
Matthew Goldman E-mail: goldman@orac.cray.com
Fax: (612) 683-3099 Work: (612) 683-3061
"Say George, I don't mean to interrupt, but
there's a glowing red dot on your forehead."
Re: problem manipulating binary data in postscript
Author: Peter F Davis
Date: Tue, 29 Dec 1992 14:06
Date: Tue, 29 Dec 1992 14:06
25 lines
1502 bytes
1502 bytes
cahoon@femto.cs.umn.edu (Forrest Clinton Cahoon) writes: >I'm trying to write some postscript which will color a hexagonal grid, >reading the color data from the end of my ps file. I'm reading one >byte for each hexagon, then doing some bit-twiddling to get values to call >setrgbcolor with before filling the hexagon. >I've got a version using "read" which works, but since "read" treats my >newline characters as valid binary data, it's not entirely >satisfactory. >What I want to use is "readhexstring", but since what this reads in is >treated as a string rather than an integer, I'm having trouble. I >need to convert my one-byte string into an integer having the same >binary representation. I don't want "cvi", because this parses a >string which represents an integer to us humans, and puts that value >on the stack -- cvi would read (1) and put the integer value 1 on the >stack, but what I need would take (1) and put the integer value 49 -- >the ASCII value of the character 1 -- on the stack. Use 'get' to get any byte from the string as an integer: (A) 0 get will put 65 on the stack.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads