Commit e37ff4f3 authored by Pino Toscano's avatar Pino Toscano

small trick: when generating small pixmaps (ie less wide than 300px) the...

small trick: when generating small pixmaps (ie less wide than 300px) the render it as a page wider than 800px, and then rescale it back. this way, we respect more the geometry of the page in the small pixmaps (tipically, thumbnails).

svn path=/trunk/playground/graphics/okular/; revision=553409
parent 80a843cb
......@@ -36,6 +36,7 @@ CHMGenerator::CHMGenerator( KPDFDocument * doc ) : Generator ( doc )
m_docInfo=0;
// m_asyncGen=0;
// px=0;
m_pixmapRequestZoom=1;
}
bool CHMGenerator::loadDocument( const QString & fileName, QVector< KPDFPage * > & pagesVector )
......@@ -103,6 +104,14 @@ void CHMGenerator::slotCompleted()
// m_syncGen->view()->layout();
m_syncGen->paint(&p, r,0,&moreToPaint);
p.end();
if (m_pixmapRequestZoom>1)
{
QPixmap* newpix=new QPixmap();
*newpix=pix->scaled(m_request->width/m_pixmapRequestZoom, m_request->height/m_pixmapRequestZoom);
delete pix;
pix=newpix;
m_pixmapRequestZoom=1;
}
additionalRequestData();
syncLock.unlock();
m_request->page->setPixmap( m_request->id, pix );
......@@ -158,6 +167,13 @@ void CHMGenerator::generatePixmap( PixmapRequest * request )
<< ", priority: " << request->priority << " id: " << request->id
<< endl;
if (request->width<300)
{
m_pixmapRequestZoom=900/request->width;
request->width*=m_pixmapRequestZoom;
request->height*=m_pixmapRequestZoom;
}
syncLock.lock();
QString url= m_file->getUrlForPage ( request->pageNumber + 1 );
int zoom = qMax( static_cast<double>(request->width)/static_cast<double>(request->page->width())
......
......@@ -85,6 +85,7 @@ class CHMGenerator : public Generator
// -1 is internal error :)
int m_state;
PixmapRequest* m_request;
int m_pixmapRequestZoom;
volatile bool m_doneFlagSet;
DocumentInfo* m_docInfo;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment