summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-10-28 21:53:24 +0000
committerTor Andersson <tor@ghostscript.com>2010-10-28 21:53:24 +0000
commit638f0fcd7638abfdd9275b3eccf84ededb971ce5 (patch)
treec83e3cae402239a87a740d06e77eaa03a414ed3b
parentbb4dcc4a138882dd0a51792a0e9ad3b778063247 (diff)
downloadmupdf-638f0fcd7638abfdd9275b3eccf84ededb971ce5.tar.xz
Use smooth image scaling for non-rectilinear images. Patch by Robin Watts.
-rw-r--r--draw/imagedraw.c4
-rw-r--r--fitz/dev_draw.c18
2 files changed, 14 insertions, 8 deletions
diff --git a/draw/imagedraw.c b/draw/imagedraw.c
index 668bfd22..99271c54 100644
--- a/draw/imagedraw.c
+++ b/draw/imagedraw.c
@@ -291,9 +291,9 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm,
dolerp = 0;
if (!fz_isrectilinear(ctm))
dolerp = 1;
- if (sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) > img->w)
+ if (sqrtf(ctm.a * ctm.a + ctm.c * ctm.c) > img->w)
dolerp = 1;
- if (sqrtf(ctm.c * ctm.c + ctm.d * ctm.d) > img->h)
+ if (sqrtf(ctm.b * ctm.b + ctm.d * ctm.d) > img->h)
dolerp = 1;
bbox = fz_roundrect(fz_transformrect(ctm, fz_unitrect));
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)