PNG re-work: fix line length calculations for pngdump.pl
authorTony Cook <tony@develop-help.com>
Fri, 20 Apr 2012 10:14:51 +0000 (20:14 +1000)
committerTony Cook <tony@develop-help.com>
Sun, 29 Apr 2012 03:40:56 +0000 (13:40 +1000)
fileformatdocs/pngdump.pl

index e79d964e4d67e6bb31d9db6419746e37ade5af90..f2dcf249390570cef76ce21edd99d335108140c4 100644 (file)
@@ -56,10 +56,11 @@ while (my ($dlen, $data, $len, $type, $payload, $crc) = read_chunk($fh)) {
 EOS
     $colour_type = $ct;
     $bits = $d;
-    my $channels = $ct == 2 ? 3 : $ct == 4 ? 2 : $ct == 6 ? 4 : 0;
+    my $channels = $ct == 2 ? 3 : $ct == 4 ? 2 : $ct == 6 ? 4 : 1;
     my $bitspp = $channels * $d;
     $sline_len = int((($w * $bitspp) + 7) / 8);
     ++$sline_len; # filter byte
+    print "  Line length: $sline_len\n";
   }
   elsif ($type eq 'sRGB') {
     print "  Rendering intent: ", ord($payload), "\n";