2013-08-26 21:45:09 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2010-05-09 01:20:02 +00:00
|
|
|
|
|
|
|
use GD;
|
|
|
|
|
2013-08-26 21:45:09 +00:00
|
|
|
my ($srcdir) = @ARGV;
|
|
|
|
defined($srcdir) or $srcdir = '.';
|
|
|
|
-d "$srcdir/icons" || die "$srcdir/icons/: directory not found";
|
|
|
|
|
|
|
|
print "/**** This is a generated file - do not edit ****/\n\n";
|
|
|
|
|
|
|
|
for my $file (sort <$srcdir/icons/char-*.png>) {
|
2010-05-09 01:20:02 +00:00
|
|
|
open(PNG, $file) or die "$file: $!\n";
|
2013-08-26 21:45:09 +00:00
|
|
|
my $img = newFromPng GD::Image(\*PNG) or die;
|
2010-05-09 01:20:02 +00:00
|
|
|
$img->trueColor(1);
|
|
|
|
close PNG;
|
|
|
|
|
2013-08-26 21:45:09 +00:00
|
|
|
my ($width, $height) = $img->getBounds();
|
2010-05-09 01:20:02 +00:00
|
|
|
die "$file: $width, $height" if ($width != 16) or ($height != 16);
|
|
|
|
|
2013-08-26 21:45:09 +00:00
|
|
|
for(my $x = 0; $x < 16; $x++) {
|
|
|
|
for(my $y = 0; $y < 16; $y++) {
|
|
|
|
my $index = $img->getPixel($x, $y);
|
|
|
|
my ($r, $g, $b) = $img->rgb($index);
|
2010-05-09 01:20:02 +00:00
|
|
|
if($r + $g + $b < 11) {
|
|
|
|
print " 0, ";
|
|
|
|
} else {
|
|
|
|
print "255, ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|