Bug 692666

Summary: Black bits in output reading PDF file
Product: Ghostscript Reporter: Marcos H. Woehrmann <marcos.woehrmann>
Component: PDF InterpreterAssignee: Robin Watts <robin.watts>
Status: NOTIFIED FIXED    
Severity: normal CC: customer531
Priority: P1    
Version: master   
Hardware: PC   
OS: All   
Customer: 531 Word Size: ---

Description Marcos H. Woehrmann 2011-11-07 21:07:15 UTC
The customer reports and I've verified that the attached PDF file has unexpected black portions when converted to tiffg4 @ 600 dpi.  These images do not appear black when the file is converted to TIFF mono @ 600 dpi using Acrobat X 10.1.1.

The command line I'm using for testing:

  bin/gs -sDEVICE=tiffg4 -o test.tif -r600 ./1016d.pdf
Comment 4 Alex Cherepanov 2011-11-08 05:17:35 UTC
The file draws black rectangles with white image masks on top of them.
All images in the file are 1 pixel high.

993.39 960.99 0.06 9.9 re
f
q
1 g
0 9.96 -0.12 0 993.48 960.96 cm
/Im203 Do
Q
Comment 5 Robin Watts 2011-11-22 12:59:55 UTC
This file, as Alex says, draws a sequence of thin horizontal rectangles, then plots an image mask over them.

Ghostscript is rendering each rectangle 2 pixel high (so it half overlaps the previous one) due to the proper postscript rule for filling pixels if any part of a pixel is touched.

The images however are only being rendered 1 pixel high, and hence being erased as soon as the next rectangle is plotted.

I am testing a fix for this now.
Comment 6 Customer 531 2011-11-22 14:35:14 UTC
Hi Robin,

Thanks for the update. Looking forward to the fix!
Comment 7 Robin Watts 2011-11-24 00:38:16 UTC
Fixed in commit:


commit 83788c03875545d620e6885e4f5ab4af08f8f55b
Author: Robin Watts <robin.watts@artifex.com>
Date:   Mon Nov 21 20:31:09 2011 +0000

    Bug 692666: grid fit images.

    The file in bug 692666 draws many thin horizontal rectangles, then draws
    1 pixel high images on top of each one. Current gs 'thickens' the
    rectangles (due to the 'any part of a pixel' rule), and they overwrite
    the previously drawn image - hence it appears black.

    The problem is thus that the images are not similarly stretched.

    Images are not supposed to use the "any part of a pixel" rule, where
    vectors are, but the fact this file works in acrobat would seem to
    contradict that. Instead we try a simple fix; if we are using the
    'any part of a pixel' file (i.e. fill_adjust != 0), and we meet an
    ImageMask image that is either 1 pixel high, or 1 pixel wide, then we
    ensure that it is 'stretched' to completely fill any pixels that it
    touches.

    We specifically do NOT perform this stretching if we are in the process
    of rendering a glyph.

    This produces various rendering diffs, none that offensive.