diff options
author | Robin Watts <robin.watts@artifex.com> | 2015-07-13 16:23:14 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2015-07-20 17:19:03 +0100 |
commit | 269fdfce2527cbba02e68d658af3f4b92ef40be0 (patch) | |
tree | c75e9e4abdae745c64f98eaafa86d572e747f536 /source/gprf/gprf-doc.c | |
parent | d8353609755104010afaf3e1967a36959f28c5dc (diff) | |
download | mupdf-269fdfce2527cbba02e68d658af3f4b92ef40be0.tar.xz |
Improve Grid fitting of images for .gproof files.
By default in MuPDF, when we render an axis aligned image, we
'gridfit' it. This is a heuristic used to improve the rendering
of tiled images, and avoid the background showing through on the
antialiased edges.
The general algorithm we use is to expand any image outwards so that
it completely covers any pixels that it touches any part of. This is
'safe' in that we never cause any pixels to not be covered that
should otherwise be so, and is important when we have images that are
aligned with (say) line art rectangles.
For gproof files though, this gives nasty results - because we have
multiple images tiled across the page all exactly abutting, in most
cases the edges will not be on exact integer coordinates. This means
we expand both images and 1 (destination) pixel is lost. This severely
hurts the rendering (in particular on text based pages).
We therefore introduce a new type of grid fitting, where we simply
align the edges of images to the closest integer pixel. This is safe
because we know that neighbouring images will be adjusted identically
and edges will stay coincident.
We enable/disable this behaviour through a new device flag, and make
the gproof interpreter set/clear this flag when generating the page -
thus normal rendering is unaffected.
We *could* have just poked the dev->flags fields directly, but that
would require magic in the display list device to check for them
being set/unset and to poke the dev->flags fields on playback, so
instead we introduce a new fz_render_flags function (that calls a
device function) to set/unset flags.
The other attraction of this is that if we ever have devices that
'filter', we can neatly handle passing flag changes on with those.
Currently the display list implementation only copes with set/clear
of the FZ_DEVFLAG_GRIDFIT_AS_TILED option. We only readily have 6
bits available to us, so we'll just extend this as required if we
add new render flags.
Diffstat (limited to 'source/gprf/gprf-doc.c')
-rw-r--r-- | source/gprf/gprf-doc.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/source/gprf/gprf-doc.c b/source/gprf/gprf-doc.c index bcd631ad..e9638340 100644 --- a/source/gprf/gprf-doc.c +++ b/source/gprf/gprf-doc.c @@ -596,6 +596,7 @@ gprf_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix * page_rect.y0 = 0; page_rect.x1 = 72.0 * page->width / doc->res; page_rect.y1 = 72.0 * page->height / doc->res; + fz_render_flags(ctx, dev, FZ_DEVFLAG_GRIDFIT_AS_TILED, 0); fz_begin_page(ctx, dev, &page_rect, ctm); i = 0; @@ -618,6 +619,7 @@ gprf_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix * } } fz_end_page(ctx, dev); + fz_render_flags(ctx, dev, 0, FZ_DEVFLAG_GRIDFIT_AS_TILED); } |