--- poppler-0.15.3-mask/poppler/PSOutputDev.cc- 2010-11-26 20:32:40.000000000 +0100 +++ poppler-0.15.3-mask/poppler/PSOutputDev.cc 2010-12-15 01:52:40.076981071 +0100 @@ -567,6 +567,7 @@ " not { pop exit } if", " (%-EOD-) eq { exit } if } loop", "} def", + "~123sn", "/pr { 2 index 2 index 3 2 roll putinterval 4 add } def", "/pdfImClip {", " gsave", @@ -4446,7 +4447,8 @@ break; case psLevel1Sep: //~ handle indexed, separation, ... color spaces - doImageL1Sep(colorMap, gFalse, inlineImg, str, width, height, len); + doImageL1Sep(ref, colorMap, gFalse, inlineImg, str, + width, height, len, maskColors, NULL, 0, 0, gFalse); break; case psLevel2: case psLevel2Sep: @@ -4479,7 +4481,8 @@ break; case psLevel1Sep: //~ handle indexed, separation, ... color spaces - doImageL1Sep(colorMap, gFalse, gFalse, str, width, height, len); + doImageL1Sep(ref, colorMap, gFalse, gFalse, str, width, height, len, + NULL, maskStr, maskWidth, maskHeight, maskInvert); break; case psLevel2: case psLevel2Sep: @@ -4608,15 +4611,22 @@ } } -void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, +void PSOutputDev::doImageL1Sep(Object *ref, GfxImageColorMap *colorMap, GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len) { + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert) { ImageStream *imgStr; Guchar *lineBuf; Guchar pixBuf[gfxColorMaxComps]; GfxCMYK cmyk; int x, y, i, comp; + // explicit masking + if (maskStr && !(maskColors && colorMap)) { + maskToClippingPath(maskStr, maskWidth, maskHeight, maskInvert); + } + // width, height, matrix, bits per component writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1Sep\n", width, height, @@ -4665,6 +4675,10 @@ str->close(); delete imgStr; gfree(lineBuf); + + if (maskStr && !(maskColors && colorMap)) { + writePS("pdfImClipEnd\n"); + } } void PSOutputDev::maskToClippingPath(Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert) { --- poppler-0.15.3-mask/poppler/PSOutputDev.h- 2010-11-10 23:32:14.000000000 +0100 +++ poppler-0.15.3-mask/poppler/PSOutputDev.h 2010-12-15 01:47:09.639634949 +0100 @@ -318,9 +318,11 @@ void doImageL1(Object *ref, GfxImageColorMap *colorMap, GBool invert, GBool inlineImg, Stream *str, int width, int height, int len); - void doImageL1Sep(GfxImageColorMap *colorMap, + void doImageL1Sep(Object *ref, GfxImageColorMap *colorMap, GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len); + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert); void doImageL2(Object *ref, GfxImageColorMap *colorMap, GBool invert, GBool inlineImg, Stream *str, int width, int height, int len,