diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-07-21 23:45:31 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-07-21 23:45:31 +0000 |
commit | 9baad7f04bd421138461457399fa74e757a44ec3 (patch) | |
tree | 6c70368a9237eaa74b53f9810eae75f93d200538 /fitz | |
parent | d5d8d07709f6ad7d76ee1c466faf4d28549299a9 (diff) | |
download | mupdf-9baad7f04bd421138461457399fa74e757a44ec3.tar.xz |
Add Robin Watts' smooth image scaling code.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/dev_draw.c | 32 | ||||
-rw-r--r-- | fitz/fitz.h | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index f707b968..95d479ab 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -6,6 +6,8 @@ #define STACKSIZE 96 +#define noSMOOTHSCALE + typedef struct fz_drawdevice_s fz_drawdevice; struct fz_drawdevice_s @@ -574,11 +576,21 @@ fz_drawfillimage(void *user, fz_pixmap *image, fz_matrix ctm) image = converted; } +#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) + { + scaled = fz_smoothscalepixmap(image, image->x, image->y, dx, dy); + image = scaled; + } +#else if (fz_calcimagescale(image, ctm, &dx, &dy)) { scaled = fz_scalepixmap(image, dx, dy); image = scaled; } +#endif fz_blendimage(dev->dest, dev->scissor, image, ctm); @@ -603,11 +615,21 @@ fz_drawfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, if (image->w == 0 || image->h == 0) return; +#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) + { + scaled = fz_smoothscalepixmap(image, image->x, image->y, dx, dy); + image = scaled; + } +#else if (fz_calcimagescale(image, ctm, &dx, &dy)) { scaled = fz_scalepixmap(image, dx, dy); image = scaled; } +#endif if (dev->dest->colorspace) { @@ -661,11 +683,21 @@ fz_drawclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm) fz_clearpixmap(mask, 0); fz_clearpixmap(dest, 0); +#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) + { + scaled = fz_smoothscalepixmap(image, image->x, image->y, dx, dy); + image = scaled; + } +#else if (fz_calcimagescale(image, ctm, &dx, &dy)) { scaled = fz_scalepixmap(image, dx, dy); image = scaled; } +#endif fz_blendimage(mask, bbox, image, ctm); diff --git a/fitz/fitz.h b/fitz/fitz.h index 12a273a5..140f2f60 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -707,6 +707,7 @@ fz_pixmap *fz_alphafromgray(fz_pixmap *gray, int luminosity); fz_bbox fz_boundpixmap(fz_pixmap *pix); fz_pixmap * fz_scalepixmap(fz_pixmap *src, int xdenom, int ydenom); +fz_pixmap * fz_smoothscalepixmap(fz_pixmap *src, float x, float y, float w, float h); fz_error fz_writepnm(fz_pixmap *pixmap, char *filename); fz_error fz_writepam(fz_pixmap *pixmap, char *filename, int savealpha); |