aboutsummaryrefslogtreecommitdiff
path: root/preview_thread.py
diff options
context:
space:
mode:
Diffstat (limited to 'preview_thread.py')
-rw-r--r--preview_thread.py79
1 files changed, 0 insertions, 79 deletions
diff --git a/preview_thread.py b/preview_thread.py
deleted file mode 100644
index 041d39e..0000000
--- a/preview_thread.py
+++ /dev/null
@@ -1,79 +0,0 @@
-from PyQt4 import QtCore, QtGui, uic
-from PyQt4.QtCore import pyqtSignal, pyqtSlot
-from PIL import Image, ImageDraw, ImageFont
-from PIL.ImageQt import ImageQt
-import core
-import time
-from queue import Queue, Empty
-import numpy
-
-class Worker(QtCore.QObject):
-
- imageCreated = pyqtSignal(['QImage'])
-
- def __init__(self, parent=None, queue=None):
- QtCore.QObject.__init__(self)
- parent.newTask.connect(self.createPreviewImage)
- parent.processTask.connect(self.process)
- self.core = core.Core()
- self.queue = queue
-
-
- @pyqtSlot(str, str, QtGui.QFont, int, int, int, int, tuple, tuple)
- def createPreviewImage(self, backgroundImage, titleText, titleFont, fontSize,\
- alignment, xOffset, yOffset, textColor, visColor):
- # print('worker thread id: {}'.format(QtCore.QThread.currentThreadId()))
- dic = {
- "backgroundImage": backgroundImage,
- "titleText": titleText,
- "titleFont": titleFont,
- "fontSize": fontSize,
- "alignment": alignment,
- "xoffset": xOffset,
- "yoffset": yOffset,
- "textColor" : textColor,
- "visColor" : visColor
- }
- self.queue.put(dic)
-
- @pyqtSlot()
- def process(self):
- try:
- nextPreviewInformation = self.queue.get(block=False)
- while self.queue.qsize() >= 2:
- try:
- self.queue.get(block=False)
- except Empty:
- continue
-
- bgImage = self.core.parseBaseImage(\
- nextPreviewInformation["backgroundImage"],
- preview=True
- )
- if bgImage == []:
- bgImage = ''
- else:
- bgImage = bgImage[0]
-
- im = self.core.drawBaseImage(
- bgImage,
- nextPreviewInformation["titleText"],
- nextPreviewInformation["titleFont"],
- nextPreviewInformation["fontSize"],
- nextPreviewInformation["alignment"],
- nextPreviewInformation["xoffset"],
- nextPreviewInformation["yoffset"],
- nextPreviewInformation["textColor"],
- nextPreviewInformation["visColor"])
- spectrum = numpy.fromfunction(lambda x: 0.008*(x-128)**2, (255,), dtype="int16")
-
- im = self.core.drawBars(spectrum, im, nextPreviewInformation["visColor"])
-
- self._image = ImageQt(im)
- self._previewImage = QtGui.QImage(self._image)
-
- self._scaledPreviewImage = self._previewImage.scaled(320, 180, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation)
-
- self.imageCreated.emit(self._scaledPreviewImage)
- except Empty:
- True