summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-12-08 12:04:43 +0000
committerRobin Watts <robin.watts@artifex.com>2011-12-08 12:04:43 +0000
commit13dc7237ff5177b75fc6d5c1289eabc68cc7504b (patch)
treeebbcac2c91835576555d9e1c7130ad7bd1f2df0e /fitz
parentd0724c562bb7ae6ad81eb89b064d59a73685f3a8 (diff)
parentba531f60532022e3419628e506462b6b84279478 (diff)
downloadmupdf-13dc7237ff5177b75fc6d5c1289eabc68cc7504b.tar.xz
Merge branch 'master' into context
Diffstat (limited to 'fitz')
-rw-r--r--fitz/base_object.c2
-rw-r--r--fitz/fitz.h1
-rw-r--r--fitz/res_pixmap.c20
3 files changed, 22 insertions, 1 deletions
diff --git a/fitz/base_object.c b/fitz/base_object.c
index 2876f363..8c79e4c6 100644
--- a/fitz/base_object.c
+++ b/fitz/base_object.c
@@ -208,7 +208,7 @@ int fz_to_int(fz_obj *obj)
if (fz_is_int(obj))
return obj->u.i;
if (fz_is_real(obj))
- return obj->u.f;
+ return (int)(obj->u.f + 0.5f); /* No roundf in MSVC */
return 0;
}
diff --git a/fitz/fitz.h b/fitz/fitz.h
index c3c33487..70d14086 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -709,6 +709,7 @@ void fz_clear_pixmap_with_color(fz_pixmap *pix, int value);
void fz_clear_pixmap_rect_with_color(fz_pixmap *pix, int value, fz_bbox r);
void fz_copy_pixmap_rect(fz_pixmap *dest, fz_pixmap *src, fz_bbox r);
void fz_premultiply_pixmap(fz_pixmap *pix);
+void fz_unmultiply_pixmap(fz_pixmap *pix);
fz_pixmap *fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray, int luminosity);
fz_bbox fz_bound_pixmap(fz_pixmap *pix);
void fz_invert_pixmap(fz_pixmap *pix);
diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c
index 471dcc72..1dfc8ad0 100644
--- a/fitz/res_pixmap.c
+++ b/fitz/res_pixmap.c
@@ -226,6 +226,26 @@ fz_premultiply_pixmap(fz_pixmap *pix)
}
}
+void
+fz_unmultiply_pixmap(fz_pixmap *pix)
+{
+ unsigned char *s = pix->samples;
+ int a, inva;
+ int k, x, y;
+
+ for (y = 0; y < pix->h; y++)
+ {
+ for (x = 0; x < pix->w; x++)
+ {
+ a = s[pix->n - 1];
+ inva = a ? 255 * 256 / a : 0;
+ for (k = 0; k < pix->n - 1; k++)
+ s[k] = (s[k] * inva) >> 8;
+ s += pix->n;
+ }
+ }
+}
+
fz_pixmap *
fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray, int luminosity)
{