diff options
-rw-r--r-- | include/mupdf/fitz/device.h | 1 | ||||
-rw-r--r-- | source/fitz/draw-affine.c | 16 | ||||
-rw-r--r-- | source/fitz/draw-device.c | 10 | ||||
-rw-r--r-- | source/fitz/draw-imp.h | 4 | ||||
-rw-r--r-- | source/tools/mudraw.c | 2 |
5 files changed, 18 insertions, 15 deletions
diff --git a/include/mupdf/fitz/device.h b/include/mupdf/fitz/device.h index b39ff4ee..81e0e173 100644 --- a/include/mupdf/fitz/device.h +++ b/include/mupdf/fitz/device.h @@ -175,6 +175,7 @@ enum /* Hints */ FZ_IGNORE_IMAGE = 1, FZ_IGNORE_SHADE = 2, + FZ_DONT_INTERPOLATE_IMAGES = 4, }; /* diff --git a/source/fitz/draw-affine.c b/source/fitz/draw-affine.c index 1a7e1c57..284ca8df 100644 --- a/source/fitz/draw-affine.c +++ b/source/fitz/draw-affine.c @@ -941,7 +941,7 @@ fz_gridfit_matrix(fz_matrix *m) /* Draw an image with an affine transform on destination */ static void -fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, byte *color, int alpha) +fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, byte *color, int alpha, int lerp_allowed) { byte *dp, *sp, *hp; int u, v, fa, fb, fc, fd; @@ -961,11 +961,11 @@ fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz dolerp = 0; is_rectilinear = fz_is_rectilinear(&local_ctm); if (!is_rectilinear) - dolerp = 1; + dolerp = lerp_allowed; if (sqrtf(local_ctm.a * local_ctm.a + local_ctm.b * local_ctm.b) > img->w) - dolerp = 1; + dolerp = lerp_allowed; if (sqrtf(local_ctm.c * local_ctm.c + local_ctm.d * local_ctm.d) > img->h) - dolerp = 1; + dolerp = lerp_allowed; /* except when we shouldn't, at large magnifications */ if (!img->interpolate) @@ -1084,15 +1084,15 @@ fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz } void -fz_paint_image_with_color(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, byte *color) +fz_paint_image_with_color(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, byte *color, int lerp_allowed) { assert(img->n == 1); - fz_paint_image_imp(dst, scissor, shape, img, ctm, color, 255); + fz_paint_image_imp(dst, scissor, shape, img, ctm, color, 255, lerp_allowed); } void -fz_paint_image(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, int alpha) +fz_paint_image(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, int alpha, int lerp_allowed) { assert(dst->n == img->n || (dst->n == 4 && img->n == 2)); - fz_paint_image_imp(dst, scissor, shape, img, ctm, NULL, alpha); + fz_paint_image_imp(dst, scissor, shape, img, ctm, NULL, alpha, lerp_allowed); } diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index bcd93edb..66c670ba 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -561,7 +561,7 @@ fz_draw_fill_text(fz_device *devp, fz_text *text, const fz_matrix *ctm, else { fz_matrix mat = {pixmap->w, 0.0, 0.0, pixmap->h, x + pixmap->x, y + pixmap->y}; - fz_paint_image(state->dest, &state->scissor, state->shape, pixmap, &mat, alpha * 255); + fz_paint_image(state->dest, &state->scissor, state->shape, pixmap, &mat, alpha * 255, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES)); } fz_drop_glyph(dev->ctx, glyph); } @@ -1093,7 +1093,7 @@ fz_draw_fill_image(fz_device *devp, fz_image *image, const fz_matrix *ctm, float pixmap = converted; } - if (dx < pixmap->w && dy < pixmap->h) + if (dx < pixmap->w && dy < pixmap->h && !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES)) { int gridfit = alpha == 1.0f && !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3); scaled = fz_transform_pixmap(dev, pixmap, &local_ctm, state->dest->x, state->dest->y, dx, dy, gridfit, &clip); @@ -1126,7 +1126,7 @@ fz_draw_fill_image(fz_device *devp, fz_image *image, const fz_matrix *ctm, float } } - fz_paint_image(state->dest, &state->scissor, state->shape, pixmap, &local_ctm, alpha * 255); + fz_paint_image(state->dest, &state->scissor, state->shape, pixmap, &local_ctm, alpha * 255, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES)); if (state->blendmode & FZ_BLEND_KNOCKOUT) fz_knockout_end(dev); @@ -1198,7 +1198,7 @@ fz_draw_fill_image_mask(fz_device *devp, fz_image *image, const fz_matrix *ctm, colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; - fz_paint_image_with_color(state->dest, &state->scissor, state->shape, pixmap, &local_ctm, colorbv); + fz_paint_image_with_color(state->dest, &state->scissor, state->shape, pixmap, &local_ctm, colorbv, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES)); if (scaled) fz_drop_pixmap(dev->ctx, scaled); @@ -1304,7 +1304,7 @@ fz_draw_clip_image_mask(fz_device *devp, fz_image *image, const fz_rect *rect, c if (scaled) pixmap = scaled; } - fz_paint_image(mask, &bbox, state->shape, pixmap, &local_ctm, 255); + fz_paint_image(mask, &bbox, state->shape, pixmap, &local_ctm, 255, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES)); } fz_always(ctx) { diff --git a/source/fitz/draw-imp.h b/source/fitz/draw-imp.h index 82823519..9b9e50c0 100644 --- a/source/fitz/draw-imp.h +++ b/source/fitz/draw-imp.h @@ -34,8 +34,8 @@ void fz_paint_solid_color(unsigned char * restrict dp, int n, int w, unsigned ch void fz_paint_span(unsigned char * restrict dp, unsigned char * restrict sp, int n, int w, int alpha); void fz_paint_span_with_color(unsigned char * restrict dp, unsigned char * restrict mp, int n, int w, unsigned char *color); -void fz_paint_image(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, int alpha); -void fz_paint_image_with_color(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, unsigned char *colorbv); +void fz_paint_image(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, int alpha, int lerp_allowed); +void fz_paint_image_with_color(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, unsigned char *colorbv, int lerp_allowed); void fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha); void fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk); diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index c95be5e3..27f32f99 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -700,6 +700,8 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_clear_pixmap_with_value(ctx, pix, 255); dev = fz_new_draw_device(ctx, pix); + if (alphabits == 0) + fz_enable_device_hints(dev, FZ_DONT_INTERPOLATE_IMAGES); if (list) fz_run_display_list(list, dev, &ctm, &tbounds, &cookie); else |