Postscript for facesaver bitmaps?

chuck bacon crtb at nih-csl.UUCP
Wed Jun 21 20:59:43 AEST 1989


Here's some PS I put together for fun, which prints out the bitmaps
of as many pictures as will fit, on as many sheets as it takes.
If you
  cat /dev/tty faces.ps joe.face pete.face | lpr
  %!needed to fool lpr
  /Size 138.24 def
  ^D
you override the default picture size.  The Size variable
describes the width of the picture in points (easy to remember).
Size defaults to 184.32 points, or pictures 2.56" wide.  Since
most pictures are 96 pixels wide and it would be desirable to use an
integral number of printer dots per pixel (for smoothness of the
halftone pattern), I suggest multiples of 23.04 points (0.32 inches),
although I can't see any degradation when using other Sizes.

The `faces' files contain two sets of picture information, namely
PicData 96 128 8 (usually, sometimes 108 128 8) and Image 96 128 8
(always, as far as I've seen).  I discovered that PicData appears
to correspond exactly to the number of hex pairs which are supplied.
Image doesn't do anything obvious, but I've assumed it's supposed to
suggest the `apparent' number of pixels.  Therefore I force either
size of PicData (96 or 108 wide) into the same width (unit, magnified
by Size).

Warning: The override Size above, 138.24 pts.(1.92") gets you NINE
faces on a page.  On my NTX with 5 meg., I can go out for a beer,
and (depending on whom I run into) get back in time to hear the
printer whine...

-------- faces.ps --------
%! faces.ps -- 6/17/89 -- for displaying uunet.uu.net:faces/ data
% Chuck Bacon - crtb at alw.nih.gov
% You get a header which looks like this:
%	FirstName: Randall		<< ends with a trailing blank! >>
%	LastName: Smith
%	E-mail: randy at ncifcrf.gov
%	PicData: 108 128 8
%	Image: 96 128 8

currentdict /Size known not
  { /Size 120 def } if		% 184.32 is for 2 x 2 pictures on a sheet
/Ourfont /Helvetica-Bold findfont def
/Namefont Ourfont Size 12 div scalefont def
/NF { Namefont setfont } bind def
/Mailfont Ourfont Size 15 div scalefont def
/MF { Mailfont setfont } bind def
/XL 90 def			% Left margin, 1.25"
/YT 720 Size 1.28 mul sub def	% Lower edge of topmost picture
/DX Size 1.35 mul def		% Horizontal distance between pictures
/DY Size 1.80 mul def		% Vertical distance between pictures
/XR 612 Size 1.1 mul sub def	% Rightmost picture placement
/YB 72 def			% Lower limit of picture placement
/YN Size -7.5 div def		% Where First/Last Names are printed
/YI Size -4.3 div def		% Where Email address gets printed

/Workstr 256 string def		% Header text may be any length
/FindRoom {
  X XR gt { /X XL def /Y Y DY sub def Y YB lt { showpage /Y YT def } if } if
 } def

%		ReadHeader: reads currentfile, usually six lines

%	Returns with stack = true if end of file, false if end of header.

/ReadHeader
 {
  /FirstName () def
  /LastName () def
  /E-mail () def
  /PicData (96 128 8) def	% 1st 3 args. to `image'
  /Image (96 128 8) def
   {	% loop
    currentfile Workstr readline not { showpage true exit } if
    (: ) search
     {	% ifelse			% true exit: end of entire file
      exch pop			% ditch the ": "
      dup length 0 gt		% A line beginning with `: ' would kill us!
       { cvn exch dup length string copy def }
       { pop pop } ifelse
     } { pop false exit } ifelse	% false exit: end of header
   } loop
 } def

%		PrintPicture: reads currentfile, does `showpage exit' if EOF

/PrintPicture
 {
  gsave X Y translate
  0 YN moveto NF FirstName show LastName show
  0 YI moveto MF E-mail show
  Size dup scale		% 120 pts. should be 5 pixels per sample
  /Picstr PicData cvx exec pop pop string def
  PicData cvx exec		% 1st 3 args. to `image'
  [ PicData cvx exec pop 0 exch 0 exch Image cvx exec pop div mul 0 0 ]
% [ Image cvx exec pop 0 exch 0 exch 0 0]
% [100 0 0 100 0 0]		% (see PostScript Ref. Man. p. 75)
  { currentfile Picstr readhexstring not { showpage exit } if }
  image				% (Ref. Man. p. 170)
  currentfile read { pop } if	% Get the `/n' after the last hex
  grestore
 } def

/PrintAll	% Print as many pictures as you encounter
 {
  /Y YT def
  /X XL def
   {
    ReadHeader { exit } if	% Quit if EOF
    FindRoom
    PrintPicture		% Picture bottom is at Y=0
    /X X DX add def
   } loop
 } def

PrintAll
---------- Absolutely must cut off here! -----------
-- 
Charles Bacon, crtb at alw.nih.gov, crb at nihcudec.Bitnet, (301)496-4823
"Good is better than evil 'cause it's nicer".  --Li'l Abner



More information about the Comp.org.usenix mailing list