"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xpdf/SplashOutputDev.cc" between
xpdf-4.01.01.tar.gz and xpdf-4.02.tar.gz

About: Xpdf is a PDF viewer for X.

SplashOutputDev.cc  (xpdf-4.01.01):SplashOutputDev.cc  (xpdf-4.02)
skipping to change at line 31 skipping to change at line 31
#include "Error.h" #include "Error.h"
#include "Object.h" #include "Object.h"
#include "Gfx.h" #include "Gfx.h"
#include "GfxFont.h" #include "GfxFont.h"
#include "Link.h" #include "Link.h"
#include "CharCodeToUnicode.h" #include "CharCodeToUnicode.h"
#include "FontEncodingTables.h" #include "FontEncodingTables.h"
#include "BuiltinFont.h" #include "BuiltinFont.h"
#include "BuiltinFontTables.h" #include "BuiltinFontTables.h"
#include "FoFiTrueType.h" #include "FoFiTrueType.h"
#include "FoFiType1C.h"
#include "JPXStream.h" #include "JPXStream.h"
#include "SplashBitmap.h" #include "SplashBitmap.h"
#include "SplashGlyphBitmap.h" #include "SplashGlyphBitmap.h"
#include "SplashPattern.h" #include "SplashPattern.h"
#include "SplashScreen.h" #include "SplashScreen.h"
#include "SplashPath.h" #include "SplashPath.h"
#include "SplashState.h" #include "SplashState.h"
#include "SplashErrorCodes.h" #include "SplashErrorCodes.h"
#include "SplashFontEngine.h" #include "SplashFontEngine.h"
#include "SplashFont.h" #include "SplashFont.h"
skipping to change at line 499 skipping to change at line 500
Ref fontID; // PDF font ID Ref fontID; // PDF font ID
double m11, m12, m21, m22; // transform matrix double m11, m12, m21, m22; // transform matrix
int glyphX, glyphY; // pixel offset of glyph bitmaps int glyphX, glyphY; // pixel offset of glyph bitmaps
int glyphW, glyphH; // size of glyph bitmaps, in pixels int glyphW, glyphH; // size of glyph bitmaps, in pixels
GBool validBBox; // false if the bbox was [0 0 0 0] GBool validBBox; // false if the bbox was [0 0 0 0]
int glyphSize; // size of glyph bitmaps, in bytes int glyphSize; // size of glyph bitmaps, in bytes
int cacheSets; // number of sets in cache int cacheSets; // number of sets in cache
int cacheAssoc; // cache associativity (glyphs per set) int cacheAssoc; // cache associativity (glyphs per set)
Guchar *cacheData; // glyph pixmap cache Guchar *cacheData; // glyph pixmap cache
T3FontCacheTag *cacheTags; // cache tags, i.e., char codes T3FontCacheTag *cacheTags; // cache tags, i.e., char codes
GBool inUse; // set while this T3 font is in active use
}; };
T3FontCache::T3FontCache(Ref *fontIDA, double m11A, double m12A, T3FontCache::T3FontCache(Ref *fontIDA, double m11A, double m12A,
double m21A, double m22A, double m21A, double m22A,
int glyphXA, int glyphYA, int glyphWA, int glyphHA, int glyphXA, int glyphYA, int glyphWA, int glyphHA,
GBool validBBoxA, GBool aa) { GBool validBBoxA, GBool aa) {
int i; int i;
fontID = *fontIDA; fontID = *fontIDA;
m11 = m11A; m11 = m11A;
skipping to change at line 540 skipping to change at line 542
for (cacheSets = type3FontCacheMaxSets; for (cacheSets = type3FontCacheMaxSets;
cacheSets > 1 && cacheSets > 1 &&
cacheSets * cacheAssoc * glyphSize > type3FontCacheSize; cacheSets * cacheAssoc * glyphSize > type3FontCacheSize;
cacheSets >>= 1) ; cacheSets >>= 1) ;
cacheData = (Guchar *)gmallocn(cacheSets * cacheAssoc, glyphSize); cacheData = (Guchar *)gmallocn(cacheSets * cacheAssoc, glyphSize);
cacheTags = (T3FontCacheTag *)gmallocn(cacheSets * cacheAssoc, cacheTags = (T3FontCacheTag *)gmallocn(cacheSets * cacheAssoc,
sizeof(T3FontCacheTag)); sizeof(T3FontCacheTag));
for (i = 0; i < cacheSets * cacheAssoc; ++i) { for (i = 0; i < cacheSets * cacheAssoc; ++i) {
cacheTags[i].mru = (Gushort)(i & (cacheAssoc - 1)); cacheTags[i].mru = (Gushort)(i & (cacheAssoc - 1));
} }
inUse = gFalse;
} }
T3FontCache::~T3FontCache() { T3FontCache::~T3FontCache() {
gfree(cacheData); gfree(cacheData);
gfree(cacheTags); gfree(cacheTags);
} }
struct T3GlyphStack { struct T3GlyphStack {
Gushort code; // character code Gushort code; // character code
skipping to change at line 616 skipping to change at line 619
colorMode != splashModeMono1; colorMode != splashModeMono1;
setupScreenParams(72.0, 72.0); setupScreenParams(72.0, 72.0);
reverseVideo = reverseVideoA; reverseVideo = reverseVideoA;
splashColorCopy(paperColor, paperColorA); splashColorCopy(paperColor, paperColorA);
skipHorizText = gFalse; skipHorizText = gFalse;
skipRotatedText = gFalse; skipRotatedText = gFalse;
xref = NULL; xref = NULL;
bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode, bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode,
colorMode != splashModeMono1, bitmapTopDown); colorMode != splashModeMono1, bitmapTopDown, NULL);
splash = new Splash(bitmap, vectorAntialias, &screenParams); splash = new Splash(bitmap, vectorAntialias, NULL, &screenParams);
splash->setMinLineWidth(globalParams->getMinLineWidth()); splash->setMinLineWidth(globalParams->getMinLineWidth());
splash->setStrokeAdjust( splash->setStrokeAdjust(
mapStrokeAdjustMode[globalParams->getStrokeAdjust()]); mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
splash->setEnablePathSimplification( splash->setEnablePathSimplification(
globalParams->getEnablePathSimplification()); globalParams->getEnablePathSimplification());
splash->clear(paperColor, 0); splash->clear(paperColor, 0);
fontEngine = NULL; fontEngine = NULL;
nT3Fonts = 0; nT3Fonts = 0;
skipping to change at line 761 skipping to change at line 764
if (splash) { if (splash) {
delete splash; delete splash;
splash = NULL; splash = NULL;
} }
if (!bitmap || w != bitmap->getWidth() || h != bitmap->getHeight()) { if (!bitmap || w != bitmap->getWidth() || h != bitmap->getHeight()) {
if (bitmap) { if (bitmap) {
delete bitmap; delete bitmap;
bitmap = NULL; bitmap = NULL;
} }
bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode,
colorMode != splashModeMono1, bitmapTopDown); colorMode != splashModeMono1, bitmapTopDown,
NULL);
} }
splash = new Splash(bitmap, vectorAntialias, &screenParams); splash = new Splash(bitmap, vectorAntialias, NULL, &screenParams);
splash->setMinLineWidth(globalParams->getMinLineWidth()); splash->setMinLineWidth(globalParams->getMinLineWidth());
splash->setEnablePathSimplification( splash->setEnablePathSimplification(
globalParams->getEnablePathSimplification()); globalParams->getEnablePathSimplification());
if (state) { if (state) {
ctm = state->getCTM(); ctm = state->getCTM();
mat[0] = (SplashCoord)ctm[0]; mat[0] = (SplashCoord)ctm[0];
mat[1] = (SplashCoord)ctm[1]; mat[1] = (SplashCoord)ctm[1];
mat[2] = (SplashCoord)ctm[2]; mat[2] = (SplashCoord)ctm[2];
mat[3] = (SplashCoord)ctm[3]; mat[3] = (SplashCoord)ctm[3];
mat[4] = (SplashCoord)ctm[4]; mat[4] = (SplashCoord)ctm[4];
skipping to change at line 804 skipping to change at line 808
splash->setLineCap(splashLineCapButt); splash->setLineCap(splashLineCapButt);
splash->setLineJoin(splashLineJoinMiter); splash->setLineJoin(splashLineJoinMiter);
splash->setLineDash(NULL, 0, 0); splash->setLineDash(NULL, 0, 0);
splash->setMiterLimit(10); splash->setMiterLimit(10);
splash->setFlatness(1); splash->setFlatness(1);
// the SA parameter supposedly defaults to false, but Acrobat // the SA parameter supposedly defaults to false, but Acrobat
// apparently hardwires it to true // apparently hardwires it to true
splash->setStrokeAdjust( splash->setStrokeAdjust(
mapStrokeAdjustMode[globalParams->getStrokeAdjust()]); mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
splash->clear(paperColor, 0); splash->clear(paperColor, 0);
reverseVideoInvertImages = globalParams->getReverseVideoInvertImages();
if (startPageCbk) { if (startPageCbk) {
(*startPageCbk)(startPageCbkData); (*startPageCbk)(startPageCbkData);
} }
} }
void SplashOutputDev::endPage() { void SplashOutputDev::endPage() {
if (colorMode != splashModeMono1 && !noComposite) { if (colorMode != splashModeMono1 && !noComposite) {
splash->compositeBackground(paperColor); splash->compositeBackground(paperColor);
} }
} }
skipping to change at line 1144 skipping to change at line 1149
} }
void SplashOutputDev::doUpdateFont(GfxState *state) { void SplashOutputDev::doUpdateFont(GfxState *state) {
GfxFont *gfxFont; GfxFont *gfxFont;
GfxFontLoc *fontLoc; GfxFontLoc *fontLoc;
GfxFontType fontType; GfxFontType fontType;
SplashOutFontFileID *id; SplashOutFontFileID *id;
SplashFontFile *fontFile; SplashFontFile *fontFile;
int fontNum; int fontNum;
FoFiTrueType *ff; FoFiTrueType *ff;
FoFiType1C *ffT1C;
Ref embRef; Ref embRef;
Object refObj, strObj; Object refObj, strObj;
#if LOAD_FONTS_FROM_MEM #if LOAD_FONTS_FROM_MEM
GString *fontBuf; GString *fontBuf;
FILE *extFontFile; FILE *extFontFile;
#else #else
GString *tmpFileName, *fileName; GString *tmpFileName, *fileName;
FILE *tmpFile; FILE *tmpFile;
#endif #endif
char blk[4096]; char blk[4096];
int *codeToGID; int *codeToGID;
CharCodeToUnicode *ctu; CharCodeToUnicode *ctu;
double *textMat; double *textMat;
double m11, m12, m21, m22, fontSize, oblique; double m11, m12, m21, m22, fontSize, oblique;
double fsx, fsy, w, fontScaleMin, fontScaleAvg, fontScale; double fsx, fsy, w, fontScaleMin, fontScaleAvg, fontScale;
Gushort ww; Gushort ww;
SplashCoord mat[4]; SplashCoord mat[4];
char *name; char *name, *start;
Unicode uBuf[8]; Unicode uBuf[8];
int substIdx, n, code, cmap, cmapPlatform, cmapEncoding, i; int substIdx, n, code, cmap, cmapPlatform, cmapEncoding, length, i;
needFontUpdate = gFalse; needFontUpdate = gFalse;
font = NULL; font = NULL;
#if LOAD_FONTS_FROM_MEM #if LOAD_FONTS_FROM_MEM
fontBuf = NULL; fontBuf = NULL;
#else #else
tmpFileName = NULL; tmpFileName = NULL;
fileName = NULL; fileName = NULL;
#endif #endif
substIdx = -1; substIdx = -1;
skipping to change at line 1301 skipping to change at line 1307
#endif #endif
(const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
delete fontLoc; delete fontLoc;
goto err2; goto err2;
} }
break; break;
case fontType1C: case fontType1C:
#if LOAD_FONTS_FROM_MEM
if ((ffT1C = FoFiType1C::make(fontBuf->getCString(),
fontBuf->getLength()))) {
#else
if ((ffT1C = FoFiType1C::load(fileName->getCString()))) {
#endif
codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ffT1C);
delete ffT1C;
} else {
codeToGID = NULL;
}
if (!(fontFile = fontEngine->loadType1CFont( if (!(fontFile = fontEngine->loadType1CFont(
id, id,
#if LOAD_FONTS_FROM_MEM #if LOAD_FONTS_FROM_MEM
fontBuf, fontBuf,
#else #else
fileName->getCString(), fileName->getCString(),
fileName == tmpFileName, fileName == tmpFileName,
#endif #endif
codeToGID,
(const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
delete fontLoc; delete fontLoc;
goto err2; goto err2;
} }
break; break;
case fontType1COT: case fontType1COT:
codeToGID = NULL;
#if LOAD_FONTS_FROM_MEM
if ((ff = FoFiTrueType::make(fontBuf->getCString(), fontBuf->getLength(),
fontNum, gTrue))) {
#else
if ((ff = FoFiTrueType::load(fileName->getCString(),
fontNum, gTrue))) {
#endif
if (ff->getCFFBlock(&start, &length) &&
(ffT1C = FoFiType1C::make(start, length))) {
codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ffT1C);
delete ffT1C;
}
delete ff;
}
if (!(fontFile = fontEngine->loadOpenTypeT1CFont( if (!(fontFile = fontEngine->loadOpenTypeT1CFont(
id, id,
#if LOAD_FONTS_FROM_MEM #if LOAD_FONTS_FROM_MEM
fontBuf, fontBuf,
#else #else
fileName->getCString(), fileName->getCString(),
fileName == tmpFileName, fileName == tmpFileName,
#endif #endif
codeToGID,
(const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
delete fontLoc; delete fontLoc;
goto err2; goto err2;
} }
break; break;
case fontTrueType: case fontTrueType:
case fontTrueTypeOT: case fontTrueTypeOT:
skipping to change at line 1554 skipping to change at line 1588
: (char *)NULL))) { : (char *)NULL))) {
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
delete fontLoc; delete fontLoc;
goto err2; goto err2;
} }
break; break;
default: default:
// this shouldn't happen // this shouldn't happen
delete fontLoc;
goto err2; goto err2;
} }
delete fontLoc; delete fontLoc;
} }
// get the font matrix // get the font matrix
textMat = state->getTextMat(); textMat = state->getTextMat();
fontSize = state->getFontSize(); fontSize = state->getFontSize();
oblique = ((SplashOutFontFileID *)fontFile->getID())->getOblique(); oblique = ((SplashOutFontFileID *)fontFile->getID())->getOblique();
skipping to change at line 1588 skipping to change at line 1623
fontScaleMin = 1; fontScaleMin = 1;
fontScaleAvg = 0; fontScaleAvg = 0;
n = 0; n = 0;
for (code = 0; code < 256; ++code) { for (code = 0; code < 256; ++code) {
if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) && if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) &&
name[0] && !name[1] && name[0] && !name[1] &&
((name[0] >= 'A' && name[0] <= 'Z') || ((name[0] >= 'A' && name[0] <= 'Z') ||
(name[0] >= 'a' && name[0] <= 'z') || (name[0] >= 'a' && name[0] <= 'z') ||
(name[0] >= '0' && name[0] <= '9'))) { (name[0] >= '0' && name[0] <= '9'))) {
w = ((Gfx8BitFont *)gfxFont)->getWidth((Guchar)code); w = ((Gfx8BitFont *)gfxFont)->getWidth((Guchar)code);
builtinFontSubst[substIdx]->widths->getWidth(name, &ww); if (builtinFontSubst[substIdx]->widths->getWidth(name, &ww) &&
if (w > 0.01 && ww > 10) { w > 0.01 && ww > 10) {
w /= ww * 0.001; w /= ww * 0.001;
if (w < fontScaleMin) { if (w < fontScaleMin) {
fontScaleMin = w; fontScaleMin = w;
} }
fontScaleAvg += w; fontScaleAvg += w;
++n; ++n;
} }
} }
} }
// if real font is narrower than substituted font, reduce the font // if real font is narrower than substituted font, reduce the font
skipping to change at line 1775 skipping to change at line 1810
tileH = (int)(tileYMax - tileYMin + 0.5); tileH = (int)(tileYMax - tileYMin + 0.5);
if (tileW < 1) { if (tileW < 1) {
tileW = 1; tileW = 1;
} }
if (tileH < 1) { if (tileH < 1) {
tileH = 1; tileH = 1;
} }
// check for an excessively large tile size // check for an excessively large tile size
tileSize = tileW * tileH; tileSize = tileW * tileH;
if (tileSize > 1000000 || tileSize < 0) { if (tileXMax - tileXMin + 0.5 > (double)INT_MAX ||
tileYMax - tileYMin + 0.5 > (double)INT_MAX ||
tileW > INT_MAX / tileH ||
tileSize > 1000000) {
mat1[0] = mat[0]; mat1[0] = mat[0];
mat1[1] = mat[1]; mat1[1] = mat[1];
mat1[2] = mat[2]; mat1[2] = mat[2];
mat1[3] = mat[3]; mat1[3] = mat[3];
for (iy = y0; iy < y1; ++iy) { for (iy = y0; iy < y1; ++iy) {
for (ix = x0; ix < x1; ++ix) { for (ix = x0; ix < x1; ++ix) {
tx = ix * xStep; tx = ix * xStep;
ty = iy * yStep; ty = iy * yStep;
mat1[4] = tx * mat[0] + ty * mat[2] + mat[4]; mat1[4] = tx * mat[0] + ty * mat[2] + mat[4];
mat1[5] = tx * mat[1] + ty * mat[3] + mat[5]; mat1[5] = tx * mat[1] + ty * mat[3] + mat[5];
skipping to change at line 1927 skipping to change at line 1965
} }
ixMin = (int)floor(txMin); ixMin = (int)floor(txMin);
ixMax = (int)ceil(txMax); ixMax = (int)ceil(txMax);
iyMin = (int)floor(tyMin); iyMin = (int)floor(tyMin);
iyMax = (int)ceil(tyMax); iyMax = (int)ceil(tyMax);
// create a temporary bitmap // create a temporary bitmap
origBitmap = bitmap; origBitmap = bitmap;
origSplash = splash; origSplash = splash;
bitmap = tileBitmap = new SplashBitmap(tileW, tileH, bitmapRowPad, bitmap = tileBitmap = new SplashBitmap(tileW, tileH, bitmapRowPad,
colorMode, gTrue, bitmapTopDown); colorMode, gTrue, bitmapTopDown,
splash = new Splash(bitmap, vectorAntialias, origSplash->getScreen()); origBitmap);
splash = new Splash(bitmap, vectorAntialias,
origSplash->getImageCache(), origSplash->getScreen());
for (i = 0; i < splashMaxColorComps; ++i) { for (i = 0; i < splashMaxColorComps; ++i) {
color[i] = 0; color[i] = 0;
} }
splash->clear(color); splash->clear(color);
splash->setMinLineWidth(globalParams->getMinLineWidth()); splash->setMinLineWidth(globalParams->getMinLineWidth());
splash->setStrokeAdjust( splash->setStrokeAdjust(
mapStrokeAdjustMode[globalParams->getStrokeAdjust()]); mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
splash->setEnablePathSimplification( splash->setEnablePathSimplification(
globalParams->getEnablePathSimplification()); globalParams->getEnablePathSimplification());
++nestCount; ++nestCount;
skipping to change at line 2079 skipping to change at line 2119
if (colorMode == splashModeMono1) { if (colorMode == splashModeMono1) {
srcMode = splashModeMono8; srcMode = splashModeMono8;
} else if (colorMode == splashModeBGR8) { } else if (colorMode == splashModeBGR8) {
srcMode = splashModeRGB8; srcMode = splashModeRGB8;
} else { } else {
srcMode = colorMode; srcMode = colorMode;
} }
bitmapWidth = ixMax - ixMin; bitmapWidth = ixMax - ixMin;
bitmapHeight = iyMax - iyMin; bitmapHeight = iyMax - iyMin;
tBitmap = new SplashBitmap(bitmapWidth, bitmapHeight, 1, tBitmap = new SplashBitmap(bitmapWidth, bitmapHeight, 1,
srcMode, gTrue, gTrue); srcMode, gTrue, gTrue, bitmap);
memset(tBitmap->getAlphaPtr(), 0, (size_t)bitmapWidth * bitmapHeight); memset(tBitmap->getAlphaPtr(), 0, (size_t)bitmapWidth * bitmapHeight);
nComps = splashColorModeNComps[srcMode]; nComps = splashColorModeNComps[srcMode];
// compute the inverse CTM // compute the inverse CTM
det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]); det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]);
ictm[0] = ctm[3] * det; ictm[0] = ctm[3] * det;
ictm[1] = -ctm[1] * det; ictm[1] = -ctm[1] * det;
ictm[2] = -ctm[2] * det; ictm[2] = -ctm[2] * det;
ictm[3] = ctm[0] * det; ictm[3] = ctm[0] * det;
ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det; ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det;
skipping to change at line 2396 skipping to change at line 2436
if (colorMode == splashModeMono1) { if (colorMode == splashModeMono1) {
srcMode = splashModeMono8; srcMode = splashModeMono8;
} else if (colorMode == splashModeBGR8) { } else if (colorMode == splashModeBGR8) {
srcMode = splashModeRGB8; srcMode = splashModeRGB8;
} else { } else {
srcMode = colorMode; srcMode = colorMode;
} }
bitmapWidth = ixMax - ixMin; bitmapWidth = ixMax - ixMin;
bitmapHeight = iyMax - iyMin; bitmapHeight = iyMax - iyMin;
tBitmap = new SplashBitmap(bitmapWidth, bitmapHeight, 1, tBitmap = new SplashBitmap(bitmapWidth, bitmapHeight, 1,
srcMode, gTrue, gTrue); srcMode, gTrue, gTrue, bitmap);
memset(tBitmap->getAlphaPtr(), 0, tBitmap->getAlphaRowSize() * bitmapHeight); memset(tBitmap->getAlphaPtr(), 0, tBitmap->getAlphaRowSize() * bitmapHeight);
nComps = splashColorModeNComps[srcMode]; nComps = splashColorModeNComps[srcMode];
// compute the inverse CTM // compute the inverse CTM
det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]); det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]);
ictm[0] = ctm[3] * det; ictm[0] = ctm[3] * det;
ictm[1] = -ctm[1] * det; ictm[1] = -ctm[1] * det;
ictm[2] = -ctm[2] * det; ictm[2] = -ctm[2] * det;
ictm[3] = ctm[0] * det; ictm[3] = ctm[0] * det;
ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det; ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det;
skipping to change at line 2900 skipping to change at line 2940
for (j = i; j > 0; --j) { for (j = i; j > 0; --j) {
t3FontCache[j] = t3FontCache[j - 1]; t3FontCache[j] = t3FontCache[j - 1];
} }
t3FontCache[0] = t3Font; t3FontCache[0] = t3Font;
break; break;
} }
} }
if (i >= nT3Fonts) { if (i >= nT3Fonts) {
// create new entry in the font cache // create new entry in the font cache
if (nT3Fonts == splashOutT3FontCacheSize) { if (nT3Fonts < splashOutT3FontCacheSize) {
delete t3FontCache[nT3Fonts - 1]; for (j = nT3Fonts; j > 0; --j) {
t3FontCache[j] = t3FontCache[j - 1];
}
} else {
for (j = nT3Fonts - 1; j >= 0; --j) {
if (!t3FontCache[j]->inUse) {
break;
}
}
if (j < 0) {
error(errSyntaxError, -1, "Type 3 fonts nested too deeply");
return gTrue;
}
delete t3FontCache[j];
--nT3Fonts; --nT3Fonts;
} for (; j > 0; --j) {
for (j = nT3Fonts; j > 0; --j) { t3FontCache[j] = t3FontCache[j - 1];
t3FontCache[j] = t3FontCache[j - 1]; }
} }
++nT3Fonts; ++nT3Fonts;
bbox = gfxFont->getFontBBox(); bbox = gfxFont->getFontBBox();
if (bbox[0] == 0 && bbox[1] == 0 && bbox[2] == 0 && bbox[3] == 0) { if (bbox[0] == 0 && bbox[1] == 0 && bbox[2] == 0 && bbox[3] == 0) {
// unspecified bounding box -- just take a guess // unspecified bounding box -- just take a guess
xMin = xt - 5; xMin = xt - 5;
xMax = xMin + 30; xMax = xMin + 30;
yMax = yt + 15; yMax = yt + 15;
yMin = yMax - 45; yMin = yMax - 45;
validBBox = gFalse; validBBox = gFalse;
skipping to change at line 2977 skipping to change at line 3030
i = (code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc; i = (code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc;
for (j = 0; j < t3Font->cacheAssoc; ++j) { for (j = 0; j < t3Font->cacheAssoc; ++j) {
if ((t3Font->cacheTags[i+j].mru & 0x8000) && if ((t3Font->cacheTags[i+j].mru & 0x8000) &&
t3Font->cacheTags[i+j].code == code) { t3Font->cacheTags[i+j].code == code) {
drawType3Glyph(state, t3Font, &t3Font->cacheTags[i+j], drawType3Glyph(state, t3Font, &t3Font->cacheTags[i+j],
t3Font->cacheData + (i+j) * t3Font->glyphSize); t3Font->cacheData + (i+j) * t3Font->glyphSize);
return gTrue; return gTrue;
} }
} }
t3Font->inUse = gTrue;
// push a new Type 3 glyph record // push a new Type 3 glyph record
t3gs = new T3GlyphStack(); t3gs = new T3GlyphStack();
t3gs->next = t3GlyphStack; t3gs->next = t3GlyphStack;
t3GlyphStack = t3gs; t3GlyphStack = t3gs;
t3GlyphStack->code = (Gushort)code; t3GlyphStack->code = (Gushort)code;
t3GlyphStack->cache = t3Font; t3GlyphStack->cache = t3Font;
t3GlyphStack->cacheTag = NULL; t3GlyphStack->cacheTag = NULL;
t3GlyphStack->cacheData = NULL; t3GlyphStack->cacheData = NULL;
t3GlyphStack->haveDx = gFalse; t3GlyphStack->haveDx = gFalse;
t3GlyphStack->doNotCache = gFalse; t3GlyphStack->doNotCache = gFalse;
skipping to change at line 3013 skipping to change at line 3068
splash = t3GlyphStack->origSplash; splash = t3GlyphStack->origSplash;
ctm = state->getCTM(); ctm = state->getCTM();
state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3], state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3],
t3GlyphStack->origCTM4, t3GlyphStack->origCTM5); t3GlyphStack->origCTM4, t3GlyphStack->origCTM5);
updateCTM(state, 0, 0, 0, 0, 0, 0); updateCTM(state, 0, 0, 0, 0, 0, 0);
drawType3Glyph(state, t3GlyphStack->cache, drawType3Glyph(state, t3GlyphStack->cache,
t3GlyphStack->cacheTag, t3GlyphStack->cacheData); t3GlyphStack->cacheTag, t3GlyphStack->cacheData);
} }
t3gs = t3GlyphStack; t3gs = t3GlyphStack;
t3GlyphStack = t3gs->next; t3GlyphStack = t3gs->next;
t3gs->cache->inUse = gFalse;
delete t3gs; delete t3gs;
} }
void SplashOutputDev::type3D0(GfxState *state, double wx, double wy) { void SplashOutputDev::type3D0(GfxState *state, double wx, double wy) {
if (!t3GlyphStack) { if (!t3GlyphStack) {
error(errSyntaxError, -1, error(errSyntaxError, -1,
"Encountered d0 operator outside of Type 3 CharProc"); "Encountered d0 operator outside of Type 3 CharProc");
return; return;
} }
t3GlyphStack->haveDx = gTrue; t3GlyphStack->haveDx = gTrue;
skipping to change at line 3123 skipping to change at line 3179
t3GlyphStack->origBitmap = bitmap; t3GlyphStack->origBitmap = bitmap;
t3GlyphStack->origSplash = splash; t3GlyphStack->origSplash = splash;
ctm = state->getCTM(); ctm = state->getCTM();
t3GlyphStack->origCTM4 = ctm[4]; t3GlyphStack->origCTM4 = ctm[4];
t3GlyphStack->origCTM5 = ctm[5]; t3GlyphStack->origCTM5 = ctm[5];
// create the temporary bitmap // create the temporary bitmap
if (colorMode == splashModeMono1) { if (colorMode == splashModeMono1) {
colorMode = splashModeMono1; colorMode = splashModeMono1;
bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1, bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,
splashModeMono1, gFalse); splashModeMono1, gFalse, gTrue, bitmap);
splash = new Splash(bitmap, gFalse, t3GlyphStack->origSplash->getScreen()); splash = new Splash(bitmap, gFalse,
t3GlyphStack->origSplash->getImageCache(),
t3GlyphStack->origSplash->getScreen());
color[0] = 0; color[0] = 0;
splash->clear(color); splash->clear(color);
color[0] = 0xff; color[0] = 0xff;
} else { } else {
colorMode = splashModeMono8; colorMode = splashModeMono8;
bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1, bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,
splashModeMono8, gFalse); splashModeMono8, gFalse, gTrue, bitmap);
splash = new Splash(bitmap, vectorAntialias, splash = new Splash(bitmap, vectorAntialias,
t3GlyphStack->origSplash->getImageCache(),
t3GlyphStack->origSplash->getScreen()); t3GlyphStack->origSplash->getScreen());
color[0] = 0x00; color[0] = 0x00;
splash->clear(color); splash->clear(color);
color[0] = 0xff; color[0] = 0xff;
} }
splash->setMinLineWidth(globalParams->getMinLineWidth()); splash->setMinLineWidth(globalParams->getMinLineWidth());
splash->setStrokeAdjust(t3GlyphStack->origSplash->getStrokeAdjust()); splash->setStrokeAdjust(t3GlyphStack->origSplash->getStrokeAdjust());
splash->setEnablePathSimplification( splash->setEnablePathSimplification(
globalParams->getEnablePathSimplification()); globalParams->getEnablePathSimplification());
copyState(t3GlyphStack->origSplash, gFalse); copyState(t3GlyphStack->origSplash, gFalse);
skipping to change at line 3206 skipping to change at line 3265
++imgMaskData->y; ++imgMaskData->y;
return gTrue; return gTrue;
} }
void SplashOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, void SplashOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
int width, int height, GBool invert, int width, int height, GBool invert,
GBool inlineImg, GBool interpolate) { GBool inlineImg, GBool interpolate) {
double *ctm; double *ctm;
SplashCoord mat[6]; SplashCoord mat[6];
SplashOutImageMaskData imgMaskData; SplashOutImageMaskData imgMaskData;
GString *imgTag;
if (state->getFillColorSpace()->isNonMarking()) { if (state->getFillColorSpace()->isNonMarking()) {
return; return;
} }
setOverprintMask(state, state->getFillColorSpace(), setOverprintMask(state, state->getFillColorSpace(),
state->getFillOverprint(), state->getOverprintMode(), state->getFillOverprint(), state->getOverprintMode(),
state->getFillColor()); state->getFillColor());
ctm = state->getCTM(); ctm = state->getCTM();
mat[0] = ctm[0]; mat[0] = ctm[0];
skipping to change at line 3231 skipping to change at line 3291
reduceImageResolution(str, ctm, &width, &height); reduceImageResolution(str, ctm, &width, &height);
imgMaskData.imgStr = new ImageStream(str, width, 1, 1); imgMaskData.imgStr = new ImageStream(str, width, 1, 1);
imgMaskData.imgStr->reset(); imgMaskData.imgStr->reset();
imgMaskData.invert = invert ? 0 : 1; imgMaskData.invert = invert ? 0 : 1;
imgMaskData.width = width; imgMaskData.width = width;
imgMaskData.height = height; imgMaskData.height = height;
imgMaskData.y = 0; imgMaskData.y = 0;
splash->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat, imgTag = makeImageTag(ref);
splash->fillImageMask(imgTag,
&imageMaskSrc, &imgMaskData, width, height, mat,
t3GlyphStack != NULL, interpolate); t3GlyphStack != NULL, interpolate);
if (inlineImg) { if (inlineImg) {
while (imgMaskData.y < height) { while (imgMaskData.y < height) {
imgMaskData.imgStr->getLine(); imgMaskData.imgStr->getLine();
++imgMaskData.y; ++imgMaskData.y;
} }
} }
delete imgTag;
delete imgMaskData.imgStr; delete imgMaskData.imgStr;
str->close(); str->close();
} }
void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state, void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state,
Object *ref, Stream *str, Object *ref, Stream *str,
int width, int height, int width, int height,
GBool invert, GBool invert,
GBool inlineImg, GBool inlineImg,
GBool interpolate) { GBool interpolate) {
double *ctm; double *ctm;
SplashCoord mat[6]; SplashCoord mat[6];
SplashOutImageMaskData imgMaskData; SplashOutImageMaskData imgMaskData;
SplashBitmap *maskBitmap; SplashBitmap *maskBitmap;
Splash *maskSplash; Splash *maskSplash;
SplashColor maskColor; SplashColor maskColor;
GString *imgTag;
ctm = state->getCTM(); ctm = state->getCTM();
mat[0] = ctm[0]; mat[0] = ctm[0];
mat[1] = ctm[1]; mat[1] = ctm[1];
mat[2] = -ctm[2]; mat[2] = -ctm[2];
mat[3] = -ctm[3]; mat[3] = -ctm[3];
mat[4] = ctm[2] + ctm[4]; mat[4] = ctm[2] + ctm[4];
mat[5] = ctm[3] + ctm[5]; mat[5] = ctm[3] + ctm[5];
reduceImageResolution(str, ctm, &width, &height); reduceImageResolution(str, ctm, &width, &height);
imgMaskData.imgStr = new ImageStream(str, width, 1, 1); imgMaskData.imgStr = new ImageStream(str, width, 1, 1);
imgMaskData.imgStr->reset(); imgMaskData.imgStr->reset();
imgMaskData.invert = invert ? 0 : 1; imgMaskData.invert = invert ? 0 : 1;
imgMaskData.width = width; imgMaskData.width = width;
imgMaskData.height = height; imgMaskData.height = height;
imgMaskData.y = 0; imgMaskData.y = 0;
maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
1, splashModeMono8, gFalse); 1, splashModeMono8, gFalse, gTrue, bitmap);
maskSplash = new Splash(maskBitmap, gTrue); maskSplash = new Splash(maskBitmap, gTrue, splash->getImageCache());
maskSplash->setStrokeAdjust( maskSplash->setStrokeAdjust(
mapStrokeAdjustMode[globalParams->getStrokeAdjust()]); mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
maskSplash->setEnablePathSimplification( maskSplash->setEnablePathSimplification(
globalParams->getEnablePathSimplification()); globalParams->getEnablePathSimplification());
clearMaskRegion(state, maskSplash, 0, 0, 1, 1); clearMaskRegion(state, maskSplash, 0, 0, 1, 1);
maskColor[0] = 0xff; maskColor[0] = 0xff;
maskSplash->setFillPattern(new SplashSolidColor(maskColor)); maskSplash->setFillPattern(new SplashSolidColor(maskColor));
maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData, imgTag = makeImageTag(ref);
maskSplash->fillImageMask(imgTag, &imageMaskSrc, &imgMaskData,
width, height, mat, gFalse, interpolate); width, height, mat, gFalse, interpolate);
delete imgTag;
delete imgMaskData.imgStr; delete imgMaskData.imgStr;
str->close(); str->close();
delete maskSplash; delete maskSplash;
splash->setSoftMask(maskBitmap); splash->setSoftMask(maskBitmap);
} }
struct SplashOutImageData { struct SplashOutImageData {
ImageStream *imgStr; ImageStream *imgStr;
GfxImageColorMap *colorMap; GfxImageColorMap *colorMap;
GfxRenderingIntent ri; GfxRenderingIntent ri;
SplashColorPtr lookup; SplashColorPtr lookup;
int *maskColors; int *maskColors;
SplashColorMode colorMode; SplashColorMode colorMode;
GBool invert;
int width, height, y; int width, height, y;
}; };
GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine, GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine,
Guchar *alphaLine) { Guchar *alphaLine) {
SplashOutImageData *imgData = (SplashOutImageData *)data; SplashOutImageData *imgData = (SplashOutImageData *)data;
Guchar *p; Guchar *p;
SplashColorPtr q, col; SplashColorPtr q, col;
int x; int n, x;
if (imgData->y == imgData->height || if (imgData->y == imgData->height ||
!(p = imgData->imgStr->getLine())) { !(p = imgData->imgStr->getLine())) {
memset(colorLine, 0, memset(colorLine, 0,
imgData->width * splashColorModeNComps[imgData->colorMode]); imgData->width * splashColorModeNComps[imgData->colorMode]);
return gFalse; return gFalse;
} }
if (imgData->lookup) { if (imgData->lookup) {
switch (imgData->colorMode) { switch (imgData->colorMode) {
skipping to change at line 3363 skipping to change at line 3431
break; break;
#if SPLASH_CMYK #if SPLASH_CMYK
case splashModeCMYK8: case splashModeCMYK8:
imgData->colorMap->getCMYKByteLine(p, colorLine, imgData->width, imgData->colorMap->getCMYKByteLine(p, colorLine, imgData->width,
imgData->ri); imgData->ri);
break; break;
#endif #endif
} }
} }
if (imgData->invert) {
n = imgData->width * splashColorModeNComps[imgData->colorMode];
for (x = 0, p = colorLine; x < n; ++x, ++p) {
*p ^= 0xff;
}
}
++imgData->y; ++imgData->y;
return gTrue; return gTrue;
} }
GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine, GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine,
Guchar *alphaLine) { Guchar *alphaLine) {
SplashOutImageData *imgData = (SplashOutImageData *)data; SplashOutImageData *imgData = (SplashOutImageData *)data;
Guchar *p0, *p, *aq; Guchar *p0, *p, *aq;
SplashColorPtr q, col; SplashColorPtr q, col;
Guchar alpha; Guchar alpha;
int nComps, x, i; int nComps, x, n, i;
if (imgData->y == imgData->height || if (imgData->y == imgData->height ||
!(p0 = imgData->imgStr->getLine())) { !(p0 = imgData->imgStr->getLine())) {
memset(colorLine, 0, memset(colorLine, 0,
imgData->width * splashColorModeNComps[imgData->colorMode]); imgData->width * splashColorModeNComps[imgData->colorMode]);
memset(alphaLine, 0, imgData->width); memset(alphaLine, 0, imgData->width);
return gFalse; return gFalse;
} }
nComps = imgData->colorMap->getNumPixelComps(); nComps = imgData->colorMap->getNumPixelComps();
skipping to change at line 3447 skipping to change at line 3522
for (i = 0; i < nComps; ++i) { for (i = 0; i < nComps; ++i) {
if (p[i] < imgData->maskColors[2*i] || if (p[i] < imgData->maskColors[2*i] ||
p[i] > imgData->maskColors[2*i+1]) { p[i] > imgData->maskColors[2*i+1]) {
alpha = 0xff; alpha = 0xff;
break; break;
} }
} }
*aq++ = alpha; *aq++ = alpha;
} }
if (imgData->invert) {
n = imgData->width * splashColorModeNComps[imgData->colorMode];
for (x = 0, p = colorLine; x < n; ++x, ++p) {
*p ^= 0xff;
}
}
++imgData->y; ++imgData->y;
return gTrue; return gTrue;
} }
void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
int width, int height, int width, int height,
GfxImageColorMap *colorMap, GfxImageColorMap *colorMap,
int *maskColors, GBool inlineImg, int *maskColors, GBool inlineImg,
GBool interpolate) { GBool interpolate) {
double *ctm; double *ctm;
SplashCoord mat[6]; SplashCoord mat[6];
SplashOutImageData imgData; SplashOutImageData imgData;
SplashColorMode srcMode; SplashColorMode srcMode;
SplashImageSource src; SplashImageSource src;
GString *imgTag;
GfxGray gray; GfxGray gray;
GfxRGB rgb; GfxRGB rgb;
#if SPLASH_CMYK #if SPLASH_CMYK
GfxCMYK cmyk; GfxCMYK cmyk;
#endif #endif
Guchar pix; Guchar pix;
int n, i; int n, i;
setOverprintMask(state, colorMap->getColorSpace(), setOverprintMask(state, colorMap->getColorSpace(),
state->getFillOverprint(), state->getOverprintMode(), state->getFillOverprint(), state->getOverprintMode(),
skipping to change at line 3491 skipping to change at line 3574
reduceImageResolution(str, ctm, &width, &height); reduceImageResolution(str, ctm, &width, &height);
imgData.imgStr = new ImageStream(str, width, imgData.imgStr = new ImageStream(str, width,
colorMap->getNumPixelComps(), colorMap->getNumPixelComps(),
colorMap->getBits()); colorMap->getBits());
imgData.imgStr->reset(); imgData.imgStr->reset();
imgData.colorMap = colorMap; imgData.colorMap = colorMap;
imgData.ri = state->getRenderingIntent(); imgData.ri = state->getRenderingIntent();
imgData.maskColors = maskColors; imgData.maskColors = maskColors;
imgData.colorMode = colorMode; imgData.colorMode = colorMode;
imgData.invert = reverseVideo && reverseVideoInvertImages;
imgData.width = width; imgData.width = width;
imgData.height = height; imgData.height = height;
imgData.y = 0; imgData.y = 0;
// special case for one-channel (monochrome/gray/separation) images: // special case for one-channel (monochrome/gray/separation) images:
// build a lookup table here // build a lookup table here
imgData.lookup = NULL; imgData.lookup = NULL;
if (colorMap->getNumPixelComps() == 1) { if (colorMap->getNumPixelComps() == 1) {
if (colorMap->getBits() <= 8) { if (colorMap->getBits() <= 8) {
n = 1 << colorMap->getBits(); n = 1 << colorMap->getBits();
skipping to change at line 3550 skipping to change at line 3634
} }
if (colorMode == splashModeMono1) { if (colorMode == splashModeMono1) {
srcMode = splashModeMono8; srcMode = splashModeMono8;
} else if (colorMode == splashModeBGR8) { } else if (colorMode == splashModeBGR8) {
srcMode = splashModeRGB8; srcMode = splashModeRGB8;
} else { } else {
srcMode = colorMode; srcMode = colorMode;
} }
src = maskColors ? &alphaImageSrc : &imageSrc; src = maskColors ? &alphaImageSrc : &imageSrc;
splash->drawImage(src, &imgData, srcMode, maskColors ? gTrue : gFalse, imgTag = makeImageTag(ref);
splash->drawImage(imgTag,
src, &imgData, srcMode, maskColors ? gTrue : gFalse,
width, height, mat, interpolate); width, height, mat, interpolate);
if (inlineImg) { if (inlineImg) {
while (imgData.y < height) { while (imgData.y < height) {
imgData.imgStr->getLine(); imgData.imgStr->getLine();
++imgData.y; ++imgData.y;
} }
} }
delete imgTag;
gfree(imgData.lookup); gfree(imgData.lookup);
delete imgData.imgStr; delete imgData.imgStr;
str->close(); str->close();
} }
struct SplashOutMaskedImageData { struct SplashOutMaskedImageData {
ImageStream *imgStr; ImageStream *imgStr;
GfxImageColorMap *colorMap; GfxImageColorMap *colorMap;
GfxRenderingIntent ri; GfxRenderingIntent ri;
SplashBitmap *mask; SplashBitmap *mask;
SplashColorPtr lookup; SplashColorPtr lookup;
SplashColorMode colorMode; SplashColorMode colorMode;
GBool invert;
int width, height, y; int width, height, y;
}; };
GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine, GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine,
Guchar *alphaLine) { Guchar *alphaLine) {
SplashOutMaskedImageData *imgData = (SplashOutMaskedImageData *)data; SplashOutMaskedImageData *imgData = (SplashOutMaskedImageData *)data;
Guchar *p, *aq; Guchar *p, *aq;
SplashColorPtr q, col; SplashColorPtr q, col;
static Guchar bitToByte[2] = {0x00, 0xff}; static Guchar bitToByte[2] = {0x00, 0xff};
Guchar *maskPtr; Guchar *maskPtr;
int maskShift; int maskShift;
int x; int n, x;
if (imgData->y == imgData->height || if (imgData->y == imgData->height ||
!(p = imgData->imgStr->getLine())) { !(p = imgData->imgStr->getLine())) {
memset(colorLine, 0, memset(colorLine, 0,
imgData->width * splashColorModeNComps[imgData->colorMode]); imgData->width * splashColorModeNComps[imgData->colorMode]);
memset(alphaLine, 0, imgData->width); memset(alphaLine, 0, imgData->width);
return gFalse; return gFalse;
} }
maskPtr = imgData->mask->getDataPtr() + maskPtr = imgData->mask->getDataPtr() +
skipping to change at line 3663 skipping to change at line 3751
break; break;
#if SPLASH_CMYK #if SPLASH_CMYK
case splashModeCMYK8: case splashModeCMYK8:
imgData->colorMap->getCMYKByteLine(p, colorLine, imgData->width, imgData->colorMap->getCMYKByteLine(p, colorLine, imgData->width,
imgData->ri); imgData->ri);
break; break;
#endif #endif
} }
} }
if (imgData->invert) {
n = imgData->width * splashColorModeNComps[imgData->colorMode];
for (x = 0, p = colorLine; x < n; ++x, ++p) {
*p ^= 0xff;
}
}
++imgData->y; ++imgData->y;
return gTrue; return gTrue;
} }
void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref,
Stream *str, int width, int height, Stream *str, int width, int height,
GfxImageColorMap *colorMap, GfxImageColorMap *colorMap,
Stream *maskStr, int maskWidth, Stream *maskStr, int maskWidth,
int maskHeight, GBool maskInvert, int maskHeight, GBool maskInvert,
GBool interpolate) { GBool interpolate) {
GfxImageColorMap *maskColorMap; GfxImageColorMap *maskColorMap;
Object maskDecode, decodeLow, decodeHigh; Object maskDecode, decodeLow, decodeHigh;
double *ctm; double *ctm;
SplashCoord mat[6]; SplashCoord mat[6];
SplashOutMaskedImageData imgData; SplashOutMaskedImageData imgData;
SplashOutImageMaskData imgMaskData; SplashOutImageMaskData imgMaskData;
SplashColorMode srcMode; SplashColorMode srcMode;
SplashBitmap *maskBitmap; SplashBitmap *maskBitmap;
Splash *maskSplash; Splash *maskSplash;
GString *imgTag;
SplashColor maskColor; SplashColor maskColor;
GfxGray gray; GfxGray gray;
GfxRGB rgb; GfxRGB rgb;
#if SPLASH_CMYK #if SPLASH_CMYK
GfxCMYK cmyk; GfxCMYK cmyk;
#endif #endif
Guchar pix; Guchar pix;
int n, i; int n, i;
setOverprintMask(state, colorMap->getColorSpace(), setOverprintMask(state, colorMap->getColorSpace(),
skipping to change at line 3731 skipping to change at line 3827
mat[2] = 0; mat[2] = 0;
mat[3] = (SplashCoord)height; mat[3] = (SplashCoord)height;
mat[4] = 0; mat[4] = 0;
mat[5] = 0; mat[5] = 0;
imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, 1, 1); imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, 1, 1);
imgMaskData.imgStr->reset(); imgMaskData.imgStr->reset();
imgMaskData.invert = maskInvert ? 0 : 1; imgMaskData.invert = maskInvert ? 0 : 1;
imgMaskData.width = maskWidth; imgMaskData.width = maskWidth;
imgMaskData.height = maskHeight; imgMaskData.height = maskHeight;
imgMaskData.y = 0; imgMaskData.y = 0;
maskBitmap = new SplashBitmap(width, height, 1, splashModeMono1, gFalse); maskBitmap = new SplashBitmap(width, height, 1, splashModeMono1,
maskSplash = new Splash(maskBitmap, gFalse); gFalse, gTrue, bitmap);
maskSplash = new Splash(maskBitmap, gFalse, splash->getImageCache());
maskSplash->setStrokeAdjust( maskSplash->setStrokeAdjust(
mapStrokeAdjustMode[globalParams->getStrokeAdjust()]); mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
maskSplash->setEnablePathSimplification( maskSplash->setEnablePathSimplification(
globalParams->getEnablePathSimplification()); globalParams->getEnablePathSimplification());
maskColor[0] = 0; maskColor[0] = 0;
maskSplash->clear(maskColor); maskSplash->clear(maskColor);
maskColor[0] = 0xff; maskColor[0] = 0xff;
maskSplash->setFillPattern(new SplashSolidColor(maskColor)); maskSplash->setFillPattern(new SplashSolidColor(maskColor));
// use "glyph mode" here to get the correct scaled size // use "glyph mode" here to get the correct scaled size
maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData, maskSplash->fillImageMask(NULL, &imageMaskSrc, &imgMaskData,
maskWidth, maskHeight, mat, gTrue, interpolate); maskWidth, maskHeight, mat, gTrue, interpolate);
delete imgMaskData.imgStr; delete imgMaskData.imgStr;
maskStr->close(); maskStr->close();
delete maskSplash; delete maskSplash;
//----- draw the source image //----- draw the source image
mat[0] = ctm[0]; mat[0] = ctm[0];
mat[1] = ctm[1]; mat[1] = ctm[1];
mat[2] = -ctm[2]; mat[2] = -ctm[2];
skipping to change at line 3765 skipping to change at line 3862
mat[5] = ctm[3] + ctm[5]; mat[5] = ctm[3] + ctm[5];
imgData.imgStr = new ImageStream(str, width, imgData.imgStr = new ImageStream(str, width,
colorMap->getNumPixelComps(), colorMap->getNumPixelComps(),
colorMap->getBits()); colorMap->getBits());
imgData.imgStr->reset(); imgData.imgStr->reset();
imgData.colorMap = colorMap; imgData.colorMap = colorMap;
imgData.ri = state->getRenderingIntent(); imgData.ri = state->getRenderingIntent();
imgData.mask = maskBitmap; imgData.mask = maskBitmap;
imgData.colorMode = colorMode; imgData.colorMode = colorMode;
imgData.invert = reverseVideo && reverseVideoInvertImages;
imgData.width = width; imgData.width = width;
imgData.height = height; imgData.height = height;
imgData.y = 0; imgData.y = 0;
// special case for one-channel (monochrome/gray/separation) images: // special case for one-channel (monochrome/gray/separation) images:
// build a lookup table here // build a lookup table here
imgData.lookup = NULL; imgData.lookup = NULL;
if (colorMap->getNumPixelComps() == 1) { if (colorMap->getNumPixelComps() == 1) {
if (colorMap->getBits() <= 8) { if (colorMap->getBits() <= 8) {
n = 1 << colorMap->getBits(); n = 1 << colorMap->getBits();
skipping to change at line 3823 skipping to change at line 3921
} }
} }
if (colorMode == splashModeMono1) { if (colorMode == splashModeMono1) {
srcMode = splashModeMono8; srcMode = splashModeMono8;
} else if (colorMode == splashModeBGR8) { } else if (colorMode == splashModeBGR8) {
srcMode = splashModeRGB8; srcMode = splashModeRGB8;
} else { } else {
srcMode = colorMode; srcMode = colorMode;
} }
splash->drawImage(&maskedImageSrc, &imgData, srcMode, gTrue, imgTag = makeImageTag(ref);
splash->drawImage(imgTag,
&maskedImageSrc, &imgData, srcMode, gTrue,
width, height, mat, interpolate); width, height, mat, interpolate);
delete imgTag;
delete maskBitmap; delete maskBitmap;
gfree(imgData.lookup); gfree(imgData.lookup);
delete imgData.imgStr; delete imgData.imgStr;
str->close(); str->close();
} }
} }
struct SplashOutSoftMaskMatteImageData { struct SplashOutSoftMaskMatteImageData {
ImageStream *imgStr; ImageStream *imgStr;
ImageStream *maskStr; ImageStream *maskStr;
GfxImageColorMap *colorMap; GfxImageColorMap *colorMap;
GfxRenderingIntent ri; GfxRenderingIntent ri;
Guchar matte[gfxColorMaxComps]; Guchar matte[gfxColorMaxComps];
SplashColorMode colorMode; SplashColorMode colorMode;
GBool invert;
int width, height, y; int width, height, y;
}; };
GBool SplashOutputDev::softMaskMatteImageSrc(void *data, GBool SplashOutputDev::softMaskMatteImageSrc(void *data,
SplashColorPtr colorLine, SplashColorPtr colorLine,
Guchar *alphaLine) { Guchar *alphaLine) {
SplashOutSoftMaskMatteImageData *imgData = SplashOutSoftMaskMatteImageData *imgData =
(SplashOutSoftMaskMatteImageData *)data; (SplashOutSoftMaskMatteImageData *)data;
Guchar *p, *ap, *aq; Guchar *p, *ap, *aq;
SplashColorPtr q; SplashColorPtr q;
GfxRGB rgb; GfxRGB rgb;
GfxGray gray; GfxGray gray;
#if SPLASH_CMYK #if SPLASH_CMYK
GfxCMYK cmyk; GfxCMYK cmyk;
#endif #endif
Guchar alpha; Guchar alpha;
int nComps, x; int nComps, n, x;
if (imgData->y == imgData->height || if (imgData->y == imgData->height ||
!(p = imgData->imgStr->getLine()) || !(p = imgData->imgStr->getLine()) ||
!(ap = imgData->maskStr->getLine())) { !(ap = imgData->maskStr->getLine())) {
memset(colorLine, 0, memset(colorLine, 0,
imgData->width * splashColorModeNComps[imgData->colorMode]); imgData->width * splashColorModeNComps[imgData->colorMode]);
memset(alphaLine, 0, imgData->width); memset(alphaLine, 0, imgData->width);
return gFalse; return gFalse;
} }
skipping to change at line 3928 skipping to change at line 4030
*q++ = 0; *q++ = 0;
*q++ = 0; *q++ = 0;
*q++ = 0; *q++ = 0;
} }
break; break;
#endif #endif
} }
*aq++ = alpha; *aq++ = alpha;
} }
if (imgData->invert) {
n = imgData->width * splashColorModeNComps[imgData->colorMode];
for (x = 0, p = colorLine; x < n; ++x, ++p) {
*p ^= 0xff;
}
}
++imgData->y; ++imgData->y;
return gTrue; return gTrue;
} }
void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref,
Stream *str, int width, int height, Stream *str, int width, int height,
GfxImageColorMap *colorMap, GfxImageColorMap *colorMap,
Stream *maskStr, Stream *maskStr,
int maskWidth, int maskHeight, int maskWidth, int maskHeight,
GfxImageColorMap *maskColorMap, GfxImageColorMap *maskColorMap,
double *matte, GBool interpolate) { double *matte, GBool interpolate) {
double *ctm; double *ctm;
SplashCoord mat[6]; SplashCoord mat[6];
SplashOutImageData imgData; SplashOutImageData imgData;
SplashOutImageData imgMaskData; SplashOutImageData imgMaskData;
SplashOutSoftMaskMatteImageData matteImgData; SplashOutSoftMaskMatteImageData matteImgData;
GString *imgTag;
SplashColorMode srcMode; SplashColorMode srcMode;
SplashBitmap *maskBitmap; SplashBitmap *maskBitmap;
Splash *maskSplash; Splash *maskSplash;
GfxColor matteColor; GfxColor matteColor;
GfxGray gray; GfxGray gray;
GfxRGB rgb; GfxRGB rgb;
#if SPLASH_CMYK #if SPLASH_CMYK
GfxCMYK cmyk; GfxCMYK cmyk;
#endif #endif
Guchar pix; Guchar pix;
skipping to change at line 4033 skipping to change at line 4143
#endif #endif
} }
//~ could add the matteImgData.lookup special case //~ could add the matteImgData.lookup special case
if (colorMap->getBits() <= 8) { if (colorMap->getBits() <= 8) {
n = 1 << maskColorMap->getBits(); n = 1 << maskColorMap->getBits();
} else { } else {
// GfxImageColorMap and ImageStream compress 16-bit samples to 8-bit // GfxImageColorMap and ImageStream compress 16-bit samples to 8-bit
n = 1 << 8; n = 1 << 8;
} }
matteImgData.colorMode = colorMode; matteImgData.colorMode = colorMode;
matteImgData.invert = reverseVideo && reverseVideoInvertImages;
matteImgData.width = width; matteImgData.width = width;
matteImgData.height = height; matteImgData.height = height;
matteImgData.y = 0; matteImgData.y = 0;
splash->drawImage(&softMaskMatteImageSrc, &matteImgData, imgTag = makeImageTag(ref);
splash->drawImage(imgTag, &softMaskMatteImageSrc, &matteImgData,
srcMode, gTrue, width, height, mat, interpolate); srcMode, gTrue, width, height, mat, interpolate);
delete imgTag;
delete matteImgData.maskStr; delete matteImgData.maskStr;
delete matteImgData.imgStr; delete matteImgData.imgStr;
maskStr->close(); maskStr->close();
str->close(); str->close();
} else { } else {
reduceImageResolution(str, ctm, &width, &height); reduceImageResolution(str, ctm, &width, &height);
reduceImageResolution(maskStr, ctm, &maskWidth, &maskHeight); reduceImageResolution(maskStr, ctm, &maskWidth, &maskHeight);
//----- set up the soft mask //----- set up the soft mask
imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, imgMaskData.imgStr = new ImageStream(maskStr, maskWidth,
maskColorMap->getNumPixelComps(), maskColorMap->getNumPixelComps(),
maskColorMap->getBits()); maskColorMap->getBits());
imgMaskData.imgStr->reset(); imgMaskData.imgStr->reset();
imgMaskData.colorMap = maskColorMap; imgMaskData.colorMap = maskColorMap;
imgMaskData.ri = state->getRenderingIntent(); imgMaskData.ri = state->getRenderingIntent();
imgMaskData.maskColors = NULL; imgMaskData.maskColors = NULL;
imgMaskData.colorMode = splashModeMono8; imgMaskData.colorMode = splashModeMono8;
imgMaskData.invert = gFalse;
imgMaskData.width = maskWidth; imgMaskData.width = maskWidth;
imgMaskData.height = maskHeight; imgMaskData.height = maskHeight;
imgMaskData.y = 0; imgMaskData.y = 0;
n = 1 << maskColorMap->getBits(); n = 1 << maskColorMap->getBits();
imgMaskData.lookup = (SplashColorPtr)gmalloc(n); imgMaskData.lookup = (SplashColorPtr)gmalloc(n);
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {
pix = (Guchar)i; pix = (Guchar)i;
maskColorMap->getGray(&pix, &gray, state->getRenderingIntent()); maskColorMap->getGray(&pix, &gray, state->getRenderingIntent());
imgMaskData.lookup[i] = colToByte(gray); imgMaskData.lookup[i] = colToByte(gray);
} }
maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
1, splashModeMono8, gFalse); 1, splashModeMono8, gFalse, gTrue, bitmap);
maskSplash = new Splash(maskBitmap, vectorAntialias); maskSplash = new Splash(maskBitmap, vectorAntialias,
splash->getImageCache());
maskSplash->setStrokeAdjust( maskSplash->setStrokeAdjust(
mapStrokeAdjustMode[globalParams->getStrokeAdjust()]); mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
maskSplash->setEnablePathSimplification( maskSplash->setEnablePathSimplification(
globalParams->getEnablePathSimplification()); globalParams->getEnablePathSimplification());
clearMaskRegion(state, maskSplash, 0, 0, 1, 1); clearMaskRegion(state, maskSplash, 0, 0, 1, 1);
maskSplash->drawImage(&imageSrc, &imgMaskData, splashModeMono8, gFalse, maskSplash->drawImage(NULL,
&imageSrc, &imgMaskData, splashModeMono8, gFalse,
maskWidth, maskHeight, mat, interpolate); maskWidth, maskHeight, mat, interpolate);
delete imgMaskData.imgStr; delete imgMaskData.imgStr;
maskStr->close(); maskStr->close();
gfree(imgMaskData.lookup); gfree(imgMaskData.lookup);
delete maskSplash; delete maskSplash;
splash->setSoftMask(maskBitmap); splash->setSoftMask(maskBitmap);
//----- draw the source image //----- draw the source image
imgData.imgStr = new ImageStream(str, width, imgData.imgStr = new ImageStream(str, width,
colorMap->getNumPixelComps(), colorMap->getNumPixelComps(),
colorMap->getBits()); colorMap->getBits());
imgData.imgStr->reset(); imgData.imgStr->reset();
imgData.colorMap = colorMap; imgData.colorMap = colorMap;
imgData.ri = state->getRenderingIntent(); imgData.ri = state->getRenderingIntent();
imgData.maskColors = NULL; imgData.maskColors = NULL;
imgData.colorMode = colorMode; imgData.colorMode = colorMode;
imgData.invert = reverseVideo && reverseVideoInvertImages;
imgData.width = width; imgData.width = width;
imgData.height = height; imgData.height = height;
imgData.y = 0; imgData.y = 0;
// special case for one-channel (monochrome/gray/separation) images: // special case for one-channel (monochrome/gray/separation) images:
// build a lookup table here // build a lookup table here
imgData.lookup = NULL; imgData.lookup = NULL;
if (colorMap->getNumPixelComps() == 1) { if (colorMap->getNumPixelComps() == 1) {
if (colorMap->getBits() <= 8) { if (colorMap->getBits() <= 8) {
n = 1 << colorMap->getBits(); n = 1 << colorMap->getBits();
skipping to change at line 4145 skipping to change at line 4262
imgData.lookup[4*i] = colToByte(cmyk.c); imgData.lookup[4*i] = colToByte(cmyk.c);
imgData.lookup[4*i+1] = colToByte(cmyk.m); imgData.lookup[4*i+1] = colToByte(cmyk.m);
imgData.lookup[4*i+2] = colToByte(cmyk.y); imgData.lookup[4*i+2] = colToByte(cmyk.y);
imgData.lookup[4*i+3] = colToByte(cmyk.k); imgData.lookup[4*i+3] = colToByte(cmyk.k);
} }
break; break;
#endif #endif
} }
} }
splash->drawImage(&imageSrc, &imgData, srcMode, gFalse, width, height, mat, imgTag = makeImageTag(ref);
splash->drawImage(imgTag,
&imageSrc, &imgData, srcMode, gFalse, width, height, mat,
interpolate); interpolate);
splash->setSoftMask(NULL); splash->setSoftMask(NULL);
delete imgTag;
gfree(imgData.lookup); gfree(imgData.lookup);
delete imgData.imgStr; delete imgData.imgStr;
str->close(); str->close();
} }
} }
GString *SplashOutputDev::makeImageTag(Object *ref) {
if (!ref || !ref->isRef()) {
return NULL;
}
return GString::format("{0:d}_{1:d}", ref->getRefNum(), ref->getRefGen());
}
void SplashOutputDev::reduceImageResolution(Stream *str, double *ctm, void SplashOutputDev::reduceImageResolution(Stream *str, double *ctm,
int *width, int *height) { int *width, int *height) {
double sw, sh; double sw, sh;
int reduction; int reduction;
if (str->getKind() == strJPX && if (str->getKind() == strJPX &&
*width >= 256 &&
*height >= 256 &&
*width * *height > 10000000) { *width * *height > 10000000) {
sw = (double)*width / (fabs(ctm[0]) + fabs(ctm[1])); sw = (double)*width / (fabs(ctm[0]) + fabs(ctm[1]));
sh = (double)*height / (fabs(ctm[2]) + fabs(ctm[3])); sh = (double)*height / (fabs(ctm[2]) + fabs(ctm[3]));
if (sw > 8 && sh > 8) { if (sw > 8 && sh > 8) {
reduction = 3; reduction = 3;
} else if (sw > 4 && sh > 4) { } else if (sw > 4 && sh > 4) {
reduction = 2; reduction = 2;
} else if (sw > 2 && sh > 2) { } else if (sw > 2 && sh > 2) {
reduction = 1; reduction = 1;
} else { } else {
skipping to change at line 4384 skipping to change at line 4513
} else if (blendingColorSpace->getMode() == csDeviceCMYK || } else if (blendingColorSpace->getMode() == csDeviceCMYK ||
(blendingColorSpace->getMode() == csICCBased && (blendingColorSpace->getMode() == csICCBased &&
blendingColorSpace->getNComps() == 4)) { blendingColorSpace->getNComps() == 4)) {
colorMode = splashModeCMYK8; colorMode = splashModeCMYK8;
#endif #endif
} }
} }
// create the temporary bitmap // create the temporary bitmap
bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, gTrue, bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, gTrue,
bitmapTopDown); bitmapTopDown, transpGroup->origBitmap);
splash = new Splash(bitmap, vectorAntialias, splash = new Splash(bitmap, vectorAntialias,
transpGroup->origSplash->getImageCache(),
transpGroup->origSplash->getScreen()); transpGroup->origSplash->getScreen());
splash->setMinLineWidth(globalParams->getMinLineWidth()); splash->setMinLineWidth(globalParams->getMinLineWidth());
splash->setStrokeAdjust( splash->setStrokeAdjust(
mapStrokeAdjustMode[globalParams->getStrokeAdjust()]); mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
splash->setEnablePathSimplification( splash->setEnablePathSimplification(
globalParams->getEnablePathSimplification()); globalParams->getEnablePathSimplification());
copyState(transpGroup->origSplash, gTrue); copyState(transpGroup->origSplash, gTrue);
if (isolated) { if (isolated) {
for (i = 0; i < splashMaxColorComps; ++i) { for (i = 0; i < splashMaxColorComps; ++i) {
color[i] = 0; color[i] = 0;
} }
splash->clear(color, 0); splash->clear(color, 0);
} else { } else {
splash->blitTransparent(transpGroup->origBitmap, tx, ty, 0, 0, w, h); splash->blitTransparent(transpGroup->origBitmap, tx, ty, 0, 0, w, h);
} }
if (!isolated && if (!isolated &&
transpGroup->origBitmap->getAlphaPtr() && transpGroup->origBitmap->getAlphaPtr() &&
transpGroup->origSplash->getInNonIsolatedGroup()) { transpGroup->origSplash->getInNonIsolatedGroup() &&
colorMode != splashModeMono1) {
// when drawing a non-isolated group into another non-isolated group, // when drawing a non-isolated group into another non-isolated group,
// compute a backdrop bitmap with corrected alpha values // compute a backdrop bitmap with corrected alpha values
backdropBitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, gTrue, backdropBitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, gTrue,
bitmapTopDown); bitmapTopDown, transpGroup->origBitmap);
transpGroup->origSplash->blitCorrectedAlpha(backdropBitmap, transpGroup->origSplash->blitCorrectedAlpha(backdropBitmap,
tx, ty, 0, 0, w, h); tx, ty, 0, 0, w, h);
transpGroup->backdropBitmap = backdropBitmap; transpGroup->backdropBitmap = backdropBitmap;
splash->setInTransparencyGroup(backdropBitmap, 0, 0, splash->setInTransparencyGroup(backdropBitmap, 0, 0,
!isolated, knockout); !isolated, knockout);
} else { } else {
backdropBitmap = transpGroup->origBitmap; backdropBitmap = transpGroup->origBitmap;
transpGroup->backdropBitmap = NULL; transpGroup->backdropBitmap = NULL;
splash->setInTransparencyGroup(backdropBitmap, tx, ty, splash->setInTransparencyGroup(backdropBitmap, tx, ty,
!isolated, knockout); !isolated, knockout);
skipping to change at line 4509 skipping to change at line 4640
ty = transpGroupStack->ty; ty = transpGroupStack->ty;
tBitmap = transpGroupStack->tBitmap; tBitmap = transpGroupStack->tBitmap;
// composite with backdrop color // composite with backdrop color
backdrop = 0; backdrop = 0;
if (!alpha && tBitmap->getMode() != splashModeMono1) { if (!alpha && tBitmap->getMode() != splashModeMono1) {
//~ need to correctly handle the case where no blending color //~ need to correctly handle the case where no blending color
//~ space is given //~ space is given
if (transpGroupStack->blendingColorSpace) { if (transpGroupStack->blendingColorSpace) {
tSplash = new Splash(tBitmap, vectorAntialias, tSplash = new Splash(tBitmap, vectorAntialias,
transpGroupStack->origSplash->getImageCache(),
transpGroupStack->origSplash->getScreen()); transpGroupStack->origSplash->getScreen());
tSplash->setStrokeAdjust( tSplash->setStrokeAdjust(
mapStrokeAdjustMode[globalParams->getStrokeAdjust()]); mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
tSplash->setEnablePathSimplification( tSplash->setEnablePathSimplification(
globalParams->getEnablePathSimplification()); globalParams->getEnablePathSimplification());
switch (tBitmap->getMode()) { switch (tBitmap->getMode()) {
case splashModeMono1: case splashModeMono1:
// transparency is not supported in mono1 mode // transparency is not supported in mono1 mode
break; break;
case splashModeMono8: case splashModeMono8:
skipping to change at line 4566 skipping to change at line 4698
delete tSplash; delete tSplash;
} }
} }
if (transferFunc) { if (transferFunc) {
transferFunc->transform(&backdrop, &backdrop2); transferFunc->transform(&backdrop, &backdrop2);
} else { } else {
backdrop2 = backdrop; backdrop2 = backdrop;
} }
softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
1, splashModeMono8, gFalse); 1, splashModeMono8, gFalse, gTrue, bitmap);
memset(softMask->getDataPtr(), (int)(backdrop2 * 255.0 + 0.5), memset(softMask->getDataPtr(), (int)(backdrop2 * 255.0 + 0.5),
softMask->getRowSize() * softMask->getHeight()); softMask->getRowSize() * softMask->getHeight());
if (tx < softMask->getWidth() && ty < softMask->getHeight()) { if (tx < softMask->getWidth() && ty < softMask->getHeight()) {
p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx; p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx;
for (y = 0; y < tBitmap->getHeight(); ++y) { for (y = 0; y < tBitmap->getHeight(); ++y) {
for (x = 0; x < tBitmap->getWidth(); ++x) { for (x = 0; x < tBitmap->getWidth(); ++x) {
if (alpha) { if (alpha) {
lum = tBitmap->getAlpha(x, y) / 255.0; lum = tBitmap->getAlpha(x, y) / 255.0;
} else { } else {
tBitmap->getPixel(x, y, color); tBitmap->getPixel(x, y, color);
skipping to change at line 4648 skipping to change at line 4780
int SplashOutputDev::getBitmapHeight() { int SplashOutputDev::getBitmapHeight() {
return bitmap->getHeight(); return bitmap->getHeight();
} }
SplashBitmap *SplashOutputDev::takeBitmap() { SplashBitmap *SplashOutputDev::takeBitmap() {
SplashBitmap *ret; SplashBitmap *ret;
ret = bitmap; ret = bitmap;
bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode, bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode,
colorMode != splashModeMono1, bitmapTopDown); colorMode != splashModeMono1, bitmapTopDown, NULL);
return ret; return ret;
} }
void SplashOutputDev::getModRegion(int *xMin, int *yMin, void SplashOutputDev::getModRegion(int *xMin, int *yMin,
int *xMax, int *yMax) { int *xMax, int *yMax) {
splash->getModRegion(xMin, yMin, xMax, yMax); splash->getModRegion(xMin, yMin, xMax, yMax);
} }
void SplashOutputDev::clearModRegion() { void SplashOutputDev::clearModRegion() {
splash->clearModRegion(); splash->clearModRegion();
 End of changes. 75 change blocks. 
44 lines changed or deleted 176 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)