[webkit-qt] Javascript inside pixeldata of QImage

Youri Westerman youri at pluxcustoms.nl
Tue Mar 19 02:39:05 PDT 2013


Hi All,

Basically I do the same thing as the example here:
http://qt-project.org/doc/qt-4.8/qwebpage.html#details

But instead of saving the image to disk I'm planning on doing other
things with the data. Anycase when I retrieve the pixeldata from the
QImage object by calling bits() on it and then inspect that data, I
found that there is javascript code in there. So it seems to me that
there is something going with the render method of the QWebPage class
or something.

Anyone out there that can shine their light on this? I tried doing the
same thing with qt5, but unfortunately the javascript code inside the
webpage does not even get executed there.

-----------------------------------------------------------------------------------------------------------------------------------
page->setViewportSize(page->mainFrame()->contentsSize());
QImage im(page->viewportSize(), QImage::Format_ARGB32);
QPainter painter(&im);

page->mainFrame()->render(&painter);
painter.end();

const char * path = "/tmp/webkitimage/test2.img";

FILE * file = fopen(path, "w");

if(!file) {
	std::cout << "Could not open file to save image data to: " << path <<
std::endl;
	exit(-1);
}

std::cout << "Opened file to write image data to!" << std::endl;

uchar * imageData = im.bits();
fwrite(imageData, 1, im.byteCount(), file);
fclose(file);
--------------------------------------------------------------------------------------------------------------------------------

Page is an object of type QWebPage.

Thanks in advance for any pointers on how to resolve this.

-- 
Youri Westerman


More information about the webkit-qt mailing list