solvespace/png2c.pl
Jonathan Westhues 0f228fc0fb Add a toolbar. This requires a tool to convert my PNG icons to
tables in the code, which I have written in perl and am checking
in.

Also get WM_MOUSELEAVE events from win32, so that I can de-hover
everything when the mouse leaves the graphics window. And fix one
of the icons, which was 23x24 instead of 24x24.

[git-p4: depot-paths = "//depot/solvespace/": change = 1883]
2009-01-02 02:38:36 -08:00

36 lines
793 B
Perl

#!/usr/bin/perl
use GD;
for $file (<icons/*.png>) {
$file =~ m#.*/(.*)\.png#;
$base = "Icon_$1";
$base =~ y/-/_/;
open(PNG, $file) or die "$file: $!\n";
$img = newFromPng GD::Image(\*PNG) or die;
$img->trueColor(1);
close PNG;
($width, $height) = $img->getBounds();
die "$file: $width, $height" if ($width != 24) or ($height != 24);
print "unsigned char $base\[24*24*3] = {\n";
for($y = 0; $y < 24; $y++) {
for($x = 0; $x < 24; $x++) {
$index = $img->getPixel($x, 23-$y);
($r, $g, $b) = $img->rgb($index);
if($r + $g + $b < 11) {
($r, $g, $b) = (30, 30, 30);
}
printf " 0x%02x, 0x%02x, 0x%02x,\n", $r, $g, $b;
}
}
print "};\n\n";
}