ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfmap2png
(Generate patch)

Comparing cfmaps/cfmap2png (file contents):
Revision 1.23 by root, Thu Jun 21 00:09:39 2007 UTC vs.
Revision 1.26 by root, Tue Aug 26 01:28:16 2008 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3# cfarch2png - convert crossfire maps to png+metadata 3# cfarch2png - convert deliantra maps to png+metadata
4# Copyright (C) 2005,2007 Marc Lehmann <cfmaps@schmorp.de> 4# Copyright (C) 2005,2007,2008 Marc Lehmann <cfmaps@schmorp.de>
5# 5#
6# CFARCH2PNG is free software; you can redistribute it and/or modify 6# CFARCH2PNG is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by 7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or 8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version. 9# (at your option) any later version.
28# Bottom object: the highest object that is a floor type object. 28# Bottom object: the highest object that is a floor type object.
29# 29#
30# ... I believe that anytime, but it still doesn't mention the smoothlevel 30# ... I believe that anytime, but it still doesn't mention the smoothlevel
31# interaction :( 31# interaction :(
32 32
33our $VERSION = '2.001'; 33our $VERSION = '2.002';
34 34
35use strict; 35use strict;
36 36
37use Crossfire 1.0; 37use Deliantra;
38use List::Util qw(max); 38use List::Util qw(max);
39 39
40use Gtk2; 40use Gtk2;
41 41
42sub T (){ 32 } 42sub T (){ 32 }
43 43
44Crossfire::load_archetypes; 44Deliantra::load_archetypes;
45Crossfire::load_tilecache; 45Deliantra::load_tilecache;
46 46
47sub cfmap_render($;$) { 47sub cfmap_render($;$) {
48 my ($mapa, $mapname) = @_; 48 my ($mapa, $mapname) = @_;
49 49
50 my %meta; 50 my %meta;
217 217
218 ($map_pb, \%meta) 218 ($map_pb, \%meta)
219} 219}
220 220
221for my $file (@ARGV) { 221for my $file (@ARGV) {
222 my $mapa = read_arch $file;
223 $file =~ s/\.map$//; 222 $file =~ s/\.map$//;
223 my $mapa = read_arch "$file.map";
224 my ($pb, $meta) = cfmap_render $mapa, $file; 224 my ($pb, $meta) = cfmap_render $mapa, $file;
225 $pb->save ("$file.png~~", "png"); 225 $pb->save ("$file.png~~", "png");
226 system "gm", "convert", "$file.png~~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg"; 226 system "gm", "convert", "$file.png~~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg";
227 #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency 227 #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency
228 system "optipng", "-q", "-out", "$file.png~", "$file.png~~"; 228 system "optipng", "-q", "-out", "$file.png~", "$file.png~~";
229# system "pngnq <\Q$file.png~\E >\Q$file.png\E"; 229# system "pngnq <\Q$file.png~\E >\Q$file.png\E";
230 unlink "$file.png~~"; 230 unlink "$file.png~~";
231 Storable::nstore $meta, "$file.pst"; 231 utime +(stat "$file.map")[8,9], "$file.jpg" or die "$file.jpg: $!";
232 utime +(stat $file)[8,9], "$file.pst"; 232 utime +(stat "$file.map")[8,9], "$file.png~" or die "$file.png~: $!";
233 utime +(stat $file)[8,9], "$file.jpg";
234 utime +(stat $file)[8,9], "$file.png~";
235 rename "$file.png~", "$file.png"; 233 rename "$file.png~", "$file.png";
236} 234}
237 235
238 236
239 237

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines