m_audioThumbCreated = isDone;
}
-
-void DocClipBase::setThumbnail(const QPixmap & pixmap)
-{
- m_thumbnail = pixmap;
-}
-
-const QPixmap & DocClipBase::thumbnail() const
-{
- return m_thumbnail;
-}
-
void DocClipBase::updateAudioThumbnail(const audioByteArray& data)
{
//kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************";
m_thumbProd->extractImage(frames);
}
-QPixmap DocClipBase::extractImage(int frame, int width, int height)
+QImage DocClipBase::extractImage(int frame, int width, int height)
{
- if (m_thumbProd == NULL) return QPixmap(width, height);
+ if (m_thumbProd == NULL) return QImage();
QMutexLocker locker(&m_producerMutex);
- QPixmap p = m_thumbProd->extractImage(frame, width, height);
- return p;
+ return m_thumbProd->extractImage(frame, width, height);
}
* it uses it as part of it's own composition. */
bool referencesClip(DocClipBase * clip) const;
- /** Sets the thumbnail to be used by this clip */
- void setThumbnail(const QPixmap & pixmap);
-
/** Returns the thumbnail producer used by this clip */
KThumb *thumbProducer();
- /** Returns the thumbnail used by this clip */
- const QPixmap & thumbnail() const;
-
/** Cache for every audio Frame with 10 Bytes */
/** format is frame -> channel ->bytes */
QMap<int, QMap<int, QByteArray> > m_audioFrameCache;
bool hasAudioCodec(const QString &codec) const;
bool checkHash() const;
void setPlaceHolder(bool place);
- QPixmap extractImage(int frame, int width, int height);
+ QImage extractImage(int frame, int width, int height);
void clearThumbProducer();
void reloadThumbProducer();
void cleanupProducers();
/** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
QList < CommentedTime > m_snapMarkers;
-
- /** A thumbnail for this clip */
- QPixmap m_thumbnail;
GenTime m_duration;
KThumb *m_thumbProd;
return QPoint(video, audio);
}
-void KdenliveDoc::cachePixmap(const QString &fileId, const QPixmap &pix) const
+void KdenliveDoc::cacheImage(const QString &fileId, const QImage &img) const
{
- pix.save(m_projectFolder.path(KUrl::AddTrailingSlash) + "thumbs/" + fileId + ".png");
+ img.save(m_projectFolder.path(KUrl::AddTrailingSlash) + "thumbs/" + fileId + ".png");
}
bool KdenliveDoc::checkDocumentClips(QDomNodeList infoproducers)
* The returned duration might differ from the actual track duration!
* It is the one stored in the track's TrackInfo. */
int trackDuration(int ix);
-
- void cachePixmap(const QString &fileId, const QPixmap &pix) const;
+ void cacheImage(const QString &fileId, const QImage &img) const;
void setProjectFolder(KUrl url);
void setZone(int start, int end);
QPoint zone() const;
emit thumbReady(frame, img);
}
-QPixmap KThumb::extractImage(int frame, int width, int height)
+QImage KThumb::extractImage(int frame, int width, int height)
{
if (m_producer == NULL) {
- QPixmap p(width, height);
- p.fill(Qt::black);
- return p;
+ QImage img(width, height, QImage::Format_ARGB32_Premultiplied);
+ img.fill(Qt::black);
+ return img;
}
- QImage img = getProducerFrame(frame, (int) (height * m_ratio + 0.5), width, height);
- return QPixmap::fromImage(img);
+ return getProducerFrame(frame, (int) (height * m_ratio + 0.5), width, height);
}
//static
void clearProducer();
void updateThumbUrl(const QString &hash);
void extractImage(QList <int> frames);
- QPixmap extractImage(int frame, int width, int height);
+ QImage extractImage(int frame, int width, int height);
#if KDE_IS_VERSION(4,5,0)
/** @brief Request thumbnails for the frame range. */
void queryIntraThumbs(QList <int> missingFrames);
data.append(list.join(";").toUtf8());
mimeData->setData("kdenlive/clip", data);
drag->setMimeData(mimeData);
- QPixmap pix = m_currentClip->thumbnail();
+ /*QPixmap pix = m_currentClip->thumbnail();
drag->setPixmap(pix);
- drag->setHotSpot(QPoint(0, 50));
+ drag->setHotSpot(QPoint(0, 50));*/
drag->start(Qt::MoveAction);
//Qt::DropAction dropAction;
return;
}
QPixmap pix;
+ QImage img;
int height = m_listView->iconSize().height();
int swidth = (int)(height * m_render->frameRenderWidth() / m_render->renderHeight()+ 0.5);
int dwidth = (int)(height * m_render->dar() + 0.5);
if (clip->clipType() == AUDIO)
pix = KIcon("audio-x-generic").pixmap(QSize(dwidth, height));
else if (clip->clipType() == IMAGE)
- pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->getProducer(), 0, swidth, dwidth, height));
+ img = KThumb::getFrame(item->referencedClip()->getProducer(), 0, swidth, dwidth, height);
else {
- pix = item->referencedClip()->extractImage(frame, dwidth, height);
+ img = item->referencedClip()->extractImage(frame, dwidth, height);
}
- if (!pix.isNull()) {
+ if (!pix.isNull() || !img.isNull()) {
monitorItemEditing(false);
+ if (!img.isNull()) pix = QPixmap::fromImage(img);
it->setData(0, Qt::DecorationRole, pix);
monitorItemEditing(true);
- QString clipId = item->getClipHash();
- if (!clipId.isEmpty()) {
+ QString hash = item->getClipHash();
+ if (!hash.isEmpty() && !img.isNull()) {
if (!isSubItem)
- m_doc->cachePixmap(clipId, pix);
+ m_doc->cacheImage(hash, img);
else
- m_doc->cachePixmap(clipId + '#' + QString::number(frame), pix);
+ m_doc->cacheImage(hash + '#' + QString::number(frame), img);
}
}
if (update)
void ProjectList::slotReplyGetImage(const QString &clipId, const QImage &img)
{
- QPixmap pix = QPixmap::fromImage(img);
- setThumbnail(clipId, pix);
+ ProjectItem *item = getItemById(clipId);
+ if (item && !img.isNull()) {
+ QPixmap pix = QPixmap::fromImage(img);
+ monitorItemEditing(false);
+ item->setData(0, Qt::DecorationRole, pix);
+ monitorItemEditing(true);
+ QString hash = item->getClipHash();
+ if (!hash.isEmpty()) m_doc->cacheImage(hash, img);
+ }
}
void ProjectList::slotReplyGetImage(const QString &clipId, const QString &name, int width, int height)
{
- QPixmap pix = KIcon(name).pixmap(QSize(width, height));
- setThumbnail(clipId, pix);
-}
-
-void ProjectList::setThumbnail(const QString &clipId, const QPixmap &pix)
-{
+ // For clips that have a generic icon (like audio clips...)
ProjectItem *item = getItemById(clipId);
+ QPixmap pix = KIcon(name).pixmap(QSize(width, height));
if (item && !pix.isNull()) {
monitorItemEditing(false);
item->setData(0, Qt::DecorationRole, pix);
monitorItemEditing(true);
- //update();
- QString clipId = item->getClipHash();
- if (!clipId.isEmpty()) m_doc->cachePixmap(clipId, pix);
}
}
m_listView->scrollToItem(sub);
m_listView->editItem(sub, 1);
}
- QPixmap p = clip->referencedClip()->extractImage(in, (int)(sub->sizeHint(0).height() * m_render->dar()), sub->sizeHint(0).height() - 2);
- sub->setData(0, Qt::DecorationRole, p);
- QString clipId = clip->getClipHash();
- if (!clipId.isEmpty()) m_doc->cachePixmap(clipId + '#' + QString::number(in), p);
+ QImage img = clip->referencedClip()->extractImage(in, (int)(sub->sizeHint(0).height() * m_render->dar()), sub->sizeHint(0).height() - 2);
+ sub->setData(0, Qt::DecorationRole, QPixmap::fromImage(img));
+ QString hash = clip->getClipHash();
+ if (!hash.isEmpty()) m_doc->cacheImage(hash + '#' + QString::number(in), img);
monitorItemEditing(true);
}
emit projectModified();
/** @brief Process ffmpeg output to find out process progress. */
void processLogInfo(QList <ProjectItem *>items, int *duration, const QString &log);
void monitorItemEditing(bool enable);
- /** @brief Set thumbnail for a project's clip. */
- void setThumbnail(const QString &clipId, const QPixmap &pix);
/** @brief Get cached thumbnail for a project's clip or create it if no cache. */
void getCachedThumbnail(ProjectItem *item);
void getCachedThumbnail(SubProjectItem *item);