]> git.sesse.net Git - kdenlive/commitdiff
Small fix in thumbnail creation
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 26 Mar 2010 14:34:14 +0000 (14:34 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 26 Mar 2010 14:34:14 +0000 (14:34 +0000)
svn path=/trunk/kdenlive/; revision=4358

src/kthumb.cpp
src/projectlist.h
src/renderer.cpp

index dcbb27ce7f7a06768549ede2e0c604e822abe8e4..358e4223b13bee57001a185356221e2711048cc0 100644 (file)
@@ -194,8 +194,8 @@ void KThumb::extractImage(int frame, int frame2)
 
 void KThumb::doGetThumbs()
 {
-    const int twidth = (int)(KdenliveSettings::trackheight() * m_dar);
     const int theight = KdenliveSettings::trackheight();
+    const int twidth = (int)(theight * m_dar + 0.5);
 
     while (!m_requestedThumbs.isEmpty()) {
         int frame = m_requestedThumbs.takeFirst();
index 6ac386bee01fa672f053f40969da56199580dbe9..e9951fd8909da48cd4af9059043c23992fbc09c5 100644 (file)
@@ -82,7 +82,7 @@ public:
                 painter->setPen(option.palette.highlightedText().color());
             }
             const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
-            QPixmap pixmap = index.data(Qt::DecorationRole).value<QPixmap>();
+            QPixmap pixmap = qVariantValue<QPixmap>(index.data(Qt::DecorationRole));
             if ((index.flags() & (Qt::ItemIsDragEnabled)) == false) {
                 KIcon icon("dialog-close");
                 QPainter p(&pixmap);
@@ -90,8 +90,7 @@ public:
                 p.end();
             }
 
-            QPoint point(r1.left() + textMargin, r1.top() + (r1.height() - pixmap.height()) / 2);
-            painter->drawPixmap(point, pixmap);
+            painter->drawPixmap(r1.left() + textMargin, r1.top() + (r1.height() - pixmap.height()) / 2, pixmap);
             int decoWidth = pixmap.width() + 2 * textMargin;
 
             QFont font = painter->font();
index 6eb6b50c47258aef977a1027a37e4a3885f8f980..f90ecd364a0154c0c42a35da463556399832bb71 100644 (file)
@@ -357,7 +357,7 @@ char *Render::decodedString(QString str)
 */
 int Render::renderWidth() const
 {
-    return (int)(m_mltProfile->height() * m_mltProfile->dar());
+    return (int)(m_mltProfile->height() * m_mltProfile->dar() + 0.5);
 }
 
 int Render::renderHeight() const
@@ -608,7 +608,7 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
         char *tmp = decodedString("kdenlivetitle:" + xml.attribute("resource"));
         producer = new Mlt::Producer(*m_mltProfile, 0, tmp);
         delete[] tmp;
-        if (xml.hasAttribute("xmldata")) {
+        if (producer && xml.hasAttribute("xmldata")) {
             char *tmp = decodedString(xml.attribute("xmldata"));
             producer->set("xmldata", tmp);
             delete[] tmp;
@@ -682,7 +682,7 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
         return;
     }
 
-    int width = (int)(imageHeight  * m_mltProfile->dar());
+    int width = (int)(imageHeight * m_mltProfile->dar() + 0.5);
     QMap < QString, QString > filePropertyMap;
     QMap < QString, QString > metadataPropertyMap;
 
@@ -738,9 +738,9 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
             mlt_image_format format = mlt_image_rgb24a;
             int frame_width = width;
             int frame_height = imageHeight;
-            QPixmap pix(width, imageHeight);
             uint8_t *data = frame->get_image(format, frame_width, frame_height, 0);
             QImage image((uchar *)data, frame_width, frame_height, QImage::Format_ARGB32);
+            QPixmap pix(frame_width, frame_height);
 
             if (!image.isNull()) {
                 pix = QPixmap::fromImage(image.rgbSwapped());
@@ -755,7 +755,7 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
             filePropertyMap["type"] = "audio";
         }
     }
-
+    delete frame;
     // Retrieve audio / video codec name
 
     // If there is a
@@ -835,7 +835,6 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
     producer->seek(0);
     emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap, replaceProducer);
     kDebug() << "REquested fuile info for: " << url.path();
-    delete frame;
     // FIXME: should delete this to avoid a leak...
     //delete producer;
 }