diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2012-01-20 17:39:25 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2012-01-20 18:05:59 +0100 |
commit | f08f46797df8d6cca982c08ed16eb1934b1dc7d9 (patch) | |
tree | b47ad08d45680ecc5a481a41b341ac7b86f7b8c5 /pdf | |
parent | 00ab7bd42463a4547dd563dd16cc99236c980459 (diff) | |
download | mupdf-f08f46797df8d6cca982c08ed16eb1934b1dc7d9.tar.xz |
Flip images the right side up in the PDF interpreter.
This way both pixmaps for rendering and image data are top-down.
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdf_interpret.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index 9d9d2cfc..ff9a8f2c 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -364,19 +364,24 @@ static void pdf_show_image(pdf_csi *csi, fz_pixmap *image) { pdf_gstate *gstate = csi->gstate + csi->gtop; + fz_matrix image_ctm; fz_rect bbox; if (csi->in_hidden_ocg > 0) return; - bbox = fz_transform_rect(gstate->ctm, fz_unit_rect); + /* PDF has images bottom-up, so flip them right side up here */ + image_ctm = fz_concat(fz_scale(1, -1), fz_translate(0, 1)); + image_ctm = fz_concat(image_ctm, gstate->ctm); + + bbox = fz_transform_rect(image_ctm, fz_unit_rect); if (image->mask) { /* apply blend group even though we skip the softmask */ if (gstate->blendmode) fz_begin_group(csi->dev, bbox, 0, 0, gstate->blendmode, 1); - fz_clip_image_mask(csi->dev, image->mask, &bbox, gstate->ctm); + fz_clip_image_mask(csi->dev, image->mask, &bbox, image_ctm); } else pdf_begin_group(csi, bbox); @@ -389,13 +394,13 @@ pdf_show_image(pdf_csi *csi, fz_pixmap *image) case PDF_MAT_NONE: break; case PDF_MAT_COLOR: - fz_fill_image_mask(csi->dev, image, gstate->ctm, + fz_fill_image_mask(csi->dev, image, image_ctm, gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha); break; case PDF_MAT_PATTERN: if (gstate->fill.pattern) { - fz_clip_image_mask(csi->dev, image, &bbox, gstate->ctm); + fz_clip_image_mask(csi->dev, image, &bbox, image_ctm); pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL); fz_pop_clip(csi->dev); } @@ -403,7 +408,7 @@ pdf_show_image(pdf_csi *csi, fz_pixmap *image) case PDF_MAT_SHADE: if (gstate->fill.shade) { - fz_clip_image_mask(csi->dev, image, &bbox, gstate->ctm); + fz_clip_image_mask(csi->dev, image, &bbox, image_ctm); fz_fill_shade(csi->dev, gstate->fill.shade, gstate->ctm, gstate->fill.alpha); fz_pop_clip(csi->dev); } @@ -412,7 +417,7 @@ pdf_show_image(pdf_csi *csi, fz_pixmap *image) } else { - fz_fill_image(csi->dev, image, gstate->ctm, gstate->fill.alpha); + fz_fill_image(csi->dev, image, image_ctm, gstate->fill.alpha); } if (image->mask) |