[tracker] tracker-extract: Use black background for transparant album art



commit a5ceff37f8fc1a7e6b37fd836d7cd94546e1dc2f
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Oct 13 13:45:37 2011 +0200

    tracker-extract: Use black background for transparant album art
    
    Fixes NB#272997.

 src/tracker-extract/tracker-albumart-qt.cpp |   30 +++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/src/tracker-extract/tracker-albumart-qt.cpp b/src/tracker-extract/tracker-albumart-qt.cpp
index 00597d9..9c76714 100644
--- a/src/tracker-extract/tracker-albumart-qt.cpp
+++ b/src/tracker-extract/tracker-albumart-qt.cpp
@@ -26,6 +26,8 @@
 #include <QImageReader>
 #include <QImageWriter>
 #include <QApplication>
+#include <QColor>
+#include <QPainter>
 
 #include <glib.h>
 
@@ -77,10 +79,18 @@ tracker_albumart_file_to_jpeg (const gchar *filename,
 		return FALSE;
 	}
 
-	QImage image;
+	QImage image1;
+	image1 = reader.read ();
 
-	image = reader.read ();
-	image.save (QString (target), "jpeg");
+	if (image1.hasAlphaChannel ()) {
+		QImage image2 (image1.size(), QImage::Format_RGB32);
+		image2.fill (QColor(Qt::black).rgb());
+		QPainter painter (&image2);
+		painter.drawImage (0, 0, image1);
+		image2.save (QString (target), "jpeg");
+	} else {
+		image1.save (QString (target), "jpeg");
+	}
 
 	return TRUE;
 }
@@ -124,10 +134,18 @@ tracker_albumart_buffer_to_jpeg (const unsigned char *buffer,
 			return FALSE;
 		}
 
-		QImage image;
+		QImage image1;
+		image1 = reader->read ();
 
-		image = reader->read ();
-		image.save (QString (target), "jpeg");
+		if (image1.hasAlphaChannel ()) {
+			QImage image2 (image1.size(), QImage::Format_RGB32);
+			image2.fill (QColor(Qt::black).rgb());
+			QPainter painter (&image2);
+			painter.drawImage (0, 0, image1);
+			image2.save (QString (target), "jpeg");
+		} else {
+			image1.save (QString (target), "jpeg");
+		}
 
 		delete reader;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]