From 250c12fdd735d6bbc9d93a047fbaa8e89d81d5ff Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 14 Mar 2008 19:34:00 +0000 Subject: [PATCH] Fix "Make sure we don't draw outside the bitmap on Splash::fillGlyph2" when painting with no aa Not useful for kpdf as we always draw with aa but why have wrong core when we can have the correct one? svn path=/branches/KDE/3.5/kdegraphics/kpdf/; revision=785709 --- xpdf/splash/Splash.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xpdf/splash/Splash.cc b/xpdf/splash/Splash.cc index f05b891ad..f5d0e8427 100644 --- a/xpdf/splash/Splash.cc +++ b/xpdf/splash/Splash.cc @@ -1717,12 +1717,14 @@ void Splash::fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noClip) p += glyph->w; } } else { + const int widthEight = (int)ceil(glyph->w / 8.0); + pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gFalse, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) { - alpha0 = p[xx]; + alpha0 = p[xx / 8]; for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) { if (alpha0 & 0x80) { pipeRun(&pipe); @@ -1758,15 +1760,17 @@ void Splash::fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noClip) pipeIncX(&pipe); } } - p += glyph->w; + p += widthEight; } } else { + const int widthEight = (int)ceil(glyph->w / 8.0); + pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gFalse, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) { - alpha0 = p[xx]; + alpha0 = p[xx / 8]; for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) { if (state->clip->test(x1, y1)) { if (alpha0 & 0x80) { @@ -1782,7 +1786,7 @@ void Splash::fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noClip) alpha0 <<= 1; } } - p += glyph->w; + p += widthEight; } } }