Commit 5b05452e authored by nextime's avatar nextime

Better options for color reduction

parent bea41aef
...@@ -1033,8 +1033,12 @@ class Gcode_tools(inkex.Effect): ...@@ -1033,8 +1033,12 @@ class Gcode_tools(inkex.Effect):
# dithering image and compile the pixels # dithering image and compile the pixels
if altcolorspace == 0: if altcolorspace == 0:
palette=list(set(img.convert("P", palette=Image.ADAPTIVE, colors=laserPower-1).getpalette())) palette=list(set(img.convert("P", palette=Image.ADAPTIVE, colors=laserPower-1).getpalette()))
elif altcolorspace <= 2:
palette=[0, 255]
else: else:
palette=list(set(img.convert("P", palette=Image.ADAPTIVE, colors=altcolorspace-1).getpalette())) palette=list(set(img.convert("P", palette=Image.ADAPTIVE, colors=altcolorspace-1).getpalette()))
maxp=max(palette)
palette = [n*255/maxp for n in palette]
inkex.errormsg("reduce colorspace to "+str(len(palette))+" colors palette...") inkex.errormsg("reduce colorspace to "+str(len(palette))+" colors palette...")
if altdither: if altdither:
inkex.errormsg("dithering enabled") inkex.errormsg("dithering enabled")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment