Gábor Stefanik created PDFBOX-4832:
--------------------------------------

             Summary: Binary CCITT image with nearest neighbor interpolation 
instead gets upscaled with bicubic, PDFBox thinks it's downscaling
                 Key: PDFBOX-4832
                 URL: https://issues.apache.org/jira/browse/PDFBOX-4832
             Project: PDFBox
          Issue Type: Bug
          Components: Rendering
    Affects Versions: 2.0.19
            Reporter: Gábor Stefanik
         Attachments: pdf_scanned-eng-bw.pdf

The attached PDF contains a CCITT-encoded black-and-white image of a roughly US 
Letter-sized page (611x783 PDF points page size), scanned at 200DPI. The image 
is slightly undersized, at 1696 pixels wide, instead of the expected 1697. The 
PDF calls for this image to be upscaled using nearest-neighbor interpolation 
(downscaling is always smoothly interpolated, to avoid artifacts - see 
PDFBOX-2364).

When I try to render this page to an RGB image in either 200 or 300 DPI, the 
image unexpectedly ends up containing shades of gray. Upon closer inspection, 
it is clear that the upscaling was performed using bicubic interpolation 
instead of nearest-neighbor. Stepping through the PDF rendering code reveals 
that, in both cases, PDFBox somehow thinks the image is being _down_scaled, and 
applies the behavior from PDFBOX-2364. Additionally, PDFBOX-4831 may also be at 
play here, as the computed target image dimensions aren't round integers, but 
very slightly undersized (e.g. 2174.999858106px instead of 2175px).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to