Add PNG predictor test page (yes, we have problems)

This commit is contained in:
Michael R Sweet
2021-06-01 17:10:36 -04:00
parent 97846e0f34
commit 2856b440d1
2 changed files with 270 additions and 2 deletions

View File

@@ -653,6 +653,8 @@ pdfioStreamWrite(
*prevptr; // Previous raw buffer
PDFIO_DEBUG("pdfioStreamWrite(st=%p, buffer=%p, bytes=%lu)\n", st, buffer, (unsigned long)bytes);
// Range check input...
if (!st || st->pdf->mode != _PDFIO_MODE_WRITE || !buffer || !bytes)
return (false);
@@ -679,7 +681,7 @@ pdfioStreamWrite(
{
// Store the PNG predictor in the first byte of the buffer...
if (st->predictor == _PDFIO_PREDICTOR_PNG_AUTO)
st->pbuffers[st->pbcurrent][0] = 4;
st->pbuffers[st->pbcurrent][0] = 4; // Use Paeth predictor for auto...
else
st->pbuffers[st->pbcurrent][0] = (unsigned char)(st->predictor - 10);
@@ -693,6 +695,11 @@ pdfioStreamWrite(
// Anti-compiler-warning code (NONE is handled above, TIFF is not supported for writing)
return (false);
case _PDFIO_PREDICTOR_PNG_NONE :
// No PNG predictor...
memcpy(thisptr, buffer, pbline);
break;
case _PDFIO_PREDICTOR_PNG_SUB :
// Encode the difference from the previous column
for (remaining = pbline; remaining > 0; remaining --, bufptr ++, thisptr ++)
@@ -741,6 +748,7 @@ pdfioStreamWrite(
return (false);
st->pbcurrent = !st->pbcurrent;
bytes -= pbline;
}
return (true);