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

Comparing cfmaps/cfmap2png (file contents):
Revision 1.4 by root, Fri Nov 18 12:04:12 2005 UTC vs.
Revision 1.6 by root, Fri Nov 18 12:50:24 2005 UTC

195 } 195 }
196 196
197 $meta{width} = $mapx; 197 $meta{width} = $mapx;
198 $meta{height} = $mapy; 198 $meta{height} = $mapy;
199 199
200 my %map_face;
201 my %draw_info; 200 my %draw_info;
202 201
203 # first pass, gather face stacking order, border and corner info 202 # first pass, gather face stacking order, border and corner info
204 for my $x (0 .. $mapx - 1) { 203 for my $x (0 .. $mapx - 1) {
205 my $col = $map->[$x]; 204 my $col = $map->[$x];
210 my $a = $as->[$layer]; 209 my $a = $as->[$layer];
211 210
212 my $o = $arch->{$a->{_name}} 211 my $o = $arch->{$a->{_name}}
213 or (warn "$mapname: arch '$a->{_name}' not found at ($x|$y)\n"), next; 212 or (warn "$mapname: arch '$a->{_name}' not found at ($x|$y)\n"), next;
214 213
215 my $A = { %$o, %$a }; 214 my $smoothlevel = exists $a->{smoothlevel} ? $a->{smoothlevel} : $o->{smoothlevel};
216 215 my $is_floor = exists $a->{is_floor} ? $a->{is_floor} : $o->{is_floor};
217 my $smoothlevel = $A->{smoothlevel};
218 my $level = $smoothlevel ? $smoothlevel 216 my $level = $smoothlevel ? $smoothlevel
219 : $A->{is_floor} ? 0 217 : $is_floor ? 0
220 : 256 + $layer; 218 : 256 + $layer;
221 219
222 while ($o) { 220 while ($o) {
221 my $face = $a->{face} || $o->{face};
222
223 my $pb = tile $A->{face} 223 my $pb = tile $face
224 or (warn "$mapname: face '$A->{face}' not found for arch '$a->{_name}' at ($x|$y)\n"), last; 224 or (warn "$mapname: face '$face' not found for arch '$a->{_name}' at ($x|$y)\n"), last;
225 225
226 my $mx = $x + $o->{x}; 226 my $mx = $x + $o->{x};
227 my $my = $y + $o->{y}; 227 my $my = $y + $o->{y};
228 228
229 last if 0 > $mx || $mx >= $mapx 229 last if 0 > $mx || $mx >= $mapx
230 || 0 > $my || $my >= $mapy; 230 || 0 > $my || $my >= $mapy;
231 231
232 # this is very ugly (some tiles are 32x33 or worse) 232 # this is very ugly (some tiles are 32x33 or worse)
233 my $bigface = $pb->get_width >= T*2 || $pb->get_height >= T*2; 233 my $bigface = $pb->get_width >= T*2 || $pb->get_height >= T*2;
234 234
235 if (my $sface = $smooth->{$A->{face}}) { 235 if (my $sface = $smooth->{$face}) {
236 $bigface and die "can't handle bigfaces with smoothing ($A->{face})\n"; 236 $bigface and die "can't handle bigfaces with smoothing ($face)\n";
237 237
238 # full tile 238 # full tile
239 $draw_info{$smoothlevel}{$sface}{$mx , $my } |= 0x1000; 239 $draw_info{$smoothlevel}{$sface}{$mx , $my } |= 0x1000;
240 240
241 # borders 241 # borders
252 } 252 }
253 253
254 my $dx = $bigface ? $o->{x} : 0; 254 my $dx = $bigface ? $o->{x} : 0;
255 my $dy = $bigface ? $o->{y} : 0; 255 my $dy = $bigface ? $o->{y} : 0;
256 256
257 $draw_info{$level}{$o->{face}}{$mx, $my} |= 0x2000 | (($dx + 128) << 24) | (($dy + 128) << 16); 257 $draw_info{$level}{$face}{$mx, $my} |= 0x2000 | (($dx + 128) << 24) | (($dy + 128) << 16);
258 258
259 $o = $o->{more}; 259 $o = $o->{more};
260 } 260 }
261 } 261 }
262 } 262 }
329for my $file (@ARGV) { 329for my $file (@ARGV) {
330 my $mapa = read_arch $file; 330 my $mapa = read_arch $file;
331 my ($pb, $meta) = cfmap_render $mapa, $file; 331 my ($pb, $meta) = cfmap_render $mapa, $file;
332 $pb->save ("$file.png~", "png"); 332 $pb->save ("$file.png~", "png");
333 system "convert", "$file.png~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg"; 333 system "convert", "$file.png~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg";
334 system "mogrify", "-colors" => 65536, "$file.png~"; 334 #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency
335 system "pngcrush", "-q", "-m" => 7, "-rem" => "alla", "-reduce", "$file.png~", "$file.png"; 335 system "pngcrush", "-q", "-m" => 7, "-rem", "alla", "-cc", "-reduce", "$file.png~", "$file.png";
336 unlink "$file.png~"; 336 unlink "$file.png~";
337 Storable::nstore $meta, "$file.pst"; 337 Storable::nstore $meta, "$file.pst";
338} 338}
339 339
340 340

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines