aboutsummaryrefslogtreecommitdiff
path: root/components/image.py
diff options
context:
space:
mode:
authorBrianna2017-06-15 23:21:34 -0400
committerGitHub2017-06-15 23:21:34 -0400
commitfc7ee6d8e5b5a96ec06918f9b5dd9310cdf814de (patch)
tree99fd013c1c87f6bb1d2ed22859b56b0bced081bc /components/image.py
parent02795503d09743b5225eed7e7b7112208dfc28d0 (diff)
parentee8031925fcd93d7bedceff6e98a06f3806426b3 (diff)
Redesigned preset UI + video & image component scaling/positioning
Added preset manager
Diffstat (limited to 'components/image.py')
-rw-r--r--components/image.py40
1 files changed, 34 insertions, 6 deletions
diff --git a/components/image.py b/components/image.py
index f9a92ca..b6aa29b 100644
--- a/components/image.py
+++ b/components/image.py
@@ -6,6 +6,9 @@ from . import __base__
class Component(__base__.Component):
'''Image'''
+
+ modified = QtCore.pyqtSignal(int, dict)
+
def widget(self, parent):
self.parent = parent
self.settings = parent.settings
@@ -17,15 +20,25 @@ class Component(__base__.Component):
page.lineEdit_image.textChanged.connect(self.update)
page.pushButton_image.clicked.connect(self.pickImage)
+ page.spinBox_scale.valueChanged.connect(self.update)
+ page.checkBox_stretch.stateChanged.connect(self.update)
+ page.spinBox_x.valueChanged.connect(self.update)
+ page.spinBox_y.valueChanged.connect(self.update)
self.page = page
return page
def update(self):
self.imagePath = self.page.lineEdit_image.text()
+ self.scale = self.page.spinBox_scale.value()
+ self.xPosition = self.page.spinBox_x.value()
+ self.yPosition = self.page.spinBox_y.value()
+ self.stretched = self.page.checkBox_stretch.isChecked()
self.parent.drawPreview()
+ super().update()
def previewRender(self, previewWorker):
+ self.imageFormats = previewWorker.core.imageFormats
width = int(previewWorker.core.settings.value('outputWidth'))
height = int(previewWorker.core.settings.value('outputHeight'))
return self.drawFrame(width, height)
@@ -40,27 +53,42 @@ class Component(__base__.Component):
return self.drawFrame(width, height)
def drawFrame(self, width, height):
- frame = Image.new("RGBA", (width, height), (0, 0, 0, 0))
+ frame = self.blankFrame(width, height)
if self.imagePath and os.path.exists(self.imagePath):
image = Image.open(self.imagePath)
- if image.size != (width, height):
+ if self.stretched and image.size != (width, height):
image = image.resize((width, height), Image.ANTIALIAS)
- frame.paste(image)
+ if self.scale != 100:
+ newHeight = int((image.height / 100) * self.scale)
+ newWidth = int((image.width / 100) * self.scale)
+ image = image.resize((newWidth, newHeight), Image.ANTIALIAS)
+ frame.paste(image, box=(self.xPosition, self.yPosition))
return frame
- def loadPreset(self, pr):
+ def loadPreset(self, pr, presetName=None):
+ super().loadPreset(pr, presetName)
self.page.lineEdit_image.setText(pr['image'])
+ self.page.spinBox_scale.setValue(pr['scale'])
+ self.page.spinBox_x.setValue(pr['x'])
+ self.page.spinBox_y.setValue(pr['y'])
+ self.page.checkBox_stretch.setChecked(pr['stretched'])
def savePreset(self):
return {
+ 'preset': self.currentPreset,
'image': self.imagePath,
+ 'scale': self.scale,
+ 'stretched': self.stretched,
+ 'x': self.xPosition,
+ 'y': self.yPosition,
}
def pickImage(self):
imgDir = self.settings.value("backgroundDir", os.path.expanduser("~"))
filename = QtGui.QFileDialog.getOpenFileName(
- self.page, "Choose Image", imgDir, "Image Files (*.jpg *.png)")
- if filename:
+ self.page, "Choose Image", imgDir,
+ "Image Files (%s)" % " ".join(self.imageFormats))
+ if filename:
self.settings.setValue("backgroundDir", os.path.dirname(filename))
self.page.lineEdit_image.setText(filename)
self.update()