home *** CD-ROM | disk | FTP | other *** search
- head 1.8;
- branch ;
- access ;
- symbols beta10:1.7;
- locks death:1.8;
- comment @# @;
-
-
- 1.8
- date 93.04.04.23.30.34; author death; state Exp;
- branches ;
- next 1.7;
-
- 1.7
- date 93.01.09.21.07.26; author death; state Exp;
- branches ;
- next 1.6;
-
- 1.6
- date 93.01.01.11.51.33; author death; state Exp;
- branches ;
- next 1.5;
-
- 1.5
- date 92.12.31.15.34.13; author death; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 92.12.05.23.07.22; author death; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 92.12.03.18.01.53; author death; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 92.11.27.19.37.57; author death; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 92.11.08.09.28.54; author death; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.8
- log
- @Sun Apr 4 23:30:34 PDT 1993
- @
- text
- @%BEGIN Bitmaps
-
- %%%%%%%%%%%%%
- % Define lengh of a run, and the byte which is repeated that many times
- %%%%%%%%%%%%%
- /lengthByte 1 string def
- /runByte 1 string def
-
- %%%%%%%%%%%%%
- % Name: unpackbytes
- % Syntax: - unpackbytes -
- % About: This unpacks packed hex data into a binary string. Data format
- % is identical to PS level 2 RLE and Mac PackBits (plus
- % terminating 0x80). Each chunk of data starts with a 'length'
- % byte. If it is < 128 use that number of following bytes (plus
- % one) literally. If it is > 128, next byte should be used
- % 257-length times. Note: if 128 ends up in data, we don't deal
- % properly (it shouldn't though)
- %%%%%%%%%%%%%
- /unpackbytes
- {
- %
- % Get a byte which tells us how to extract the next chunk of data
- %
- /thelength
- currentfile lengthByte readhexstring pop
- 0 get
- def
- %
- % If length < 128, copy that number of bytes+1 in litterally
- % Otherwise, copy next byte 257-length number of times
- %
- thelength 128 lt
- {
- /dataString thelength 1 add string def
- currentfile dataString readhexstring pop
- }
- {
- /runlength 257 thelength sub def
- /runString runlength string def
- currentfile runByte readhexstring pop pop
-
- 0 1 runlength 1 sub
- { runString exch runByte putinterval }
- for
- runString
- }
- ifelse
- }
- def
-
- %%%%%%%%%%%%%
- % Name: bitmap [0090, 0091, 0097, 0098 (Pict1 & subset pict2)]
- % Syntax: colordat bits mode llx lly width height sourcewW sourceH
- % bool [regiondata] bool bitmap -
- % About: Display a B&W bitmap. If bool is true, clipping region data
- % follows. The width & height of the image, and the rect (origin,
- % width, height) to display it follow. Mac drawing mode, bitdepth,
- % then info for a colorspace definition. Final args are redundant.
- % (both this and colorbitmap have same args this way)
- %%%%%%%%%%%%%
- /bitmap
- {
- gsave
- % use flag on stack
- {
- initclip
- regionBounds
- clip
- /numShapes exch def
- numShapes 0 gt
- {
- numShapes
- regionPath
- clip
- }
- if
- }
- if
- /isPacked exch def
- /sourceHeight exch def
- /sourceWidth exch def
- /destHeight exch def
- /destWidth exch def
- /boty exch def
- /botx exch def
- /mode exch def
- /bitDepth exch def % unused
- /colordata exch def % "
- /numcolors exch def % "
- %
- % Compute a string with length equal to the number of bytes used
- % per scaline. That number is (bits-per-scaline /8), & wrap up to
- % next whole byte.
- %
- /scanString sourceWidth 8 div ceiling cvi string def
- botx boty destHeight add translate
- destWidth destHeight scale
- %
- % With B&W bitmaps, it's easy to support the two Or transfer modes
- % Check for the two Or modes, and use proper imageMask.
- % Otherwise, default to doing a srcCpy
- %
- 0 setgray
- PSlevel 1 eq
- {
- mode /srcOr eq
- mode /notSrcOr eq
- or
- {
- %
- % Compute a true or false value for imagemask using mode
- %
- sourceWidth sourceHeight mode /notSrcOr eq
- [sourceWidth 0 0 sourceHeight 0 sourceHeight]
- isPacked true eq
- { {unpackbytes} }
- { {currentfile scanString readhexstring pop} }
- ifelse
- imagemask
- }
- {
- %
- % Do a copy mode.
- %
- sourceWidth sourceHeight 1
- [sourceWidth 0 0 sourceHeight 0 sourceHeight]
- isPacked true eq
- { {unpackbytes} }
- { {currentfile scanString readhexstring pop} }
- ifelse
- image
- }
- ifelse
- %
- % Remove the trailing end-of-line80 or eol>
- %
- isPacked false eq
- { 2 { currentfile read pop pop } repeat }
- { 4 { currentfile read pop pop } repeat }
- ifelse
- }
- {
- /DeviceGray setcolorspace
- %
- % Build the dict. parameter for the PS2 image or imageMask op.
- %
- /imageParams 7 dict def
- imageParams begin
- /ImageType 1 def
- /Width sourceWidth def
- /Height sourceHeight def
- /BitsPerComponent 1 def
- /Decode mode /notSrcOr eq
- { [ 1 0 ] } { [ 0 1 ] } ifelse def
- /ImageMatrix [sourceWidth 0 0 sourceHeight
- 0 sourceHeight] def
- /DataSource isPacked true eq
- { currentfile /ASCIIHexDecode filter
- /RunLengthDecode filter}
- { currentfile /ASCIIHexDecode filter}
- ifelse
- def
- end
-
- mode /srcOr eq
- mode /notSrcOr eq
- or
- { imageParams imagemask }
- { imageParams image }
- ifelse
- }
- ifelse
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: colorbitmap [0090, 0091, 0097, 0098 (for pict2 images)]
- % Syntax: colordat bits mode llx lly width height sourcewW sourceH
- % bool [regiondata] bool colorbitmap -
- % About: Display a bitmap. If bool is true, clipping region data follows.
- % The width and height of the image, and the rect (origin, width,
- % height) to display it follow. Mac drawing mode, bitdepth, then
- % info for a colorspace definition. The bit data follows.
- %%%%%%%%%%%%%
- /colorbitmap
- {
- gsave
- % use flag on stack
- {
- initclip
- regionBounds
- clip
- /numShapes exch def
- numShapes 0 gt
- {
- numShapes
- regionPath
- clip
- }
- if
- }
- if
- /isPacked exch def
- /sourceHeight exch def
- /sourceWidth exch def
- /destHeight exch def
- /destWidth exch def
- /boty exch def
- /botx exch def
- /mode exch def
- /sampleDepth exch def
- /colordata exch def
- /numcolors exch def
- %
- % Move to the right location and scale coordinate space properly.
- %
- botx boty destHeight add translate
- destWidth destHeight scale
- PSlevel 1 eq
- {
- %
- % Compute string with space for full scanline of image data:
- % Use bits per scanline, divide by 8, round up to whole byte.
- %
- /scanString sourceWidth sampleDepth mul 8 div
- ceiling cvi string def
- sourceWidth sourceHeight sampleDepth
- [sourceWidth 0 0 sourceHeight 0 sourceHeight]
- isPacked true eq
- { {unpackbytes} }
- { {currentfile scanString readhexstring pop} }
- ifelse
- image
- %
- % Remove trailing end-of-line80 or eol>
- %
- isPacked false eq
- { 2 { currentfile read pop pop } repeat }
- { 4 { currentfile read pop pop } repeat }
- ifelse
- }
- {
- [ /Indexed /DeviceRGB numcolors colordata] setcolorspace
- %
- % Build the dict. parameter to the PS level 2 image operator
- %
- /imageParams 7 dict def
- imageParams begin
- /ImageType 1 def
- /Width sourceWidth def
- /Height sourceHeight def
- /BitsPerComponent sampleDepth def
- /Decode [ 0 2 sampleDepth exp 1 sub ] def
- /ImageMatrix [sourceWidth 0 0 sourceHeight 0
- sourceHeight] def
- /DataSource isPacked true eq
- { currentfile /ASCIIHexDecode filter
- /RunLengthDecode filter}
- { currentfile /ASCIIHexDecode filter}
- ifelse
- def
- end
- imageParams image
- }
- ifelse
- grestore
- }
- def
-
- %END Bitmaps
- @
-
-
- 1.7
- log
- @Sat Jan 9 21:07:25 PST 1993
- @
- text
- @d55 1
- a55 1
- % [regiondata] bool bitmap -
- d181 1
- a181 1
- % [regiondata] bool colorbitmap -
- @
-
-
- 1.6
- log
- @Fri Jan 1 11:51:33 PST 1993
- @
- text
- @a3 5
- % Note:
- %
- %%%%%%%%%%%%%
-
- %%%%%%%%%%%%%
- d9 2
- a10 2
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Utility routine: unpackbytes
- d12 8
- a19 11
- % Description:
- % This unpacks packed hex data into binary strings. Data format is identical
- % to PS level 2 RLE and the same as Mac PackBits (plus terminating 80).
- % Data is divided into chunks. Each chunk starts with a 'length' byte.
- % if byte is < 128 use that number of following bytes (plus one) literally.
- % if byte is > 128, next byte should be used 257-(thatbyte) times
- % 128 (80) is improperly dealt with here if it appears in the data
- % (it is an error when it does) Ignoring 128 saves time, tho, and all
- % files using this are well formed and don't use it.
- % Bugs:
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d49 2
- a50 1
- } def
- d52 10
- a61 15
-
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 0090, 0091, 0097, 0098 (for B&W images (Pict1 & subset pict2))
- % Name: bitmap
- % Syntax: mode llx lly width height sourcewidth sourceheight [regiondata] bool bitmap -
- % Description:
- % This takes a fair bit of data on the stack and displays an image. Specifically,
- % if 'bool' is true, then it is followed by regiondata, which describes a clipping region
- % for the bitmap. if it is false, there is none. This is followed by a description of
- % the width and height of the image, the width and height it is to be displayed at,
- % the lower and left coordinates it is to be displayed at, and a mac drawing mode to be
- % used. Following the operator should be all the bitmap data.
- % Bugs:
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d65 1
- a65 1
- % use the true or false flag on the stack when we were called
- d88 2
- a89 2
- /bitDepth exch def
- /colordata exch def % unused in this routine
- d92 3
- a94 4
- % Set up, and read in the hex data and display it.
- % compute a string with that is identical to the number of bytes used per
- % scaline. That number is (bits-per-scaline /8) [equals num bytes as float number]
- % wrap this up to the next whole byte, and there you go.
- d100 3
- a102 5
- % In this case of B&W bitmaps, it's easy to support tthe two Or transfer
- % modes thanks to the wonder of imageMask. Check for the two transfer
- % modes, and use a proper imagemask. Otherwise, default to doing a srcCpy
- % (note, a notSrcCopy might be straightforward if we inverted bytes after
- % reading them into scanString)
- d104 1
- d112 1
- a112 1
- % Set our pen to black. We don't want to inadvertantly imagemask in color
- a113 5
- 0 setgray
- %
- % Compute a true or false value for imagemask. if the mode is notSrcOr we
- % pass false to imagemask. Otherwise, a true.
- %
- d117 2
- a118 2
- {{unpackbytes} }
- {{currentfile scanString readhexstring pop} }
- d123 3
- d129 2
- a130 2
- {{unpackbytes} }
- {{currentfile scanString readhexstring pop} }
- a143 1
- 0 setgray
- d146 1
- a146 2
- % Build the dictinary parameter to the PS level 2 image operator
- % (can't use << or >> because PS level 1 gets unhappy)
- d150 11
- a160 8
- /ImageType 1 def
- /Width sourceWidth def
- /Height sourceHeight def
- /BitsPerComponent 1 def
- /Decode mode /notSrcOr eq { [ 1 0 ] } { [ 0 1 ] } ifelse def
- /ImageMatrix [sourceWidth 0 0 sourceHeight 0 sourceHeight] def
- /DataSource isPacked true eq
- { currentfile /ASCIIHexDecode filter /RunLengthDecode filter}
- d165 1
- d175 2
- a176 1
- } def
- d178 9
- a186 17
-
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Opcode: 0090, 0091, 0097, 0098 (for pict2 images)
- % Name: colorbitmap
- % Syntax: colordef bits mode llx lly width height sourcewW sourceH [regiondata] bool pict2bitmap -
- % Description:
- % This takes a fair bit of data on the stack and displays an image. Specifically,
- % if 'bool' is true, then it is followed by regiondata, which describes a clipping region
- % for the bitmap. if it is false, there is none. This is followed by a description of
- % the width and height of the image, the width and height it is to be displayed at,
- % the lower and left coordinates it is to be displayed at, and a mac drawing mode to be
- % used. After these, there is a number of bits deep (per sample) that this bitmap will
- % use. After this, an indexed colorspace definition to be used with the bitmap if this is a
- % ps level 2 interpreter. Following the the operator is all the raw bitmap data.
- % Bugs:
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- d190 1
- a190 1
- % use the true or false flag on the stack when we were called
- d212 1
- a212 1
- pop % we don't care about the mode, for now.
- d225 1
- a225 1
- % Get bits per scanline, divide by 8, round up to next whole byte.
- d227 2
- a228 1
- /scanString sourceWidth sampleDepth mul 8 div ceiling cvi string def
- d233 1
- a233 1
- {{currentfile scanString readhexstring pop} }
- d237 1
- a237 1
- % Remove the trailing end-of-line80 or eol> (for RLE and Asciihexdec. filters)
- d245 1
- a245 3
- [ /Indexed /DeviceRGB numcolors colordata] setcolorspace %
- % Build the dictinary parameter to the PS level 2 image operator
- % (can't use << or >> because PS level 1 gets unhappy)
- d247 2
- d251 3
- a253 3
- /ImageType 1 def
- /Width sourceWidth def
- /Height sourceHeight def
- d256 5
- a260 3
- /ImageMatrix [sourceWidth 0 0 sourceHeight 0 sourceHeight] def
- /DataSource isPacked true eq
- { currentfile /ASCIIHexDecode filter /RunLengthDecode filter}
- d269 2
- a270 2
- } def
-
- @
-
-
- 1.5
- log
- @Thu Dec 31 15:34:13 PST 1992
- @
- text
- @@
-
-
- 1.4
- log
- @Sat Dec 5 23:07:22 PST 1992
- @
- text
- @d3 8
- a10 1
- % Define values for storing the 'length' byte and a byte when a run is found
- d12 1
- d14 14
- a27 15
- % define a string to be used when reading a byte that has been repeated
- /runByte 1 string def
-
- %
- % - unpackbytes -
- %
- % This unpacks packed hex data into binary strings. Data format is identical
- % to PS level 2 RLE and the same as Mac PackBits (plus terminating 80).
- % Data is divided into chunks. Each chunk starts with a 'length' byte.
- % if byte is < 128 use that number of following bytes (plus one) literally.
- % if byte is > 128, next byte should be used 257-(thatbyte) times
- % 128 (80) is improperly dealt with here if it appears in the data
- % (it is an error when it does) Ignoring 128 saves time, tho, and all
- % files using this are well formed and don't use it.
- %
- d30 3
- a32 1
- % get the length byte
- d37 4
- a40 1
-
- a42 1
- % the length byte says copy thelength bytes literally
- a46 1
- % the length byte says copy next byte 257-thelength times
- d52 1
- a52 1
- { runString exch runByte putinterval }
- d101 2
- d152 1
- a152 1
- % Remove the trailing (end-of-line)80> or just (end-of-line)>
- d154 2
- a155 1
- isPacked true eq
- a156 1
- { 2 { currentfile read pop pop } repeat }
- d183 2
- a184 2
- { imageParams imagemask }
- { imageParams image }
- d235 2
- d242 1
- a242 1
- PSlevel 2 eq
- d244 21
- a264 2
- /colordata exch def
- /numcolors exch def
- a283 24
- }
- {
- % PS Level 1
- pop % the color lookup info
- %
- % Compute string with space for full scanline of image data:
- % Get bits per scanline, divide by 8, round up to next whole byte.
- %
- /scanString sourceWidth sampleDepth mul 8 div ceiling cvi string def
- sourceWidth sourceHeight sampleDepth
- [sourceWidth 0 0 sourceHeight 0 sourceHeight]
- isPacked true eq
- { {unpackbytes} }
- {{currentfile scanString readhexstring pop} }
- ifelse
- image
- %
- % Remove the trailing (end-of-line)80> or just (end-of-line)>
- % (80 is the PS level 2 RLE end of file marker, and > is eof for ascii hex encoded files)
- %
- isPacked true eq
- { 4 { currentfile read pop pop } repeat }
- { 2 { currentfile read pop pop } repeat }
- ifelse
- @
-
-
- 1.3
- log
- @Thu Dec 3 18:01:52 PST 1992
- @
- text
- @d90 1
- d107 1
- a107 3
- mode /srcOr eq
- mode /notSrcOr eq
- or
- d109 30
- d140 1
- a140 1
- % Set our pen to black. We don't want to inadvertantly imagemask in color
- a141 7
- 0 setgray
- %
- % Compute a true or false value for imagemask. if the mode is notSrcOr we
- % pass false to imagemask. Otherwise, a true.
- %
- sourceWidth sourceHeight mode /notSrcOr eq
- [sourceWidth 0 0 sourceHeight 0 sourceHeight]
- d143 2
- a144 2
- {{unpackbytes} }
- {{currentfile scanString readhexstring pop} }
- a145 1
- imagemask
- d148 25
- a172 5
- sourceWidth sourceHeight 1
- [sourceWidth 0 0 sourceHeight 0 sourceHeight]
- isPacked true eq
- {{unpackbytes} }
- {{currentfile scanString readhexstring pop} }
- a173 1
- image
- d230 3
- a232 2
- setcolorspace % use the colorspace definition on the stack
- %
- d244 5
- a248 1
- /DataSource currentfile /ASCIIHexDecode filter def
- d263 1
- a263 1
- {{unpackbytes} }
- d268 2
- a269 1
- % Skip end of file marker (> (decimal value is 62)).
- d271 4
- a274 1
- 2 { currentfile read pop pop } repeat
- @
-
-
- 1.2
- log
- @Fri Nov 27 19:37:56 PST 1992
- @
- text
- @a48 17
- %
- %
- % - showimage -
- %
- % This reads the packed data in, unpacks it, and displays the image properly.
- % It also reads and discards the terminating byte (80).
- %
- /showimage
- {
- 576 720 scale
- 576 720 1
- [576 0 0 -720 0 720]
- {unpackbytes}
- image
- % Discard the final 80 byte.
- currentfile lengthByte readhexstring pop pop
- } def
- a50 1
-
- a66 1
-
- d70 1
- a70 1
- regionPath
- d72 8
- d82 1
- d89 1
- a89 3
- pop % we don't care about the mode, for now.
-
-
- d92 3
- d96 2
- a97 2
- /scanString 1 string def
- botx boty sourceHeight add translate
- d99 37
- a135 4
- sourceWidth sourceHeight false
- [sourceWidth 0 0 sourceHeight 0 sourceHeight]
- {currentfile scanString readhexstring pop}
- imagemask
- d143 1
- a143 1
- % Name: pict2bitmap
- d156 1
- a156 1
- /pict2bitmap
- d162 1
- a162 1
- regionPath
- d164 8
- d174 1
- d183 5
- a187 1
- % Might want to modify this when do 1 operand iomage...
- d191 15
- a205 13
- botx boty sourceHeight add translate
- destWidth destHeight scale
- % Build the dictionary to pass to the PS level 2 image operator.
- <<
- /ImageType 1
- /Width sourceWidth
- /Height sourceHeight
- /BitsPerComponent sampleDepth
- /Decode [0 1 0 1 0 1]
- /ImageMatrix [sourceWidth 0 0 sourceHeight 0 sourceHeight]
- /DataSource currentfile /ASCIIHexDecode filter
- >>
- image
- d209 1
- a209 1
- pop
- d211 2
- a212 1
- % Set up, and read in the hex data and display it.
- d214 1
- a214 3
- /scanString 1 string def
- botx boty sourceHeight add translate
- destWidth destHeight scale
- d217 4
- a220 1
- {currentfile scanString readhexstring pop}
- d222 4
- @
-
-
- 1.1
- log
- @Sun Nov 8 09:28:54 PST 1992
- @
- text
- @d1 1
- a2 1
-
- d70 11
- a80 2
- % Opcode 90, 91, 97, 98: fill BitsRect SameRgn
- % mode llyxlly width height sourcewidth sourceheight bitsRect -
- d83 1
- a83 13
- {
- % read a region in if there is one
- {initclip regionPath clip}
- if
- /sourceHeight exch def
- /sourceWidth exch def
- /destHeight exch def
- /destWidth exch def
- /boty exch def
- /botx exch def
- pop % we don't care about the mode, for now.
- % buggy /scanString sourceWidth 8 idiv 1 add string def %% nort good
- /scanString 1 string def
- d85 21
- d116 1
- d118 13
- a130 3
- % Opcode 90, 91, 97, 98 for pict2: fill BitsRect SameRgn
- % mode llyxlly width height sourcewidth sourceheight bitsRect -
- % insert alarm bells. BIG ones...
- a133 20
- % read a region in if there is one
- {initclip regionPath clip}
- if
- /sourceHeight exch def
- /sourceWidth exch def
- /destHeight exch def
- /destWidth exch def
- /boty exch def
- /botx exch def
- pop % we don't care about the mode, for now.
- /sampleDepth exch def
- /numCLUTentries exch def
-
- % pop all the clut entries, because we dont have PS level 2 yet...
- numCLUTentries
- {pop}
- repeat
-
- %% /scanString sourceWidth 8 idiv 1 add string def %% nort good
- /scanString 1 string def
- d135 48
- a182 6
- botx boty sourceHeight add translate
- destWidth destHeight scale
- sourceWidth sourceHeight sampleDepth % for color images, this will be messy, because we ignoreing the clut...
- [sourceWidth 0 0 sourceHeight 0 sourceHeight]
- {currentfile scanString readhexstring pop}
- image
- d187 1
- a187 10
-
-
-
-
-
-
-
-
-
-
- @
-