Improve cover images.
authorAkos Polster <polster@conmp2-42a162100.europe.nokia.com>
Fri, 19 Nov 2010 13:18:31 +0000 (14:18 +0100)
committerAkos Polster <polster@conmp2-42a162100.europe.nokia.com>
Fri, 19 Nov 2010 13:18:31 +0000 (14:18 +0100)
model/book.cpp
pkg/changelog

index c24d53f..56c88bc 100644 (file)
@@ -1,4 +1,5 @@
 #include <qtextdocument.h>  // Qt::escape is currently defined here...
+#include <QtGui>
 
 #include "book.h"
 #include "opshandler.h"
@@ -15,9 +16,20 @@ const int COVER_HEIGHT = 59;
 
 static QImage makeCover(const QString &path)
 {
-    return QImage(path).scaled(COVER_WIDTH, COVER_HEIGHT,
-        Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation).
-        scaled(COVER_WIDTH, COVER_HEIGHT, Qt::KeepAspectRatio);
+    QPixmap src = QPixmap(path).scaled(COVER_WIDTH, COVER_HEIGHT,
+        Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    QPixmap transparent(src.size());
+    transparent.fill(Qt::transparent);
+
+    QPainter p;
+    p.begin(&transparent);
+    p.setCompositionMode(QPainter::CompositionMode_Source);
+    p.drawPixmap((COVER_WIDTH - src.width()) / 2,
+                 (COVER_HEIGHT - src.height()) / 2, src);
+    p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+    p.end();
+
+    return transparent.toImage();
 }
 
 Book::Book(const QString &p, QObject *parent): QObject(parent), loaded(false)
@@ -511,7 +523,7 @@ bool Book::extractMetaData()
 {
     QStringList excludedExtensions;
     excludedExtensions << ".html" << ".xhtml" << ".xht" << ".htm" << ".gif"
-            << ".png" << ".css" << "*.ttf" << "mimetype";
+            << ".css" << "*.ttf" << "mimetype";
     return extract(excludedExtensions);
 }
 
index 4eeedd1..b5549c5 100644 (file)
@@ -4,6 +4,8 @@ dorian (0.3.9-1) unstable; urgency=low
   * Really delete current book [#6614]
   * Remove inactive items from Options menu on Symbian [#6606]
   * Fix Library window content scrolling [#6622]
+  * Allow PNG cover images
+  * Improve cover images
 
  -- Akos Polster <akos@pipacs.com>  Wed, 17 Nov 2010 02:00:00 +0100