[Freeciv-Dev] Re: palettes (was: client goto & patrol v2)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Thue <thue@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> I actually managed to make XAW work... And not mess up the color map in the
> trident tiles!
> The only thing left is to make an icon for patrol in the engels tileset. The
> one used in trident should be usable, but when I try adding it using the GIMP
> the
> color map goes wrong and the diff becomes huge. How to do that?
I remembered I had a similar problem once before, and I found the
attached perl program which I had written. Run it like:
xpm2palette.pl data/engels/tiles.xpm > ~/.gimp/palettes/engels_tiles_1_11_5
(sample engels_tiles_1_11_5 also attached)
Then in Gimp, do <right-btn> -> Image -> Indexed and select Custom Palette,
choosing above created palette. Then save, and it should do the right
thing... (well, "works for me"!)
-- David
#!/usr/local/bin/perl -w
# Takes xpm on input or filename, writes GIMP palette to output
# Just based on sample xpms, may not be very general --dwp */
use strict;
my @af = qw(a b c d e f);
my $first = 1;
my %hexhash = ();
@hexhash{0..9} = (0..9);
@hexhash{@af} = (10..15);
while(<>) {
next if(m(^\s*/\*\s[xX][pP][mM]\s\*/\s*$));
next if(m(^\s*static\s+char\s*\*\s*\w+\[\]\s*=\s*\{\s*$));
next if(m(^\s*\"\d+\s+\d+\s+\d+\s+\d+\",\s*$));
next if(m(^\s*\"\s+c\s+[Nn][Oo][Nn][Ee]\",\s*$));
if(m(^\s*\".{1,3}\s*c\s+\#([0-9a-zA-Z]{6})\",\s*$)) {
##print "rgb>", $1, "\n";
my @letters = split(//, $1);
##print join(" ", @letters), "\n";
my $r = $hexhash{lc $letters[0]} * 16 + $hexhash{lc $letters[1]};
my $g = $hexhash{lc $letters[2]} * 16 + $hexhash{lc $letters[3]};
my $b = $hexhash{lc $letters[4]} * 16 + $hexhash{lc $letters[5]};
if($first) {
print "GIMP Palette\n";
print "# Added by $0\n";
$first = 0;
}
print "$r $g $b\tUnknown\n";
next;
}
last;
##print $_;
}
engels_tiles_1_11_5
Description: GNU Zip compressed data
|
|