+}
+
+QPixmap KThumb::extractImage(int frame, int width, int height) {
+ return getFrame(m_producer, frame, width, height);
+}
+
+//static
+QPixmap KThumb::getImage(KUrl url, int frame, int width, int height) {
+ Mlt::Profile profile((char*) KdenliveSettings::current_profile().data());
+ QPixmap pix(width, height);
+ if (url.isEmpty()) return pix;
+
+ char *tmp = Render::decodedString(url.path());
+ //"<westley><playlist><producer resource=\"" + url.path() + "\" /></playlist></westley>");
+ //Mlt::Producer producer(profile, "westley-xml", tmp);
+ Mlt::Producer *producer = new Mlt::Producer(profile, tmp);
+ delete[] tmp;
+
+ if (producer->is_blank()) {
+ pix.fill(Qt::black);
+ delete producer;
+ return pix;
+ }
+ pix = getFrame(producer, frame, width, height);
+ delete producer;
+ return pix;
+}
+
+//static
+/*
+QPixmap KThumb::getImage(QDomElement xml, int frame, int width, int height) {
+ Mlt::Profile profile((char*) KdenliveSettings::current_profile().data());
+ QPixmap pix(width, height);
+ QDomDocument doc;
+ QDomElement westley = doc.createElement("westley");
+ QDomElement play = doc.createElement("playlist");
+ doc.appendChild(westley);
+ westley.appendChild(play);
+ play.appendChild(doc.importNode(xml, true));
+ char *tmp = Render::decodedString(doc.toString());
+ Mlt::Producer producer(profile, "westley-xml", tmp);
+ delete[] tmp;
+
+ if (producer.is_blank()) {
+ pix.fill(Qt::black);
+ return pix;
+ }
+ return getFrame(producer, frame, width, height);
+}*/
+
+//static
+QPixmap KThumb::getFrame(Mlt::Producer *producer, int framepos, int width, int height) {
+ if (producer == NULL) {
+ QPixmap p(width, height);
+ p.fill(Qt::red);
+ return p;
+ }
+
+ producer->seek(framepos);
+ Mlt::Frame *frame = producer->get_frame();
+ if (!frame) {
+ kDebug() << "///// BROKEN FRAME";
+ QPixmap p(width, height);
+ p.fill(Qt::red);
+ return p;
+ }
+ mlt_image_format format = mlt_image_yuv422;
+ int frame_width = 0;
+ int frame_height = 0;
+ frame->set("normalised_height", height);
+ frame->set("normalised_width", width);
+ QPixmap pix(width, height);
+ uint8_t *data = frame->get_image(format, frame_width, frame_height, 0);
+ uint8_t *new_image = (uint8_t *)mlt_pool_alloc(frame_width * (frame_height + 1) * 4);
+ mlt_convert_yuv422_to_rgb24a((uint8_t *)data, new_image, frame_width * frame_height);
+
+ QImage image((uchar *)new_image, frame_width, frame_height, QImage::Format_ARGB32);