[poppler] poppler/qt4/src: poppler-page.cc,1.15,1.16

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Apr 4 14:01:03 PDT 2006


Update of /cvs/poppler/poppler/qt4/src
In directory kemper:/tmp/cvs-serv26801/qt4/src

Modified Files:
	poppler-page.cc 
Log Message:
        * splash/Splash.cc:
        * splash/SplashBitmap.cc: Make Splashbitmap RGB8 use 32bits internally
        * qt/poppler-page.cc:
        * qt4/src/poppler-page.cc: Adapt to splashbitmap change so copying to
        QImage is faster.
        Patch by Frank Meerkötter slightly modified by Albert Astals Cid

I'll leave adapting the glib frontend for you guys, i tried to adapt it but i got lost at gdk_pixbuf_get_n_channels (pixbuf);



Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-page.cc,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- poppler-page.cc	2 Apr 2006 18:07:59 -0000	1.15
+++ poppler-page.cc	4 Apr 2006 21:01:01 -0000	1.16
@@ -76,15 +76,12 @@
   //  QImage *img = new QImage( (uchar*)color_ptr, bw, bh, QImage::Format_RGB32 );
   // --------
 
-  QImage img( 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;
+  SplashColorPtr dataPtr = output_dev->getBitmap()->getDataPtr();
+  // construct a qimage SHARING the raw bitmap data in memory
+  QImage img( dataPtr, bw, bh, QImage::Format_RGB32 );
+  img = img.copy();
+  // unload underlying xpdf bitmap
+  output_dev->startPage( 0, NULL );
 
   return img;
 }



More information about the poppler mailing list