[poppler]
poppler/qt: poppler-page.cc, 1.10, 1.11 poppler-qt.h, 1.13, 1.14
Albert Astals Cid
aacid at freedesktop.org
Thu Jan 5 05:54:00 PST 2006
Update of /cvs/poppler/poppler/qt
In directory gabe:/tmp/cvs-serv8069/qt
Modified Files:
poppler-page.cc poppler-qt.h
Log Message:
Introduce variants of renderTo that return a QImage and do not use a QPixmap so threading is possible.
Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-page.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- poppler-page.cc 1 Jan 2006 22:18:47 -0000 1.10
+++ poppler-page.cc 5 Jan 2006 13:53:58 -0000 1.11
@@ -59,31 +59,37 @@
void Page::renderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres) const
{
+ QImage img = renderToImage(xres, yres);
+ *q = new QPixmap( img );
+}
+
+QImage Page::renderToImage(double xres, double yres) const
+{
SplashOutputDev *output_dev;
SplashBitmap *bitmap;
SplashColorPtr color_ptr;
output_dev = data->doc->data->getOutputDev();
-
+
data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, xres, yres,
0, false, false, false, -1, -1, -1, -1);
bitmap = output_dev->getBitmap ();
color_ptr = bitmap->getDataPtr ();
int bw = output_dev->getBitmap()->getWidth();
int bh = output_dev->getBitmap()->getHeight();
- QImage * img = new QImage( bw, bh, 32 );
+
+ QImage img( bw, bh, 32 );
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] ) );
+ img.setPixel( i, j, qRgb( pixel[0], pixel[1], pixel[2] ) );
}
}
delete[] pixel;
- *q = new QPixmap( *img );
-
- delete img;
+
+ return img;
}
QString Page::getText(const Rectangle &r) const
Index: poppler-qt.h
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-qt.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- poppler-qt.h 30 Dec 2005 22:31:32 -0000 1.13
+++ poppler-qt.h 5 Jan 2006 13:53:58 -0000 1.14
@@ -128,12 +128,32 @@
void renderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres) const;
/**
- * This is a convenience function that is equivalent to
- * renderToPixmap() with xres and yres set to 72.0. We keep it
- * only for binary compatibility
- **/
+ This is a convenience function that is equivalent to
+ renderToPixmap() with xres and yres set to 72.0. We keep it
+ only for binary compatibility
+
+ \sa renderToImage()
+ */
void renderToPixmap(QPixmap **q, int x, int y, int w, int h) const;
-
+
+ /**
+ \brief Render the page to a QImage using the Splash renderer
+
+ This method can be used to render the page to a QImage. It
+ uses the "Splash" rendering engine.
+
+ \param xres horizontal resolution of the graphics device,
+ in dots per inch (defaults to 72 dpi)
+
+ \param yres vertical resolution of the graphics device, in
+ dots per inch (defaults to 72 dpi)
+
+ \returns a QImage of the page.
+
+ \sa renderToPixmap()
+ */
+ QImage renderToImage(double xres = 72.0, double yres = 72.0) const;
+
/**
* Returns the size of the page in points
**/
More information about the poppler
mailing list