Hi All

There’s been lots of work recently on shading and tiling patterns and I’ve been 
testing out some
of the new rendering capabilities. However, I think I’ve discovered a 
fundamental problem with
using AWT’s PaintContext for drawing.

I noticed that the PDF from PDFBOX-1094 looks fine when rendered at the default 
72dpi however
if I render it at 144dpi then the tiling patterns appear pixelated. As 
expected, RenderUtil creates a
proportionally larger BufferedImage to render to and then calls 
graphics#scale(x,y) so that everything
drawn to the graphics is scaled. This seems to work as expected for vectors and 
drawImage, we get
nice crisp graphics at large scales. However, for our custom PaintContext 
classes we get pixellated
graphics.

I decided to instrument the calls to ColoredTilingContext#getRaster(x, y, w, h) 
at 72 and 144 dpi to see
if the problem is caused by up-scaling of paint *after* it is rendered to a 
raster. This is indeed, the cause
and I observed the following calls for the PDFBOX-1094 file:

72 DPI
----------
                 x     y     w   h
getRaster 302 586 76 76
getRaster 396 586 76 76
getRaster 344 662 86 86
getRaster 340 623 94 82
getRaster 302 317 76 76
getRaster 396 317 76 76
getRaster 344 393 86 87
getRaster 340 355 94 82

144 DPI
—————
                 x     y     w   h
getRaster 302 586 76 76
getRaster 396 586 76 76
getRaster 344 662 86 86
getRaster 340 623 94 82
getRaster 302 317 76 76
getRaster 396 317 76 76
getRaster 344 393 86 87
getRaster 340 355 94 82

Perhaps there is some rendering hint or Graphics setting we’re not aware of? If 
not we will have to migrate
away from using PaintContext and do the painting ourselves using a clipping 
path. :-(

-- John

Reply via email to