Skip to content

Commit d4c186e

Browse files
committed
add dither control
1 parent 8fd7244 commit d4c186e

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

rct-graphics-helper/magick_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def write_to_cache(self, id, delete_previous=False, next_file=""):
2929

3030
# Quantizes the image using a palette
3131
def quantize(self, palette, amount):
32-
self.full_command += " -dither FloydSteinberg -define dither:diffusion-amount=" + str(amount) + "% -remap " + \
32+
self.full_command += " -dither FloydSteinberg "+(amount and " -define dither:diffusion-amount=" + str(amount) + "% -remap " or " ") + \
3333
self.__stringify_input(palette) + " -colorspace sRGB"
3434

3535
# Trims the image to the smallest possible size and outputs the offset difference

rct-graphics-helper/operators/render_operator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def finish():
7878
render_task_processor = RenderTaskProcessor(
7979
context, self.palette_manager)
8080

81+
82+
render_task_processor.renderer.set_dither(general_props.dithering_strength)
83+
8184
task = self.create_task(context)
8285

8386
render_task_processor.process(task, finish)

rct-graphics-helper/properties/general_properties.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ class GeneralProperties(bpy.types.PropertyGroup):
9494
description="Which color groups to dither to. Recolorables will be excluded from this palette when used to avoid conflicts.",
9595
size=len(defaults))
9696

97+
dithering_strength = bpy.props.IntProperty(
98+
name = "Dithering Strength",
99+
description = "Floyd-Steinberg error diffusion",
100+
default = 35,
101+
min = 1,
102+
max = 100
103+
)
104+
97105
render_mode = bpy.props.EnumProperty(
98106
name="Render Mode",
99107
items=(

rct-graphics-helper/rct_graphics_helper_panel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def draw(self, context):
8282
row = layout.row()
8383
row.separator()
8484

85+
row = layout.row()
86+
row.prop(properties,"dithering_strength")
87+
8588
row = layout.row()
8689
row.label("Dither Palette:")
8790

rct-graphics-helper/renderer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, context, palette_manager):
3838
self.context = context
3939

4040
self.magick_path = "magick"
41-
self.floyd_steinberg_diffusion = 5
41+
self.floyd_steinberg_diffusion = 35
4242

4343
self.palette_manager = palette_manager
4444

@@ -63,6 +63,9 @@ def __init__(self, context, palette_manager):
6363
bpy.app.handlers.render_complete.append(self._render_finished)
6464
bpy.app.handlers.render_cancel.append(self._render_reset)
6565

66+
def set_dither(self, percent):
67+
self.floyd_steinberg_diffusion = percent
68+
6669
# Render out the current scene
6770
def render(self, output_still, callback):
6871
self.render_finished_callback = callback

0 commit comments

Comments
 (0)