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

Comparing cfmaps/cfmap2png (file contents):
Revision 1.19 by root, Fri Feb 3 07:11:52 2006 UTC vs.
Revision 1.21 by root, Wed Feb 14 02:33:47 2007 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3# cfarch2png - convert crossfire maps to png+metadata 3# cfarch2png - convert crossfire maps to png+metadata
4# Copyright (C) 2005 Marc Lehmann <gvpe@schmorp.de> 4# Copyright (C) 2005,2007 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 = '1.21'; 33our $VERSION = '1.211';
34 34
35use strict; 35use strict;
36 36
37use Storable; 37use Storable;
38use List::Util qw(max); 38use List::Util qw(max);
53 -M "$path.pst" < -M $path 53 -M "$path.pst" < -M $path
54 && Storable::retrieve "$path.pst" 54 && Storable::retrieve "$path.pst"
55 } or do { 55 } or do {
56 my %pak; 56 my %pak;
57 57
58 open my $fh, "<:raw", $path 58 open my $fh, "<:raw:perlio", $path
59 or die "$_[0]: $!"; 59 or die "$_[0]: $!";
60 while (<$fh>) { 60 while (<$fh>) {
61 my ($type, $id, $len, $path) = split; 61 my ($type, $id, $len, $path) = split;
62 $path =~ s/.*\///; 62 $path =~ s/.*\///;
63 read $fh, $pak{$path}, $len; 63 read $fh, $pak{$path}, $len;
76 -M "$path.pst" < -M $path 76 -M "$path.pst" < -M $path
77 && Storable::retrieve "$path.pst" 77 && Storable::retrieve "$path.pst"
78 } or do { 78 } or do {
79 my %smooth; 79 my %smooth;
80 80
81 open my $fh, "<:raw", $path 81 open my $fh, "<:raw:perlio", $path
82 or die "$path: $!"; 82 or die "$path: $!";
83 while (<$fh>) { 83 while (<$fh>) {
84 next if /^\s*($|#)/; 84 next if /^\s*($|#)/;
85 85
86 $smooth{$1} = $2 if /^(\S+)\s+(\S+)$/; 86 $smooth{$1} = $2 if /^(\S+)\s+(\S+)$/;
102 && Storable::retrieve "$path.pst" 102 && Storable::retrieve "$path.pst"
103 } or do { 103 } or do {
104 my %arc; 104 my %arc;
105 my ($more, $prev); 105 my ($more, $prev);
106 106
107 open my $fh, "<:raw", $path 107 open my $fh, "<:utf8", $path
108 or die "$path: $!"; 108 or die "$path: $!";
109 109
110 my $parse_block; $parse_block = sub { 110 my $parse_block; $parse_block = sub {
111 my %arc = @_; 111 my %arc = @_;
112 112
385 ($map_pb, \%meta) 385 ($map_pb, \%meta)
386} 386}
387 387
388for my $file (@ARGV) { 388for my $file (@ARGV) {
389 my $mapa = read_arch $file; 389 my $mapa = read_arch $file;
390 $file =~ s/\.map$//;
390 my ($pb, $meta) = cfmap_render $mapa, $file; 391 my ($pb, $meta) = cfmap_render $mapa, $file;
391 $pb->save ("$file.png~~", "png"); 392 $pb->save ("$file.png~~", "png");
392 system "convert", "$file.png~~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg"; 393 system "gm", "convert", "$file.png~~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg";
393 #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency 394 #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency
394 system "pngcrush", "-q", "-m" => 7, "-rem", "alla", "-cc", "-reduce", "$file.png~~", "$file.png~"; 395 system "pngcrush", "-q", "-m" => 7, "-rem", "alla", "-cc", "-reduce", "$file.png~~", "$file.png~";
395# system "pngnq <\Q$file.png~\E >\Q$file.png\E"; 396# system "pngnq <\Q$file.png~\E >\Q$file.png\E";
396 unlink "$file.png~~"; 397 unlink "$file.png~~";
397 Storable::nstore $meta, "$file.pst"; 398 Storable::nstore $meta, "$file.pst";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines