summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-10-13 21:14:01 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-10-14 01:19:06 +0800
commit9a87ef85fe92a1be62211ea8af8afd08dc460562 (patch)
tree4e74a1dcb8540c2e8a3a778ddc64f0d10d255630 /source
parent1e7f53baed664ceec64af09dd73149f7136dbe77 (diff)
downloadmupdf-9a87ef85fe92a1be62211ea8af8afd08dc460562.tar.xz
pnm: Premultiply alpha for use in pixmap.
Diffstat (limited to 'source')
-rw-r--r--source/fitz/load-pnm.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/fitz/load-pnm.c b/source/fitz/load-pnm.c
index f585cd8a..7c31c4df 100644
--- a/source/fitz/load-pnm.c
+++ b/source/fitz/load-pnm.c
@@ -531,6 +531,31 @@ pam_binary_read_image(fz_context *ctx, struct info *pnm, unsigned char *p, unsig
p += 2;
}
}
+
+ if (pnm->alpha)
+ {
+ /* CMYK is a subtractive colorspace, we want additive for premul alpha */
+ if (img->n > 4)
+ {
+ fz_pixmap *rgb = fz_new_pixmap(ctx, fz_device_rgb(ctx), img->w, img->h, 1);
+ rgb->xres = img->xres;
+ rgb->yres = img->yres;
+
+ fz_try(ctx)
+ {
+ fz_convert_pixmap(ctx, rgb, img);
+ fz_drop_pixmap(ctx, img);
+ img = rgb;
+ rgb = NULL;
+ }
+ fz_always(ctx)
+ fz_drop_pixmap(ctx, rgb);
+ fz_catch(ctx)
+ fz_rethrow(ctx);
+ }
+
+ fz_premultiply_pixmap(ctx, img);
+ }
}
return img;