summaryrefslogtreecommitdiff
path: root/src/websnap.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-10-17 02:39:24 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-10-19 11:41:45 +0200
commit4d8d9d6e4eb149b46af315269e9578eb6bbfc241 (patch)
tree363308f6dc37c843b371ca95cde40b05e0033ecf /src/websnap.cpp
parentMerge commit 'refs/merge-requests/1842' of git://gitorious.org/rekonq/mainlin... (diff)
downloadrekonq-4d8d9d6e4eb149b46af315269e9578eb6bbfc241.tar.xz
STEP 1
creating a new Preview Image Object, based on QWidget and containing the pixmap AND the url
Diffstat (limited to 'src/websnap.cpp')
-rw-r--r--src/websnap.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/websnap.cpp b/src/websnap.cpp
index 577370ba..5727bc6f 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -95,24 +95,44 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h)
size = QSize(width,width*((0.0+h)/w));
page.setViewportSize(size);
}
-
- // create the target surface
- QPixmap image = QPixmap(size);
- image.fill(Qt::transparent);
-
- // render
- QPainter p(&image);
+
+ // create the page image
+ QImage pageImage = QImage(size, QImage::Format_ARGB32_Premultiplied);
+ pageImage.fill(Qt::transparent);
+ // render it
+ QPainter p(&pageImage);
page.mainFrame()->render(&p);
p.end();
- image = image.scaled(w, h, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
+ pageImage = pageImage.scaled(w, h, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
+ // background image
+ QSize fixedSize(w + 30, h + 26);
+ QImage backImage = QImage(fixedSize, QImage::Format_ARGB32_Premultiplied);
+ QString backImagePath = KStandardDirs::locate("appdata", "pics/bg.png");
+ backImage.load( backImagePath );
+
+ // create target
+ QImage resultImage = QImage(fixedSize, QImage::Format_ARGB32_Premultiplied);
+ resultImage.fill(Qt::transparent);
+
+ QPainter pt(&resultImage);
+ pt.setCompositionMode(QPainter::CompositionMode_Source);
+ pt.fillRect(resultImage.rect(), Qt::transparent);
+ pt.setCompositionMode(QPainter::CompositionMode_SourceOver);
+ pt.drawImage(0, 0, backImage);
+ pt.setCompositionMode(QPainter::CompositionMode_SourceOver);
+ pt.drawImage(15, 13, pageImage);
+ pt.setCompositionMode(QPainter::CompositionMode_DestinationOver);
+ pt.fillRect(resultImage.rect(), Qt::transparent);
+ pt.end();
+
// restore page settings
page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded);
page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded);
page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
- return image;
+ return QPixmap::fromImage(resultImage);
}