--- ImageOutputDev.cc.pbm-invert 2008-03-26 21:38:52.000000000 +0200 +++ ImageOutputDev.cc 2008-08-06 00:44:43.000000000 +0300 @@ -103,10 +103,13 @@ void ImageOutputDev::drawImage(GfxState FILE *f; ImageStream *imgStr; Guchar *p; + Guchar zero = 0; + GfxGray gray; GfxRGB rgb; int x, y; int c; int size, i; + int pbm_mask = 0xff; // dump JPEG file if (dumpJPEG && str->getKind() == strDCT && @@ -149,10 +152,16 @@ void ImageOutputDev::drawImage(GfxState // initialize stream str->reset(); + // if 0 comes out as 0 in the color map, the we _flip_ stream bits + // otherwise we pass through stream bits unmolested + colorMap->getGray(&zero, &gray); + if(colToByte(gray)) + pbm_mask = 0; + // copy the stream size = height * ((width + 7) / 8); for (i = 0; i < size; ++i) { - fputc(str->getChar(), f); + fputc(str->getChar() ^ pbm_mask, f); } str->close();