diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-10-28 21:53:24 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-10-28 21:53:24 +0000 |
commit | 638f0fcd7638abfdd9275b3eccf84ededb971ce5 (patch) | |
tree | c83e3cae402239a87a740d06e77eaa03a414ed3b /fitz/dev_draw.c | |
parent | bb4dcc4a138882dd0a51792a0e9ad3b778063247 (diff) | |
download | mupdf-638f0fcd7638abfdd9275b3eccf84ededb971ce5.tar.xz |
Use smooth image scaling for non-rectilinear images. Patch by Robin Watts.
Diffstat (limited to 'fitz/dev_draw.c')
-rw-r--r-- | fitz/dev_draw.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index 744d5e76..e321eaf4 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -540,7 +540,7 @@ fz_calcimagescale(fz_pixmap *image, fz_matrix ctm, int *dx, int *dy) } static fz_pixmap * -fz_smoothtransformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y) +fz_smoothtransformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy) { fz_pixmap *scaled; @@ -568,6 +568,12 @@ fz_smoothtransformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y) ctm->e = scaled->y; return scaled; } + /* Downscale, non rectilinear case */ + if ((dx > 0) && (dy > 0)) + { + scaled = fz_smoothscalepixmap(image, 0, 0, (float)dx, (float)dy); + return scaled; + } return NULL; } @@ -597,11 +603,11 @@ fz_drawfillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) } #ifdef SMOOTHSCALE - dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b); - dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d); + dx = sqrtf(ctm.a * ctm.a + ctm.c * ctm.c); + dy = sqrtf(ctm.b * ctm.b + ctm.d * ctm.d); if (dx < image->w && dy < image->h) { - scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y); + scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy); if (scaled == NULL) { if (dx < 1) @@ -649,7 +655,7 @@ fz_drawfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d); if (dx < image->w && dy < image->h) { - scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y); + scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy); if (scaled == NULL) { if (dx < 1) @@ -720,7 +726,7 @@ fz_drawclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm) dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d); if (dx < image->w && dy < image->h) { - scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y); + scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy); if (scaled == NULL) { if (dx < 1) |