From 72f72d64a422d6628c4796f5c0bf2e508f134214 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Wed, 4 May 2011 16:05:14 +0900 Subject: Adding upstream version 0.5.1 --- scripts/xface2xpm.in | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 scripts/xface2xpm.in (limited to 'scripts/xface2xpm.in') diff --git a/scripts/xface2xpm.in b/scripts/xface2xpm.in new file mode 100644 index 0000000..30253cb --- /dev/null +++ b/scripts/xface2xpm.in @@ -0,0 +1,94 @@ +#!@PERL@ + +$USAGE = "xface2xpm [-t] [-fg ] [-bg ] []"; + +# compface/uncompface +# ftp://metalab.unc.edu/pub/Linux/apps/graphics/convert/ +$UNCOMPFACE = "uncompface"; + +$T = "c"; +$BG = "white"; +$FG = "black"; +while (@ARGV) { + $_ = shift @ARGV; + if (/^-h/) { + &usage(0); + } elsif (/^-t/) { + $T = "s"; + $BG = "none"; + } elsif (/^-bg/) { + @ARGV || &usage(1); + $BG = shift @ARGV; + } elsif (/^-fg/) { + @ARGV || &usage(1); + $FG = shift @ARGV; + } elsif (/^-./) { + &usage(1); + } else { + unshift(@ARGV, $_); + last; + } +} + +$xf = ""; +while(<>) { +# s/^X-Face://i if ($xf eq ""); + $xf .= $_; +} + +pipe(R, W2); +pipe(R2, W); +if (! fork()) { + close(R); + close(W); + open(STDIN, "<&R2"); + open(STDOUT, ">&W2"); + exec $UNCOMPFACE; + exit 1; +} +close(R2); +close(W2); +print W $xf; +close(W); +while() { + while(s/0x(..)(..)//) { + push(@bm, hex($1), hex($2)); + } +} +close(R); +@bm || exit 1; + +$W = 48; +$H = @bm * 8 / $W; # must be 48 +print <> (8-$i)) & 1) ? "." : " "); + } + } + print (@bm ? "\",\n" : "\"\n"); +} +print <