--- 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 04:35:29.961581277 +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", @@ -4417,7 +4418,8 @@ switch (level) { case psLevel1: case psLevel1Sep: - doImageL1(ref, NULL, invert, inlineImg, str, width, height, len); + doImageL1(ref, NULL, invert, inlineImg, str, width, height, len, + NULL, NULL, 0, 0, gFalse); break; case psLevel2: case psLevel2Sep: @@ -4442,11 +4444,13 @@ colorMap->getBits() + 7) / 8); switch (level) { case psLevel1: - doImageL1(ref, colorMap, gFalse, inlineImg, str, width, height, len); + doImageL1(ref, colorMap, gFalse, inlineImg, str, + width, height, len, maskColors, NULL, 0, 0, gFalse); 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: @@ -4475,11 +4479,13 @@ colorMap->getBits() + 7) / 8); switch (level) { case psLevel1: - doImageL1(ref, colorMap, gFalse, gFalse, str, width, height, len); + doImageL1(ref, colorMap, gFalse, gFalse, str, width, height, len, + NULL, maskStr, maskWidth, maskHeight, maskInvert); 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: @@ -4497,12 +4503,19 @@ void PSOutputDev::doImageL1(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 pixBuf[gfxColorMaxComps]; GfxGray gray; int col, x, y, c, i; + // explicit masking + if (maskStr && !(maskColors && colorMap)) { + maskToClippingPath(maskStr, maskWidth, maskHeight, maskInvert); + } + if ((inType3Char || preload) && !colorMap) { if (inlineImg) { // create an array @@ -4606,17 +4619,28 @@ str->close(); } } + + if (maskStr && !(maskColors && colorMap)) { + writePS("pdfImClipEnd\n"); + } } -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 +4689,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 04:33:10.902284774 +0100 @@ -317,10 +317,14 @@ void maskToClippingPath(Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert); void doImageL1(Object *ref, GfxImageColorMap *colorMap, GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len); - void doImageL1Sep(GfxImageColorMap *colorMap, + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert); + 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,