From 8846af57ba9635fe4a1c44778dc468f22277e538 Mon Sep 17 00:00:00 2001
From: tassaron
Date: Wed, 14 Jun 2017 19:37:47 -0400
Subject: image component stretch/scale/x/y options
---
components/image.py | 24 +++++++++++++++++--
components/image.ui | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++---
components/video.ui | 43 +++++++++++++++++++++++++++++----
3 files changed, 126 insertions(+), 9 deletions(-)
(limited to 'components')
diff --git a/components/image.py b/components/image.py
index cdf10c7..a2f0521 100644
--- a/components/image.py
+++ b/components/image.py
@@ -20,12 +20,20 @@ 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()
@@ -47,19 +55,31 @@ class Component(__base__.Component):
frame = Image.new("RGBA", (width, height), (0, 0, 0, 0))
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, 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):
diff --git a/components/image.ui b/components/image.ui
index 3cd5b1b..685e997 100644
--- a/components/image.ui
+++ b/components/image.ui
@@ -124,8 +124,11 @@
16777215
+
+ -10000
+
- 999999999
+ 10000
@@ -163,10 +166,10 @@
- 0
+ -1000
- 999999999
+ 1000
0
@@ -177,6 +180,65 @@
+ -
+
+
-
+
+
+ Stretch
+
+
+ false
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 5
+ 20
+
+
+
+
+ -
+
+
+ Scale
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+ QAbstractSpinBox::UpDownArrows
+
+
+ %
+
+
+ 10
+
+
+ 200
+
+
+ 100
+
+
+
+
+
-
diff --git a/components/video.ui b/components/video.ui
index 6a01368..aca46b4 100644
--- a/components/video.ui
+++ b/components/video.ui
@@ -111,7 +111,7 @@
-
-
+
0
@@ -124,8 +124,11 @@
16777215
+
+ -10000
+
- 999999999
+ 10000
@@ -163,10 +166,10 @@
- 0
+ -10000
- 999999999
+ 10000
0
@@ -202,6 +205,35 @@
+ -
+
+
+ Scale
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+ QAbstractSpinBox::UpDownArrows
+
+
+ %
+
+
+ 10
+
+
+ 200
+
+
+ 100
+
+
+
-
@@ -217,6 +249,9 @@
+ -
+
+
--
cgit v1.2.3