[poppler] poppler/qt4/tests: stress-poppler-qt4.cpp, 1.3, 1.4 test-password-qt4.cpp, 1.1, 1.2 test-poppler-qt4.cpp, 1.7, 1.8

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Nov 15 13:07:53 PST 2006


Update of /cvs/poppler/poppler/qt4/tests
In directory kemper:/tmp/cvs-serv30833/qt4/tests

Modified Files:
	stress-poppler-qt4.cpp test-password-qt4.cpp 
	test-poppler-qt4.cpp 
Log Message:
2006-11-15  Albert Astals Cid <aacid at kde.org>

        * qt4/src/poppler-link.cc:
        * qt4/src/poppler-page.cc:
        * qt4/src/poppler-qt4.h:
        * qt4/src/poppler-document.cc:
        * qt4/src/poppler-private.h: Generalize the way we render the pages:
        merge all the Page::renderTo* functions in only one that renders on
        a QImage, taking into account the currently chosen backend.
        It is possible to switch rendering backend using the Document.
        Patch by Pino Toscano.

        * qt4/tests/stress-poppler-qt4.cpp:
        * qt4/tests/test-password-qt4.cpp:
        * qt4/tests/test-poppler-qt4.cpp: Adapt the tests to the changes in
        the rendering API of Page. Patch by Pino Toscano.



Index: stress-poppler-qt4.cpp
===================================================================
RCS file: /cvs/poppler/poppler/qt4/tests/stress-poppler-qt4.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- stress-poppler-qt4.cpp	28 Dec 2005 09:23:43 -0000	1.3
+++ stress-poppler-qt4.cpp	15 Nov 2006 21:07:50 -0000	1.4
@@ -53,8 +53,7 @@
 
 		for( int index = 0; index < doc->numPages(); ++index ) {
 		    Poppler::Page *page = doc->page( index );
-		    QPixmap *pixmap = new QPixmap(page->pageSize());
-		    page->renderToPixmap(pixmap);
+		    QImage image = page->renderToImage();
 		    page->pageSize();
 		    page->orientation();
 		    delete page;

Index: test-password-qt4.cpp
===================================================================
RCS file: /cvs/poppler/poppler/qt4/tests/test-password-qt4.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test-password-qt4.cpp	6 Aug 2005 01:53:06 -0000	1.1
+++ test-password-qt4.cpp	15 Nov 2006 21:07:50 -0000	1.2
@@ -17,7 +17,7 @@
 private:
     void display();
     int m_currentPage;
-    QPixmap	*pixmap;
+    QImage image;
     Poppler::Document *doc;
 };
 
@@ -34,8 +34,7 @@
 	Poppler::Page *page = doc->page(m_currentPage);
 	if (page) {
 	    qDebug() << "Displaying page: " << m_currentPage;
-	    pixmap = new QPixmap(page->pageSize());
-	    page->renderToPixmap(pixmap);
+	    image = page->renderToImage();
 	    update();
 	    delete page;
 	}
@@ -47,16 +46,15 @@
 PDFDisplay::~PDFDisplay()
 {
     delete doc;
-    delete pixmap;
 }
 
 void PDFDisplay::paintEvent( QPaintEvent *e )
 {
     QPainter paint( this );                     // paint widget
-    if (pixmap) {
-	paint.drawPixmap(0, 0, *pixmap);
+    if (!image.isNull()) {
+	paint.drawImage(0, 0, image);
     } else {
-	qWarning() << "no pixmap";
+	qWarning() << "null image";
     }
 }
 

Index: test-poppler-qt4.cpp
===================================================================
RCS file: /cvs/poppler/poppler/qt4/tests/test-poppler-qt4.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- test-poppler-qt4.cpp	13 May 2006 15:58:39 -0000	1.7
+++ test-poppler-qt4.cpp	15 Nov 2006 21:07:50 -0000	1.8
@@ -17,7 +17,7 @@
 private:
     void display();
     int m_currentPage;
-    QPixmap *pixmap;
+    QImage image;
     Poppler::Document *doc;
     bool useArthur;
 };
@@ -25,7 +25,6 @@
 PDFDisplay::PDFDisplay( Poppler::Document *d, bool arthur )
 {
     doc = d;
-    pixmap = 0;
     m_currentPage = 0;
     useArthur = arthur;
     display();
@@ -39,15 +38,14 @@
             if (useArthur)
             {
                 qDebug() << "Displaying page using Arthur backend: " << m_currentPage;
-                pixmap = new QPixmap(page->pageSize());
-                page->renderToPixmap(pixmap, 72.0, 72.0);
+                doc->setRenderBackend(Poppler::Document::ArthurBackend);
             }
             else
             {
                 qDebug() << "Displaying page using Splash backend: " << m_currentPage;
-                delete pixmap;
-                pixmap = page->splashRenderToPixmap();
+                doc->setRenderBackend(Poppler::Document::SplashBackend);
             }
+            image = page->renderToImage();
             update();
             delete page;
         }
@@ -59,16 +57,15 @@
 PDFDisplay::~PDFDisplay()
 {
     delete doc;
-    delete pixmap;
 }
 
 void PDFDisplay::paintEvent( QPaintEvent *e )
 {
     QPainter paint( this );                     // paint widget
-    if (pixmap) {
-	paint.drawPixmap(0, 0, *pixmap);
+    if (!image.isNull()) {
+	paint.drawImage(0, 0, image);
     } else {
-	qWarning() << "no pixmap";
+	qWarning() << "null image";
     }
 }
 



More information about the poppler mailing list