3 # Given a list of input PNGs, create a C source file containing a
4 # const array of XPMs, named by a given C identifier.
10 # XPM format is generated directly by ImageMagick, so that's easy
11 # enough. We just have to adjust the declaration line so that it
12 # has the right name, linkage and storage class.
14 open XPM, "convert $f xpm:- |";
15 push @lines, $_ while <XPM>;
17 die "XPM from $f in unexpected format\n" unless $lines[1] =~ /^static.*\{$/;
18 $lines[1] = "static const char *const ${id}_$k"."[] = {\n";
20 push @xpms, @lines, "\n";
24 foreach $line (@xpms) { print $line; }
25 print "const char *const *const ${id}[] = {\n";
26 for ($i = 0; $i < $k; $i++) { print " ${id}_$i,\n"; }
28 print "const int n_${id} = $k;\n";