|
|
@ -25,6 +25,8 @@ QAtomicInt XPDFRenderer::sInstancesCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile) |
|
|
|
XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile) |
|
|
|
: mDocument(0) |
|
|
|
: mDocument(0) |
|
|
|
|
|
|
|
, mpSplashBitmap(0) |
|
|
|
|
|
|
|
, mSplash(0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!globalParams) |
|
|
|
if (!globalParams) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -48,6 +50,17 @@ XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile) |
|
|
|
|
|
|
|
|
|
|
|
XPDFRenderer::~XPDFRenderer() |
|
|
|
XPDFRenderer::~XPDFRenderer() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
qDeleteAll(mThumbs); |
|
|
|
|
|
|
|
mThumbs.clear(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qDeleteAll(mNumPageToPageMap); |
|
|
|
|
|
|
|
mNumPageToPageMap.clear(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(mSplash){ |
|
|
|
|
|
|
|
delete mSplash; |
|
|
|
|
|
|
|
mSplash = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mDocument) |
|
|
|
if (mDocument) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete mDocument; |
|
|
|
delete mDocument; |
|
|
@ -162,7 +175,7 @@ void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
// Generate the thumbnail
|
|
|
|
// Generate the thumbnail
|
|
|
|
mThumbs << *createPDFImage(pageNumber, xscale, yscale, bounds); |
|
|
|
mThumbs << createPDFImage(pageNumber, xscale, yscale, bounds); |
|
|
|
mThumbMap[pageNumber - 1] = true; |
|
|
|
mThumbMap[pageNumber - 1] = true; |
|
|
|
if(pageNumber == mDocument->getNumPages()) |
|
|
|
if(pageNumber == mDocument->getNumPages()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -175,7 +188,7 @@ void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds) |
|
|
|
if(!mPagesMap[pageNumber - 1] || bZoomChanged) |
|
|
|
if(!mPagesMap[pageNumber - 1] || bZoomChanged) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Generate the page
|
|
|
|
// Generate the page
|
|
|
|
mNumPageToPageMap[pageNumber] = *createPDFImage(pageNumber, xscale, yscale, bounds); |
|
|
|
mNumPageToPageMap[pageNumber] = createPDFImage(pageNumber, xscale, yscale, bounds); |
|
|
|
mPagesMap[pageNumber - 1] = true; |
|
|
|
mPagesMap[pageNumber - 1] = true; |
|
|
|
if(mPagesMap.size() == mDocument->getNumPages()) |
|
|
|
if(mPagesMap.size() == mDocument->getNumPages()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -184,7 +197,7 @@ void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QImage pdfImage; |
|
|
|
QImage *pdfImage; |
|
|
|
|
|
|
|
|
|
|
|
if(!bThumbGenerated || bFirstThumbnail) |
|
|
|
if(!bThumbGenerated || bFirstThumbnail) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -197,10 +210,7 @@ void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds) |
|
|
|
|
|
|
|
|
|
|
|
QTransform savedTransform = p->worldTransform(); |
|
|
|
QTransform savedTransform = p->worldTransform(); |
|
|
|
p->resetTransform(); |
|
|
|
p->resetTransform(); |
|
|
|
QTime t; |
|
|
|
p->drawImage(QPointF(savedTransform.dx() + mSliceX, savedTransform.dy() + mSliceY), *pdfImage); |
|
|
|
t.start(); |
|
|
|
|
|
|
|
p->drawImage(QPointF(savedTransform.dx() + mSliceX, savedTransform.dy() + mSliceY), pdfImage); |
|
|
|
|
|
|
|
//qDebug() << "XPDFRenderer::render(...) execution time: " << t.elapsed() << "ms";
|
|
|
|
|
|
|
|
p->setWorldTransform(savedTransform); |
|
|
|
p->setWorldTransform(savedTransform); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -211,6 +221,8 @@ QImage* XPDFRenderer::createPDFImage(int pageNumber, const qreal xscale, const q |
|
|
|
if (isValid()) |
|
|
|
if (isValid()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white
|
|
|
|
SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white
|
|
|
|
|
|
|
|
if(mSplash) |
|
|
|
|
|
|
|
delete mSplash; |
|
|
|
mSplash = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor); |
|
|
|
mSplash = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor); |
|
|
|
mSplash->startDoc(mDocument->getXRef()); |
|
|
|
mSplash->startDoc(mDocument->getXRef()); |
|
|
|
int hResolution = 72; |
|
|
|
int hResolution = 72; |
|
|
@ -241,6 +253,7 @@ QImage* XPDFRenderer::createPDFImage(int pageNumber, const qreal xscale, const q |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mpSplashBitmap = mSplash->getBitmap(); |
|
|
|
mpSplashBitmap = mSplash->getBitmap(); |
|
|
|
|
|
|
|
delete img; |
|
|
|
img = new QImage(mpSplashBitmap->getDataPtr(), mpSplashBitmap->getWidth(), mpSplashBitmap->getHeight(), mpSplashBitmap->getWidth() * 3, QImage::Format_RGB888); |
|
|
|
img = new QImage(mpSplashBitmap->getDataPtr(), mpSplashBitmap->getWidth(), mpSplashBitmap->getHeight(), mpSplashBitmap->getWidth() * 3, QImage::Format_RGB888); |
|
|
|
} |
|
|
|
} |
|
|
|
return img; |
|
|
|
return img; |
|
|
|