From: Jean-Baptiste Mardelle Date: Fri, 29 May 2009 23:30:13 +0000 (+0000) Subject: Use project aspect ratio for clip properties dialog thumbnail, fix problem with extra... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=3d3b92ae3aaa85e370b000cc4807773f3e1ba10e;p=kdenlive Use project aspect ratio for clip properties dialog thumbnail, fix problem with extracting video frames that have a not even width svn path=/trunk/kdenlive/; revision=3449 --- diff --git a/src/clipproperties.cpp b/src/clipproperties.cpp index 5b767fb0..adb51fa4 100644 --- a/src/clipproperties.cpp +++ b/src/clipproperties.cpp @@ -214,8 +214,9 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg m_view.clip_fps->setText(props.value("fps")); if (props.contains("aspect_ratio")) m_view.clip_ratio->setText(props.value("aspect_ratio")); - - QPixmap pix = m_clip->thumbProducer()->getImage(url, m_clip->getClipThumbFrame(), 240, 180); + int width = 180.0 * KdenliveSettings::project_display_ratio(); + if (width % 2 == 1) width++; + QPixmap pix = m_clip->thumbProducer()->getImage(url, m_clip->getClipThumbFrame(), width, 180); m_view.clip_thumb->setPixmap(pix); if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(AUDIOTAB); } else { diff --git a/src/dvdwizardvob.cpp b/src/dvdwizardvob.cpp index 071a574f..a0a90cd3 100644 --- a/src/dvdwizardvob.cpp +++ b/src/dvdwizardvob.cpp @@ -123,7 +123,9 @@ void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters) delete[] tmp; if (producer->is_blank() == false) { - pix = KThumb::getFrame(producer, 0, 60, 45); + int width = 45.0 * profile.dar(); + if (width % 2 == 1) width++; + pix = KThumb::getFrame(producer, 0, width, 45); item->setIcon(0, pix); int playTime = producer->get_playtime(); item->setText(1, Timecode::getStringTimecode(playTime, profile.fps())); @@ -183,7 +185,7 @@ void DvdWizardVob::changeFormat() delete[] tmp; if (producer->is_blank() == false) { - //pix = KThumb::getFrame(producer, 0, 180, 135); + //pix = KThumb::getFrame(producer, 0, 135 * profile.dar(), 135); //item->setIcon(0, pix); item->setText(1, Timecode::getStringTimecode(producer->get_playtime(), profile.fps())); } diff --git a/src/kthumb.cpp b/src/kthumb.cpp index a8ce5ca5..1b6d9767 100644 --- a/src/kthumb.cpp +++ b/src/kthumb.cpp @@ -272,11 +272,13 @@ QPixmap KThumb::extractImage(int frame, int width, int height) //static QPixmap KThumb::getImage(KUrl url, int frame, int width, int height) { - Mlt::Profile profile((char*) KdenliveSettings::current_profile().data()); + char *tmp = Render::decodedString(KdenliveSettings::current_profile()); + Mlt::Profile profile(tmp); + delete[] tmp; QPixmap pix(width, height); if (url.isEmpty()) return pix; - char *tmp = Render::decodedString(url.path()); + tmp = Render::decodedString(url.path()); //""); //Mlt::Producer producer(profile, "xml-string", tmp); Mlt::Producer *producer = new Mlt::Producer(profile, tmp); diff --git a/src/markerdialog.cpp b/src/markerdialog.cpp index 1994c6c8..7fd78843 100644 --- a/src/markerdialog.cpp +++ b/src/markerdialog.cpp @@ -53,8 +53,9 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons //char *tmp = doc.toString().toUtf8().data(); m_producer = new Mlt::Producer(*m_profile, "xml-string", doc.toString().toUtf8().data()); //delete[] tmp; - - QPixmap p((int)(100 * m_dar), 100); + int width = 100.0 * m_dar; + if (width % 2 == 1) width++; + QPixmap p(width, 100); QString colour = clip->getProperty("colour"); switch (m_clip->clipType()) { case VIDEO: @@ -64,7 +65,7 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons connect(this, SIGNAL(updateThumb()), m_previewTimer, SLOT(start())); case IMAGE: case TEXT: - p = KThumb::getFrame(m_producer, t.time().frames(m_fps), (int)(100 * m_dar), 100); + p = KThumb::getFrame(m_producer, t.time().frames(m_fps), width, 100); break; case COLOR: colour = colour.replace(0, 2, "#"); @@ -104,7 +105,9 @@ void MarkerDialog::slotUpdateThumb() { m_previewTimer->stop(); int pos = m_tc.getFrameCount(m_view.marker_position->text(), m_fps); - QPixmap p = KThumb::getFrame(m_producer, pos, (int)(100 * m_dar), 100); + int width = 100.0 * m_dar; + if (width % 2 == 1) width++; + QPixmap p = KThumb::getFrame(m_producer, pos, width, 100); if (!p.isNull()) m_view.clip_thumb->setPixmap(p); else kDebug() << "!!!!!!!!!!! ERROR CREATING THUMB"; } diff --git a/src/renderer.cpp b/src/renderer.cpp index 0ef31973..9698084d 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -269,7 +269,7 @@ QPixmap Render::extractFrame(int frame_position, int width, int height) if (width == -1) { width = renderWidth(); height = renderHeight(); - } + } else if (width % 2 == 1) width++; QPixmap pix(width, height); if (!m_mltProducer) { pix.fill(Qt::black);