% Postscript pre-amble to parse scribepic output. This is a fairly % straightforward translation of Peter Rowley's (U Toronto) C code to % do the same thing. % % Originally converted to PostScript by J.W. Peterson % Arbitrary bitmap sizing added by J. Schimpf % Margin & format control added by J. Schimpf % Compressed and comments removed by M. Kaczmarczik % /infile (%stdin) (r) file def /getbyte { infile (x) readhexstring pop 0 get } def /inch { 72 mul } def /inc { 1 add } def /parseline { /in_pos 0 def { in_pos xbytes lt { /cnt getbyte def cnt 127 gt { /cnt cnt 256 sub def } if cnt 0 ge { cnt inc { scanline in_pos getbyte put /in_pos in_pos inc def } repeat } { /data_byte getbyte def cnt neg 1 add { scanline in_pos data_byte put /in_pos in_pos inc def } repeat } ifelse } { exit } ifelse } loop scanline } def /drawpaint { gsave infile token pop 1 eq { /invstat true def } { /invstat false def } ifelse /xbytes infile token pop def /ysize infile token pop def /margin infile token pop def /height infile token pop def /up infile token pop def /scanline xbytes string def /nysize ysize neg def /xbits xbytes 8 mul def /width height xbits ysize div mul def margin width sub 2 div inch up inch translate width inch height inch scale xbits ysize invstat [ xbits 0 0 nysize 0 ysize ] { parseline } imagemask grestore } def drawpaint