mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #1701 from pypeclub/feature/overscan_color_extract_review
Overscan color extract review
This commit is contained in:
commit
61f2e5a6e0
9 changed files with 115 additions and 29 deletions
|
|
@ -986,9 +986,21 @@ class ExtractReview(pyblish.api.InstancePlugin):
|
|||
output_width = output_def.get("width") or None
|
||||
output_height = output_def.get("height") or None
|
||||
|
||||
# Overscal color
|
||||
overscan_color_value = "black"
|
||||
overscan_color = output_def.get("overscan_color")
|
||||
if overscan_color:
|
||||
bg_red, bg_green, bg_blue, _ = overscan_color
|
||||
overscan_color_value = "#{0:0>2X}{1:0>2X}{2:0>2X}".format(
|
||||
bg_red, bg_green, bg_blue
|
||||
)
|
||||
self.log.debug("Overscan color: `{}`".format(overscan_color_value))
|
||||
|
||||
# Convert overscan value video filters
|
||||
overscan_crop = output_def.get("overscan_crop")
|
||||
overscan = OverscanCrop(input_width, input_height, overscan_crop)
|
||||
overscan = OverscanCrop(
|
||||
input_width, input_height, overscan_crop, overscan_color_value
|
||||
)
|
||||
overscan_crop_filters = overscan.video_filters()
|
||||
# Add overscan filters to filters if are any and modify input
|
||||
# resolution by it's values
|
||||
|
|
@ -1158,9 +1170,10 @@ class ExtractReview(pyblish.api.InstancePlugin):
|
|||
"scale={}x{}:flags=lanczos".format(
|
||||
width_scale, height_scale
|
||||
),
|
||||
"pad={}:{}:{}:{}:black".format(
|
||||
"pad={}:{}:{}:{}:{}".format(
|
||||
output_width, output_height,
|
||||
width_half_pad, height_half_pad
|
||||
width_half_pad, height_half_pad,
|
||||
overscan_color_value
|
||||
),
|
||||
"setsar=1"
|
||||
])
|
||||
|
|
@ -1707,12 +1720,15 @@ class OverscanCrop:
|
|||
item_regex = re.compile(r"([\+\-])?([0-9]+)(.+)?")
|
||||
relative_source_regex = re.compile(r"%([\+\-])")
|
||||
|
||||
def __init__(self, input_width, input_height, string_value):
|
||||
def __init__(
|
||||
self, input_width, input_height, string_value, overscal_color=None
|
||||
):
|
||||
# Make sure that is not None
|
||||
string_value = string_value or ""
|
||||
|
||||
self.input_width = input_width
|
||||
self.input_height = input_height
|
||||
self.overscal_color = overscal_color
|
||||
|
||||
width, height = self._convert_string_to_values(string_value)
|
||||
self._width_value = width
|
||||
|
|
@ -1767,16 +1783,22 @@ class OverscanCrop:
|
|||
|
||||
elif width >= self.input_width and height >= self.input_height:
|
||||
output.append(
|
||||
"pad={}:{}:(iw-ow)/2:(ih-oh)/2".format(width, height)
|
||||
"pad={}:{}:(iw-ow)/2:(ih-oh)/2:{}".format(
|
||||
width, height, self.overscal_color
|
||||
)
|
||||
)
|
||||
|
||||
elif width > self.input_width and height < self.input_height:
|
||||
output.append("crop=iw:{}".format(height))
|
||||
output.append("pad={}:ih:(iw-ow)/2:(ih-oh)/2".format(width))
|
||||
output.append("pad={}:ih:(iw-ow)/2:(ih-oh)/2:{}".format(
|
||||
width, self.overscal_color
|
||||
))
|
||||
|
||||
elif width < self.input_width and height > self.input_height:
|
||||
output.append("crop={}:ih".format(width))
|
||||
output.append("pad=iw:{}:(iw-ow)/2:(ih-oh)/2".format(height))
|
||||
output.append("pad=iw:{}:(iw-ow)/2:(ih-oh)/2:{}".format(
|
||||
height, self.overscal_color
|
||||
))
|
||||
|
||||
return output
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,12 @@
|
|||
]
|
||||
},
|
||||
"overscan_crop": "",
|
||||
"overscan_color": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
255
|
||||
],
|
||||
"width": 0,
|
||||
"height": 0,
|
||||
"bg_color": [
|
||||
|
|
|
|||
|
|
@ -12,6 +12,17 @@ class ColorEntity(InputEntity):
|
|||
def _item_initalization(self):
|
||||
self.valid_value_types = (list, )
|
||||
self.value_on_not_set = [0, 0, 0, 255]
|
||||
self.use_alpha = self.schema_data.get("use_alpha", True)
|
||||
|
||||
def set_override_state(self, *args, **kwargs):
|
||||
super(ColorEntity, self).set_override_state(*args, **kwargs)
|
||||
value = self._current_value
|
||||
if (
|
||||
not self.use_alpha
|
||||
and isinstance(value, list)
|
||||
and len(value) == 4
|
||||
):
|
||||
value[3] = 255
|
||||
|
||||
def convert_to_valid_type(self, value):
|
||||
"""Conversion to valid type.
|
||||
|
|
@ -51,4 +62,8 @@ class ColorEntity(InputEntity):
|
|||
).format(value)
|
||||
raise BaseInvalidValueType(reason, self.path)
|
||||
new_value.append(item)
|
||||
|
||||
# Make sure
|
||||
if not self.use_alpha:
|
||||
new_value[3] = 255
|
||||
return new_value
|
||||
|
|
|
|||
|
|
@ -182,6 +182,16 @@
|
|||
"key": "overscan_crop",
|
||||
"label": "Overscan crop"
|
||||
},
|
||||
{
|
||||
"type": "label",
|
||||
"label": "Overscan color is used when input aspect ratio is not same as output aspect ratio."
|
||||
},
|
||||
{
|
||||
"type": "color",
|
||||
"label": "Overscan color",
|
||||
"key": "overscan_color",
|
||||
"use_alpha": false
|
||||
},
|
||||
{
|
||||
"type": "label",
|
||||
"label": "Width and Height must be both set to higher value than 0 else source resolution is used."
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ class ColorWidget(InputWidget):
|
|||
self._dialog.open()
|
||||
return
|
||||
|
||||
dialog = ColorDialog(self.input_field.color(), self)
|
||||
dialog = ColorDialog(
|
||||
self.input_field.color(), self.entity.use_alpha, self
|
||||
)
|
||||
self._dialog = dialog
|
||||
|
||||
dialog.open()
|
||||
|
|
@ -120,12 +122,12 @@ class ColorViewer(QtWidgets.QWidget):
|
|||
|
||||
|
||||
class ColorDialog(QtWidgets.QDialog):
|
||||
def __init__(self, color=None, parent=None):
|
||||
def __init__(self, color=None, use_alpha=True, parent=None):
|
||||
super(ColorDialog, self).__init__(parent)
|
||||
|
||||
self.setWindowTitle("Color picker dialog")
|
||||
|
||||
picker_widget = ColorPickerWidget(color, self)
|
||||
picker_widget = ColorPickerWidget(color, use_alpha, self)
|
||||
|
||||
footer_widget = QtWidgets.QWidget(self)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,19 +17,12 @@ from .color_inputs import (
|
|||
class ColorPickerWidget(QtWidgets.QWidget):
|
||||
color_changed = QtCore.Signal(QtGui.QColor)
|
||||
|
||||
def __init__(self, color=None, parent=None):
|
||||
def __init__(self, color=None, use_alpha=True, parent=None):
|
||||
super(ColorPickerWidget, self).__init__(parent)
|
||||
|
||||
# Color triangle
|
||||
color_triangle = QtColorTriangle(self)
|
||||
|
||||
alpha_slider_proxy = QtWidgets.QWidget(self)
|
||||
alpha_slider = AlphaSlider(QtCore.Qt.Horizontal, alpha_slider_proxy)
|
||||
|
||||
alpha_slider_layout = QtWidgets.QHBoxLayout(alpha_slider_proxy)
|
||||
alpha_slider_layout.setContentsMargins(5, 5, 5, 5)
|
||||
alpha_slider_layout.addWidget(alpha_slider, 1)
|
||||
|
||||
# Eye picked widget
|
||||
pick_widget = PickScreenColorWidget()
|
||||
pick_widget.setMaximumHeight(50)
|
||||
|
|
@ -47,8 +40,6 @@ class ColorPickerWidget(QtWidgets.QWidget):
|
|||
color_view = ColorViewer(self)
|
||||
color_view.setMaximumHeight(50)
|
||||
|
||||
alpha_inputs = AlphaInputs(self)
|
||||
|
||||
color_inputs_color = QtGui.QColor()
|
||||
col_inputs_by_label = [
|
||||
("HEX", HEXInputs(color_inputs_color, self)),
|
||||
|
|
@ -58,6 +49,7 @@ class ColorPickerWidget(QtWidgets.QWidget):
|
|||
]
|
||||
|
||||
layout = QtWidgets.QGridLayout(self)
|
||||
|
||||
empty_col = 1
|
||||
label_col = empty_col + 1
|
||||
input_col = label_col + 1
|
||||
|
|
@ -65,6 +57,9 @@ class ColorPickerWidget(QtWidgets.QWidget):
|
|||
empty_widget.setFixedWidth(10)
|
||||
layout.addWidget(empty_widget, 0, empty_col)
|
||||
|
||||
layout.setColumnStretch(0, 1)
|
||||
layout.setColumnStretch(input_col, 1)
|
||||
|
||||
row = 0
|
||||
layout.addWidget(btn_pick_color, row, label_col)
|
||||
layout.addWidget(color_view, row, input_col)
|
||||
|
|
@ -84,20 +79,41 @@ class ColorPickerWidget(QtWidgets.QWidget):
|
|||
layout.setRowStretch(row, 1)
|
||||
row += 1
|
||||
|
||||
layout.addWidget(alpha_slider_proxy, row, 0)
|
||||
alpha_label = None
|
||||
alpha_slider_proxy = None
|
||||
alpha_slider = None
|
||||
alpha_inputs = None
|
||||
if not use_alpha:
|
||||
color.setAlpha(255)
|
||||
else:
|
||||
alpha_inputs = AlphaInputs(self)
|
||||
alpha_label = QtWidgets.QLabel("Alpha", self)
|
||||
alpha_slider_proxy = QtWidgets.QWidget(self)
|
||||
alpha_slider = AlphaSlider(
|
||||
QtCore.Qt.Horizontal, alpha_slider_proxy
|
||||
)
|
||||
|
||||
alpha_slider_layout = QtWidgets.QHBoxLayout(alpha_slider_proxy)
|
||||
alpha_slider_layout.setContentsMargins(5, 5, 5, 5)
|
||||
alpha_slider_layout.addWidget(alpha_slider, 1)
|
||||
|
||||
layout.addWidget(alpha_slider_proxy, row, 0)
|
||||
|
||||
layout.addWidget(alpha_label, row, label_col)
|
||||
layout.addWidget(alpha_inputs, row, input_col)
|
||||
|
||||
row += 1
|
||||
|
||||
layout.addWidget(QtWidgets.QLabel("Alpha", self), row, label_col)
|
||||
layout.addWidget(alpha_inputs, row, input_col)
|
||||
row += 1
|
||||
layout.setRowStretch(row, 1)
|
||||
|
||||
color_view.set_color(color_triangle.cur_color)
|
||||
|
||||
color_triangle.color_changed.connect(self.triangle_color_changed)
|
||||
alpha_slider.valueChanged.connect(self._on_alpha_slider_change)
|
||||
pick_widget.color_selected.connect(self.on_color_change)
|
||||
alpha_inputs.alpha_changed.connect(self._on_alpha_inputs_changed)
|
||||
btn_pick_color.released.connect(self.pick_color)
|
||||
if alpha_slider:
|
||||
alpha_slider.valueChanged.connect(self._on_alpha_slider_change)
|
||||
alpha_inputs.alpha_changed.connect(self._on_alpha_inputs_changed)
|
||||
|
||||
self.color_input_fields = color_input_fields
|
||||
self.color_inputs_color = color_inputs_color
|
||||
|
|
@ -131,7 +147,8 @@ class ColorPickerWidget(QtWidgets.QWidget):
|
|||
return self.color_view.color()
|
||||
|
||||
def set_color(self, color):
|
||||
self.alpha_inputs.set_alpha(color.alpha())
|
||||
if self.alpha_inputs:
|
||||
self.alpha_inputs.set_alpha(color.alpha())
|
||||
self.on_color_change(color)
|
||||
|
||||
def pick_color(self):
|
||||
|
|
@ -163,10 +180,10 @@ class ColorPickerWidget(QtWidgets.QWidget):
|
|||
|
||||
def alpha_changed(self, value):
|
||||
self.color_view.set_alpha(value)
|
||||
if self.alpha_slider.value() != value:
|
||||
if self.alpha_slider and self.alpha_slider.value() != value:
|
||||
self.alpha_slider.setValue(value)
|
||||
|
||||
if self.alpha_inputs.alpha_value != value:
|
||||
if self.alpha_inputs and self.alpha_inputs.alpha_value != value:
|
||||
self.alpha_inputs.set_alpha(value)
|
||||
|
||||
def _on_alpha_inputs_changed(self, value):
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ def draw_checkerboard_tile(piece_size=None, color_1=None, color_2=None):
|
|||
if piece_size is None:
|
||||
piece_size = 7
|
||||
|
||||
# Make sure piece size is not float
|
||||
piece_size = int(piece_size)
|
||||
if color_1 is None:
|
||||
color_1 = QtGui.QColor(188, 188, 188)
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 26 KiB |
|
|
@ -112,6 +112,10 @@ Profile may generate multiple outputs from a single input. Each output must defi
|
|||
| "-10% -200px" | 1800px 800px |
|
||||
| "-10% -0px" | 1800px 1000px |
|
||||
|
||||
- **`Overscan color`**
|
||||
- Color of empty area caused by different aspect ratio of input and output.
|
||||
- By default is set to black color.
|
||||
|
||||
- **`Letter Box`**
|
||||
- **Enabled** - Enable letter boxes
|
||||
- **Ratio** - Ratio of letter boxes
|
||||
|
|
@ -124,6 +128,14 @@ Profile may generate multiple outputs from a single input. Each output must defi
|
|||

|
||||

|
||||
|
||||
- **`Background color`**
|
||||
- Background color can be used for inputs with possible transparency (e.g. png sequence).
|
||||
- Input's without possible alpha channel are ignored all the time (e.g. mov).
|
||||
- Background color slows down rendering process.
|
||||
- set alpha to `0` to not use this option at all (in most of cases background stays black)
|
||||
- other than `0` alpha will draw color as background
|
||||
|
||||
|
||||
### IntegrateAssetNew
|
||||
|
||||
Saves information for all published subsets into DB, published assets are available for other hosts, tools and tasks after.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue