summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2011-02-08 08:37:25 +0000
committerTor Andersson <tor@ghostscript.com>2011-02-08 08:37:25 +0000
commit1b8a2963bd93117e72d2a5159e739a77e455c37f (patch)
tree8aa94c005529ad52c92d07cbefdc7fe3be76de51
parent385b171b8bef464bbf652c81d85728ccb064ab86 (diff)
downloadmupdf-1b8a2963bd93117e72d2a5159e739a77e455c37f.tar.xz
Only interpolate upscaled images when the interpolate flag is set in the image dictionary.
-rw-r--r--draw/imagedraw.c15
-rw-r--r--fitz/dev_draw.c6
-rw-r--r--fitz/fitz.h1
-rw-r--r--fitz/res_colorspace.c4
-rw-r--r--fitz/res_pixmap.c1
-rw-r--r--mupdf/pdf_colorspace.c1
-rw-r--r--mupdf/pdf_image.c1
7 files changed, 20 insertions, 9 deletions
diff --git a/draw/imagedraw.c b/draw/imagedraw.c
index d2468b38..c44a3ba1 100644
--- a/draw/imagedraw.c
+++ b/draw/imagedraw.c
@@ -289,12 +289,15 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm,
/* turn on interpolation for upscaled and non-rectilinear transforms */
dolerp = 0;
- if (!fz_isrectilinear(ctm))
- dolerp = 1;
- if (sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) > img->w)
- dolerp = 1;
- if (sqrtf(ctm.c * ctm.c + ctm.d * ctm.d) > img->h)
- dolerp = 1;
+ if (img->interpolate)
+ {
+ if (!fz_isrectilinear(ctm))
+ dolerp = 1;
+ if (sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) > img->w)
+ dolerp = 1;
+ if (sqrtf(ctm.c * ctm.c + ctm.d * ctm.d) > img->h)
+ dolerp = 1;
+ }
bbox = fz_roundrect(fz_transformrect(ctm, fz_unitrect));
bbox = fz_intersectbbox(bbox, scissor);
diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c
index 439c4115..4d3c94f2 100644
--- a/fitz/dev_draw.c
+++ b/fitz/dev_draw.c
@@ -601,7 +601,7 @@ 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);
- if (dx < image->w && dy < image->h)
+ if (dx < image->w || dy < image->h)
{
scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy);
if (scaled == nil)
@@ -649,7 +649,7 @@ fz_drawfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm,
#ifdef SMOOTHSCALE
dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b);
dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
- if (dx < image->w && dy < image->h)
+ if (dx < image->w || dy < image->h)
{
scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy);
if (scaled == nil)
@@ -720,7 +720,7 @@ fz_drawclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm)
#ifdef SMOOTHSCALE
dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b);
dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
- if (dx < image->w && dy < image->h)
+ if (dx < image->w || dy < image->h)
{
scaled = fz_smoothtransformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy);
if (scaled == nil)
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 6a339303..685a75f3 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -611,6 +611,7 @@ struct fz_pixmap_s
int refs;
int x, y, w, h, n;
fz_pixmap *mask; /* explicit soft/image mask */
+ int interpolate;
fz_colorspace *colorspace;
unsigned char *samples;
int freesamples;
diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c
index f3ea317d..09e6c349 100644
--- a/fitz/res_colorspace.c
+++ b/fitz/res_colorspace.c
@@ -497,6 +497,10 @@ fz_convertpixmap(fz_pixmap *sp, fz_pixmap *dp)
assert(ss && ds);
+ if (sp->mask)
+ dp->mask = fz_keeppixmap(sp->mask);
+ dp->interpolate = sp->interpolate;
+
if (ss == fz_devicegray)
{
if (ds == fz_devicergb) fastgraytorgb(sp, dp);
diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c
index 88e10230..e70d084d 100644
--- a/fitz/res_pixmap.c
+++ b/fitz/res_pixmap.c
@@ -12,6 +12,7 @@ fz_newpixmapwithdata(fz_colorspace *colorspace, int x, int y, int w, int h, unsi
pix->w = w;
pix->h = h;
pix->mask = nil;
+ pix->interpolate = 1;
pix->colorspace = nil;
pix->n = 1;
diff --git a/mupdf/pdf_colorspace.c b/mupdf/pdf_colorspace.c
index 4fb0c54d..28774fe1 100644
--- a/mupdf/pdf_colorspace.c
+++ b/mupdf/pdf_colorspace.c
@@ -229,6 +229,7 @@ pdf_expandindexedpixmap(fz_pixmap *src)
if (src->mask)
dst->mask = fz_keeppixmap(src->mask);
+ dst->interpolate = src->interpolate;
return dst;
}
diff --git a/mupdf/pdf_image.c b/mupdf/pdf_image.c
index 9d59d9b2..aa9df25b 100644
--- a/mupdf/pdf_image.c
+++ b/mupdf/pdf_image.c
@@ -233,6 +233,7 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz
fz_dropcolorspace(colorspace);
tile->mask = mask;
+ tile->interpolate = interpolate;
fz_free(samples);