Subject: | _fixDecodePNG works wrongly for multibyte sample sizes |
I see these lines of code in the function in question:
if ($row_pred == 1) { ##no critic (IfElse)
for my $i (1 .. $width-2) {
$row[$i] = ($row[$i-1] + $row[$i]) & 0xff;
}
} elsif ($row_pred == 2) {
Unless I misread the PNG spec, the $i-1 should not have -1 there, but -$sample_size, which can be calculated by multiplying $colors by ($bpc >> 3). PDF::API2 does it that way (unless I misread its source code, which I doubt). (See lib/PDF/API2/Basic/PDF/Filter/FlateDecode.pm in the latter distribution.)
The result is that any PDF that happens to use /BitsPerComponent 16 or /Colors with a value > 1 in its cross-reference streams will be unreadable by CAM::PDF.