Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!think.com!mintaka!bloom-beacon!dont-send-mail-to-path-lines From: neilb@dcs.leeds.ac.UK (Neil Bowers) Newsgroups: comp.windows.x Subject: X Bitmap to Postscript Message-ID: <12294.9102041318@csparc3.dcs.leeds.ac.uk> Date: 4 Feb 91 13:18:07 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 128 Ali Alipour - ali@apollo.hp.com - asked > Is there a public domain software to convert X bitmap to postscript? Gennady Moshkovich asked > Subject: HOW TO PRINT A BITMAP ???????? > [ ... ] > I need to print a bitmap from X background. > Is there any way way to translate to EPS or PS A while back I picked up a script 'Xitops' by Hibachi -- I made a few changes, and renamed it xbm2ps. If Hibachi is out there, I hope you don't mind me posting this -- I didn't have any email address for you. Enjoy! Neil (neilb@uk.ac.leeds.dcs) PS You need to have a sed with decent regular expression handling. GNU sed will do. ------------------------ xbm2ps ------------------------------------ #!/bin/csh -f # # xbm2ps -- translate X bitmap to postscript # # Usage xbm2ps [ -width w | -height h ] # # Neil Bowers (neilb@uk.ac.leeds.dcs) # from the script 'Xitops' by Hibachi # # parse args while ($#argv > 0) switch ($argv[1]) case -width: if ($#argv < 2) goto Usage shift set pswidth = $argv[1] breaksw case -height: if ($#argv < 2) goto Usage shift set psheight = $argv[1] breaksw case -*: echo unknown option: $argv[1] exit default: if (! $?src) then set src = $argv[1] else if (! $?dst) then set dst = $argv[1] else goto Usage: endif breaksw endsw shift end # Both source and destination must be specified if ((! $?src) || (! $?dst)) goto Usage if ($?pswidth && $?psheight) then echo Only one of -height and -width can be specified exit endif if (! -f $src) then echo xbm2ps: $src not found exit endif if ($src == $dst) then echo "xbm2ps: source and destination are the same\!" exit endif # Get dimensions of bitmap set width=`fgrep width $src | awk '$print $3'` set height=`fgrep height $src | awk '$print $3'` # if no output dimensions specified, # largest output dimension set to default (3in) if (! $?pswidth && ! $?psheight) then if ($width > $height) then set pswidth = 3 else set psheight = 3 endif endif if ($?pswidth) then set xscale = "$pswidth 72 mul" set yscale = "$pswidth 72 mul $height mul $width div" else set xscale = "$psheight 72 mul $width mul $height div" set yscale = "$psheight 72 mul" endif @ bytwid = $width / 8 echo '%\!' > $dst echo "/picstr $bytwid string def" >> $dst echo '72 dup translate' >> $dst echo "$xscale $yscale scale" >> $dst echo "$width $height 1" >> $dst echo "[$width 0 0 -$height 0 $height]" >> $dst echo '$currentfile picstr readhexstring pop' >> $dst echo 'image' >> $dst sed -e '/#define/d' -e '/_bits/d' $src | \ tr -d ' ,;' | \ sed 's/0x\(.\)\(.\)/\2\1/g' | \ tr '0123456789abcdefABCDEF' 'f7b3d591e6a2c480a2c480' >> $dst echo 'showpage' >> $dst exit Usage: echo "Usage: foobar [-width w | -height h] source destination"