- Posts: 20
- Joined: Mon Aug 13, 2018 7:10 pm
- Real Name: Simon Björk
I'm trying to convert the thumbnail data to a QPixMap, but without success. I see that OpenCV is used in the example files, but shouldn't I be able to use PySide for this?
Here's some example code that I expected to work:
Here's some example code that I expected to work:
- Code: Select all
import sys
from PySide import QtCore, QtGui
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.lab = QtGui.QLabel()
# Use for testing to see that everything works.
#self.img = QtGui.QImage("path/to/image.png")
self.img = QtGui.QImage()
img_data = self.get_img_data()
bytesarr = QtCore.QByteArray.fromBase64(img_data)
self.img.loadFromData(bytesarr, 'PNG')
pix = QtGui.QPixmap.fromImage(self.img)
self.lab.setPixmap(pix)
layout = QtGui.QVBoxLayout()
layout.addWidget(self.lab)
self.setLayout(layout)
def get_img_data(self):
# Get a Resolve object
# Update with your own code.
resolve = get_resolve()
pm = resolve.GetProjectManager()
proj = pm.GetCurrentProject()
tl = proj.GetCurrentTimeline()
# Clip under time indicator.
clip = tl.GetCurrentVideoItem()
if not clip:
print "No clip under time indicator."
return
thumb = tl.GetCurrentClipThumbnailImage()
thumb_data = thumb["data"]
return thumb_data
app = QtGui.QApplication(sys.argv)
ex = Example()
ex.show()
app.exec_()