mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 08:17:49 -06:00
Add some options to CreateThumbnail to allow for some customisation over the format of the begin block for the image
This commit is contained in:
parent
9351096803
commit
df9862b866
1 changed files with 22 additions and 3 deletions
|
@ -35,16 +35,21 @@ class CreateThumbnail(Script):
|
||||||
def _convertSnapshotToGcode(self, encoded_snapshot, width, height, chunk_size=78):
|
def _convertSnapshotToGcode(self, encoded_snapshot, width, height, chunk_size=78):
|
||||||
gcode = []
|
gcode = []
|
||||||
|
|
||||||
|
use_thumbnail = self.getSettingValueByKey("use_thumbnail")
|
||||||
|
use_star = self.getSettingValueByKey("use_star")
|
||||||
|
|
||||||
encoded_snapshot_length = len(encoded_snapshot)
|
encoded_snapshot_length = len(encoded_snapshot)
|
||||||
|
image_type = "thumbnail" if use_thumbnail else "png"
|
||||||
|
resolution_symbol = '*' if use_star else 'x'
|
||||||
gcode.append(";")
|
gcode.append(";")
|
||||||
gcode.append("; thumbnail begin {}x{} {}".format(
|
gcode.append("; {} begin {}{}{} {}".format(
|
||||||
width, height, encoded_snapshot_length))
|
image_type, width, resolution_symbol, height, encoded_snapshot_length))
|
||||||
|
|
||||||
chunks = ["; {}".format(encoded_snapshot[i:i+chunk_size])
|
chunks = ["; {}".format(encoded_snapshot[i:i+chunk_size])
|
||||||
for i in range(0, len(encoded_snapshot), chunk_size)]
|
for i in range(0, len(encoded_snapshot), chunk_size)]
|
||||||
gcode.extend(chunks)
|
gcode.extend(chunks)
|
||||||
|
|
||||||
gcode.append("; thumbnail end")
|
gcode.append("; {} end".format(image_type))
|
||||||
gcode.append(";")
|
gcode.append(";")
|
||||||
gcode.append("")
|
gcode.append("")
|
||||||
|
|
||||||
|
@ -79,6 +84,20 @@ class CreateThumbnail(Script):
|
||||||
"minimum_value": "0",
|
"minimum_value": "0",
|
||||||
"minimum_value_warning": "12",
|
"minimum_value_warning": "12",
|
||||||
"maximum_value_warning": "600"
|
"maximum_value_warning": "600"
|
||||||
|
},
|
||||||
|
"use_thumbnail":
|
||||||
|
{
|
||||||
|
"label": "Thumbnail Begin/End",
|
||||||
|
"description": "Use Thumbnail Begin/End rather than PNG",
|
||||||
|
"type": "bool",
|
||||||
|
"default_value": true
|
||||||
|
},
|
||||||
|
"use_star":
|
||||||
|
{
|
||||||
|
"label": "xxx*yyy",
|
||||||
|
"description": "Use '*' instead of 'x' for size of image",
|
||||||
|
"type": "bool",
|
||||||
|
"default_value": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}"""
|
}"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue