Krita Source Code Documentation
Loading...
Searching...
No Matches
scaletool.py
Go to the documentation of this file.
1# SPDX-License-Identifier: CC0-1.0
2
3try:
4 from PyQt6.QtWidgets import (QWidget, QSpinBox,
5 QVBoxLayout, QFormLayout, QComboBox)
6except:
7 from PyQt5.QtWidgets import (QWidget, QSpinBox,
8 QVBoxLayout, QFormLayout, QComboBox)
9from builtins import i18n, i18nc
10
11class ScaleTool(QWidget):
12
13 def __init__(self, mainDialog, parent=None):
14 super(ScaleTool, self).__init__(parent)
15
16 self.setObjectName(i18n("Scale"))
17
18 self.layout = QFormLayout()
19 self.resolutionLayout = QVBoxLayout()
20 self.widthSpinBox = QSpinBox()
21 self.heightSpinBox = QSpinBox()
22 self.xResSpinBox = QSpinBox()
23 self.yResSpinBox = QSpinBox()
24 self.strategyComboBox = QComboBox()
25
26 self.strategyComboBox.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)
27 self.setLayout(self.layout)
28 self.initialize()
29
30 def initialize(self):
31 self.widthSpinBox.setRange(1, 10000)
32 self.heightSpinBox.setRange(1, 10000)
33 self.xResSpinBox.setRange(1, 10000)
34 self.yResSpinBox.setRange(1, 10000)
35
36 strategies = ['Hermite', 'Bicubic', 'Box',
37 'Bilinear', 'Bell', 'BSpline',
38 'Kanczos3', 'Mitchell']
39 self.strategyComboBox.addItems(strategies)
40
41 self.resolutionLayout.addWidget(self.xResSpinBox)
42 self.resolutionLayout.addWidget(self.yResSpinBox)
43
44 self.layout.addRow(i18n("Width:"), self.widthSpinBox)
45 self.layout.addRow(i18n("Height:"), self.heightSpinBox)
46 self.layout.addRow(i18n("Resolution:"), self.resolutionLayout)
47 self.layout.addRow(i18nc("Resize interpolation method list label", "Filter:"), self.strategyComboBox)
48
49 def adjust(self, documents):
50 for document in documents:
51 document.scaleImage(self.widthSpinBox.value(),
52 self.heightSpinBox.value(),
53 self.xResSpinBox.value(),
54 self.yResSpinBox.value(),
55 self.strategyComboBox.currentText())
float value(const T *src, size_t ch)
__init__(self, mainDialog, parent=None)
Definition scaletool.py:13