[poppler] poppler/qt4/src: poppler-page.cc, 1.6, 1.7 poppler-qt4.h,
1.10, 1.11
Albert Astals Cid
aacid at freedesktop.org
Mon Nov 28 14:50:22 PST 2005
Update of /cvs/poppler/poppler/qt4/src
In directory gabe:/tmp/cvs-serv21107/qt4/src
Modified Files:
poppler-page.cc poppler-qt4.h
Log Message:
Fix QPixmap contents generation messed when doing the xpdf 3.01 transition in qt4 frontend
Use Splash backend by default in the qt4 test, added -arthur option to use the Arthur backend
Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-page.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- poppler-page.cc 25 Nov 2005 22:52:56 -0000 1.6
+++ poppler-page.cc 28 Nov 2005 22:50:19 -0000 1.7
@@ -54,24 +54,49 @@
void Page::splashRenderToPixmap(QPixmap **q, int x, int y, int w, int h) const
{
- SplashOutputDev *output_dev;
+ splashRenderToPixmap(q, x, y, w, h, 72.0, 72.0);
+}
+
+void Page::splashRenderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres) const
+{
SplashColor white;
- SplashBitmap *bitmap;
white[0] = 255;
white[1] = 255;
white[2] = 255;
- SplashColorPtr color_ptr;
- output_dev = new SplashOutputDev(splashModeRGB8, 4, gFalse, white);
+ SplashOutputDev *output_dev = new SplashOutputDev(splashModeRGB8, 4, gFalse, white);
output_dev->startDoc(m_page->parentDoc->m_doc->doc.getXRef ());
- m_page->parentDoc->m_doc->doc.displayPageSlice(output_dev, m_page->index + 1, 72, 72,
- 0, false, true, false, -1, -1, -1, -1);
- bitmap = output_dev->getBitmap ();
- color_ptr = bitmap->getDataPtr ();
+ m_page->parentDoc->m_doc->doc.displayPageSlice(output_dev, m_page->index + 1, xres, yres,
+ 0, false, true, false, -1, -1, -1, -1);
+
+ SplashBitmap *bitmap = output_dev->getBitmap ();
+ int bw = bitmap->getWidth();
+ int bh = bitmap->getHeight();
+
+ // Produce a QImage and copy the image there pixel-by-pixel. This is
+ // quite slow and rather ugly, and the following two lines would be
+ // much nicer. But it does not work since the change to xpdf 3.01
+ // it's worth investigating
- QImage * img = new QImage( (uchar*)color_ptr, bitmap->getWidth(), bitmap->getHeight(), QImage::Format_RGB32 );
+ // --------
+ // SplashColorPtr color_ptr = bitmap->getDataPtr ();
+ // QImage *img = new QImage( (uchar*)color_ptr, bw, bh, QImage::Format_RGB32 );
+ // --------
+
+ QImage * img = new QImage( bw, bh, QImage::Format_RGB32 );
+ SplashColorPtr pixel = new Guchar[4];
+ for (int i = 0; i < bw; i++) {
+ for (int j = 0; j < bh; j++) {
+ output_dev->getBitmap()->getPixel(i, j, pixel);
+ img->setPixel( i, j, qRgb( pixel[0], pixel[1], pixel[2] ) );
+ }
+ }
+ delete[] pixel;
+
+ // Turn the QImage into a QPixmap
*q = new QPixmap(QPixmap::fromImage(*img));
-
+
+ // Delete temporary buffers
delete img;
delete output_dev;
}
Index: poppler-qt4.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-qt4.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- poppler-qt4.h 27 Nov 2005 01:33:51 -0000 1.10
+++ poppler-qt4.h 28 Nov 2005 22:50:19 -0000 1.11
@@ -124,16 +124,23 @@
~Page();
/**
- Render the page to a pixmap using the Splash renderer
- */
+ * Render the page to a pixmap using the Splash renderer
+ */
+ void splashRenderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres) const;
+
+ /**
+ * This is a convenience function that is equivalent to
+ * splashRenderToPixmap() with xres and yres set to 72.0. We keep it
+ * only for binary compatibility
+ */
void splashRenderToPixmap(QPixmap **q, int x, int y, int w, int h) const;
-
+
/**
Render the page to a pixmap using the Arthur (Qt4) renderer
-
+
\param q pointer to a QPixmap that is already set to the
intended size.
-
+
You are meant to create the pixmap before passing it to
this routine, using something like:
\code
More information about the poppler
mailing list