From 881746789a489fad85aae8317555f73dbe261556 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 29 Apr 2017 18:21:56 -0400 Subject: puzzles: refactor and resync with upstream This brings puzzles up-to-date with upstream revision 2d333750272c3967cfd5cd3677572cddeaad5932, though certain changes made by me, including cursor-only Untangle and some compilation fixes remain. Upstream code has been moved to its separate subdirectory and future syncs can be done by simply copying over the new sources. Change-Id: Ia6506ca5f78c3627165ea6791d38db414ace0804 --- apps/plugins/puzzles/src/icons/cicon.pl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 apps/plugins/puzzles/src/icons/cicon.pl (limited to 'apps/plugins/puzzles/src/icons/cicon.pl') diff --git a/apps/plugins/puzzles/src/icons/cicon.pl b/apps/plugins/puzzles/src/icons/cicon.pl new file mode 100755 index 0000000000..3578bd33fe --- /dev/null +++ b/apps/plugins/puzzles/src/icons/cicon.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl + +# Given a list of input PNGs, create a C source file file +# containing a const array of XPMs, under the name `xpm_icon'. + +$k = 0; +@xpms = (); +foreach $f (@ARGV) { + # XPM format is generated directly by ImageMagick, so that's easy + # enough. We just have to adjust the declaration line so that it + # has the right name, linkage and storage class. + @lines = (); + open XPM, "convert $f xpm:- |"; + push @lines, $_ while ; + close XPM; + die "XPM from $f in unexpected format\n" unless $lines[1] =~ /^static.*\{$/; + $lines[1] = "static const char *const xpm_icon_$k"."[] = {\n"; + $k++; + push @xpms, @lines, "\n"; +} + +# Now output. +foreach $line (@xpms) { print $line; } +print "const char *const *const xpm_icons[] = {\n"; +for ($i = 0; $i < $k; $i++) { print " xpm_icon_$i,\n"; } +print "};\n"; +print "const int n_xpm_icons = $k;\n"; -- cgit v1.2.3