"Fossies" - the Fresh Open Source Software Archive  

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

About: Xpdf is a PDF viewer for X.

SplashBitmap.cc  (xpdf-4.01.01):SplashBitmap.cc  (xpdf-4.02)
skipping to change at line 28 skipping to change at line 28
#include "gmempp.h" #include "gmempp.h"
#include "SplashErrorCodes.h" #include "SplashErrorCodes.h"
#include "SplashBitmap.h" #include "SplashBitmap.h"
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// SplashBitmap // SplashBitmap
//------------------------------------------------------------------------ //------------------------------------------------------------------------
SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad, SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
SplashColorMode modeA, GBool alphaA, SplashColorMode modeA, GBool alphaA,
GBool topDown) { GBool topDown, SplashBitmap *parentA) {
// NB: this code checks that rowSize fits in a signed 32-bit // NB: this code checks that rowSize fits in a signed 32-bit
// integer, because some code (outside this class) makes that // integer, because some code (outside this class) makes that
// assumption // assumption
width = widthA; width = widthA;
height = heightA; height = heightA;
mode = modeA; mode = modeA;
switch (mode) { switch (mode) {
case splashModeMono1: case splashModeMono1:
if (width <= 0) { if (width <= 0) {
gMemError("invalid bitmap width"); gMemError("invalid bitmap width");
skipping to change at line 66 skipping to change at line 66
case splashModeCMYK8: case splashModeCMYK8:
if (width <= 0 || width > INT_MAX / 4) { if (width <= 0 || width > INT_MAX / 4) {
gMemError("invalid bitmap width"); gMemError("invalid bitmap width");
} }
rowSize = (SplashBitmapRowSize)width * 4; rowSize = (SplashBitmapRowSize)width * 4;
break; break;
#endif #endif
} }
rowSize += rowPad - 1; rowSize += rowPad - 1;
rowSize -= rowSize % rowPad; rowSize -= rowSize % rowPad;
data = (SplashColorPtr)gmallocn64(height, rowSize);
parent = parentA;
oldData = NULL;
oldAlpha = NULL;
oldRowSize = 0;
oldAlphaRowSize = 0;
oldHeight = 0;
if (parent && parent->oldData &&
parent->oldRowSize == rowSize &&
parent->oldHeight == height) {
data = parent->oldData;
parent->oldData = NULL;
} else {
data = (SplashColorPtr)gmallocn64(height, rowSize);
}
if (!topDown) { if (!topDown) {
data += (height - 1) * rowSize; data += (height - 1) * rowSize;
rowSize = -rowSize; rowSize = -rowSize;
} }
if (alphaA) { if (alphaA) {
alphaRowSize = width; alphaRowSize = width;
alpha = (Guchar *)gmallocn64(height, alphaRowSize); if (parent && parent->oldAlpha &&
parent->oldAlphaRowSize == alphaRowSize &&
parent->oldHeight == height) {
alpha = parent->oldAlpha;
parent->oldAlpha = NULL;
} else {
alpha = (Guchar *)gmallocn64(height, alphaRowSize);
}
} else { } else {
alphaRowSize = 0; alphaRowSize = 0;
alpha = NULL; alpha = NULL;
} }
} }
SplashBitmap::~SplashBitmap() { SplashBitmap::~SplashBitmap() {
if (data) { if (data && rowSize < 0) {
if (rowSize < 0) { rowSize = -rowSize;
gfree(data + (height - 1) * rowSize); data -= (height - 1) * rowSize;
} else { }
gfree(data); if (parent && rowSize > 10000000 / height) {
} gfree(parent->oldData);
gfree(parent->oldAlpha);
parent->oldData = data;
parent->oldAlpha = alpha;
parent->oldRowSize = rowSize;
parent->oldAlphaRowSize = alphaRowSize;
parent->oldHeight = height;
} else {
gfree(data);
gfree(alpha);
} }
gfree(alpha); gfree(oldData);
gfree(oldAlpha);
} }
SplashError SplashBitmap::writePNMFile(char *fileName) { SplashError SplashBitmap::writePNMFile(char *fileName) {
FILE *f; FILE *f;
SplashError err; SplashError err;
if (!(f = fopen(fileName, "wb"))) { if (!(f = fopen(fileName, "wb"))) {
return splashErrOpenFile; return splashErrOpenFile;
} }
err = writePNMFile(f); err = writePNMFile(f);
 End of changes. 5 change blocks. 
10 lines changed or deleted 41 lines changed or added

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