diff options
author | David Boddie <dboddie@trolltech.com> | 2009-11-24 15:22:19 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-11-24 15:22:19 (GMT) |
commit | 97aa8ad5ec6b5d23ad023518db92fa91d5fa7fe0 (patch) | |
tree | dd3645a6afc426a804e73df378c3d47906a8bcf9 /examples/webkit/framecapture/framecapture.cpp | |
parent | 8eea9828289b842c8a300f1f4309d059b15fd7b0 (diff) | |
parent | 792e43aa2607d21deeada4b9f14bb82dc96ad4ec (diff) | |
download | Qt-97aa8ad5ec6b5d23ad023518db92fa91d5fa7fe0.zip Qt-97aa8ad5ec6b5d23ad023518db92fa91d5fa7fe0.tar.gz Qt-97aa8ad5ec6b5d23ad023518db92fa91d5fa7fe0.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'examples/webkit/framecapture/framecapture.cpp')
-rw-r--r-- | examples/webkit/framecapture/framecapture.cpp | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/examples/webkit/framecapture/framecapture.cpp b/examples/webkit/framecapture/framecapture.cpp index 2c2e11b..ef49e93 100644 --- a/examples/webkit/framecapture/framecapture.cpp +++ b/examples/webkit/framecapture/framecapture.cpp @@ -59,6 +59,7 @@ void FrameCapture::load(const QUrl &url, const QString &outputFileName) m_page.mainFrame()->load(url); m_page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); m_page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + m_page.setViewportSize(QSize(1024, 768)); } void FrameCapture::printProgress(int percent) @@ -81,41 +82,36 @@ void FrameCapture::saveResult(bool ok) return; } - // save each internal frame in different image files - int frameCounter = 0; - foreach(QWebFrame *frame, m_page.mainFrame()->childFrames()) { - QString fileName(m_fileName); - int index = m_fileName.lastIndexOf('.'); - fileName = fileName.insert(index, "_frame" + QString::number(++frameCounter)); + // save each frame in different image files + saveFrame(m_page.mainFrame()); - frame->setClipRenderToViewport(false); + emit finished(); +} - QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied); - image.fill(Qt::transparent); +void FrameCapture::saveFrame(QWebFrame *frame) +{ + static int frameCounter = 0; - saveFrame(frame, image, fileName); + QString fileName(m_fileName); + if (frameCounter) { + int index = m_fileName.lastIndexOf('.'); + fileName = fileName.insert(index, "_frame" + QString::number(frameCounter)); } - // save the main frame - m_page.setViewportSize(m_page.mainFrame()->contentsSize()); - QImage image(m_page.mainFrame()->contentsSize(), QImage::Format_ARGB32_Premultiplied); + QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); - saveFrame(m_page.mainFrame(), image, m_fileName); - - emit finished(); -} -void FrameCapture::saveFrame(QWebFrame *frame, QImage image, QString fileName) -{ QPainter painter(&image); painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::TextAntialiasing, true); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); - - frame->render(&painter); - + frame->documentElement().render(&painter); painter.end(); image.save(fileName); + + ++frameCounter; + foreach(QWebFrame *childFrame, frame->childFrames()) + saveFrame(childFrame); } |