summaryrefslogtreecommitdiff
path: root/source/fitz/load-pnm.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-10-13 21:20:54 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-10-14 01:19:07 +0800
commited229f9ac6c2d85e2cdd789aba03e1dfd3cd55fc (patch)
tree3b9c486394be5f5fd9ac4c5233ff76686961100b /source/fitz/load-pnm.c
parent126565f00653f7b6e05999ce309b8e07e14ef548 (diff)
downloadmupdf-ed229f9ac6c2d85e2cdd789aba03e1dfd3cd55fc.tar.xz
pnm: Support b/w PAM images with alpha.
Diffstat (limited to 'source/fitz/load-pnm.c')
-rw-r--r--source/fitz/load-pnm.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/source/fitz/load-pnm.c b/source/fitz/load-pnm.c
index abb97096..3f572907 100644
--- a/source/fitz/load-pnm.c
+++ b/source/fitz/load-pnm.c
@@ -4,6 +4,7 @@ enum
{
PAM_UNKNOWN = 0,
PAM_BW,
+ PAM_BWA,
PAM_GRAY,
PAM_GRAYA,
PAM_RGB,
@@ -152,6 +153,7 @@ pnm_read_tupletype(fz_context *ctx, unsigned char *p, unsigned char *e, int *tup
const struct { int len; char *str; int type; } tupletypes[] =
{
{13, "BLACKANDWHITE", PAM_BW},
+ {19, "BLACKANDWHITE_ALPHA", PAM_BWA},
{9, "GRAYSCALE", PAM_GRAY},
{15, "GRAYSCALE_ALPHA", PAM_GRAYA},
{3, "RGB", PAM_RGB},
@@ -431,7 +433,7 @@ pam_binary_read_image(fz_context *ctx, struct info *pnm, unsigned char *p, unsig
switch (pnm->depth)
{
case 1: pnm->tupletype = pnm->maxval == 1 ? PAM_BW : PAM_GRAY; break;
- case 2: pnm->tupletype = PAM_GRAYA; break;
+ case 2: pnm->tupletype = pnm->maxval == 1 ? PAM_BWA : PAM_GRAYA; break;
case 3: pnm->tupletype = PAM_RGB; break;
case 4: pnm->tupletype = PAM_CMYK; break;
case 5: pnm->tupletype = PAM_CMYKA; break;
@@ -443,14 +445,20 @@ pam_binary_read_image(fz_context *ctx, struct info *pnm, unsigned char *p, unsig
pnm->tupletype = PAM_GRAY;
else if (pnm->tupletype == PAM_GRAY && pnm->maxval == 1)
pnm->tupletype = PAM_BW;
+ else if (pnm->tupletype == PAM_BWA && pnm->maxval > 1)
+ pnm->tupletype = PAM_GRAYA;
+ else if (pnm->tupletype == PAM_GRAYA && pnm->maxval == 1)
+ pnm->tupletype = PAM_BWA;
switch (pnm->tupletype)
{
+ case PAM_BWA:
+ pnm->alpha = 1;
+ /* fallthrough */
case PAM_BW:
pnm->cs = fz_device_gray(ctx);
maxval = 1;
- if (pnm->maxval == 1)
- bitmap = 1;
+ bitmap = 1;
break;
case PAM_GRAYA:
pnm->alpha = 1;