Skip to content

Commit

Permalink
Minor fix to ensure backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Molodos committed Mar 20, 2024
1 parent 68247c1 commit 72460e2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[4.3.1]
- Minor fix to ensure backwards compatibility

[4.3.0]
- Minor fixes on how snapshots for thumbnails are created
- Added support for Cura 5.7
Expand Down
2 changes: 1 addition & 1 deletion package_plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"display_name": "Elegoo Neptune Thumbnails",
"package_id": "ElegooNeptune3Thumbnails",
"package_type": "plugin",
"package_version": "4.3.0",
"package_version": "4.3.1",
"sdk_version": 8,
"sdk_version_semver": "8.0.0",
"website": "https://github.com/Molodos/ElegooNeptuneThumbnails"
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"email": "[email protected]",
"website": "https://github.com/Molodos"
},
"version": "4.3.0",
"version": "4.3.1",
"description": "Adds Elegoo Neptune printer thumbnail to G-code. Contains options to display parameters like estimated print time or model height on the thumbnail",
"supported_sdk_versions": [
"8.0.0",
Expand Down
18 changes: 16 additions & 2 deletions tools/thumbnail_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def generate_klipper_thumbnail_gcode(cls, slice_data: SliceData) -> str:
"""
Generate klipper thumbnail gcode for thumbnails in sizes 32x32 and 300x300
"""
small_icon: QImage = Snapshot.isometricSnapshot(width=32, height=32)
small_icon: QImage = cls._take_snapshot(width=32, height=32)
big_icon: QImage = cls._render_thumbnail(slice_data=slice_data, is_preview=False, add_background=False)
big_icon = big_icon.scaled(300, 300)
g_code: str = "\r"
Expand Down Expand Up @@ -153,7 +153,7 @@ def _render_thumbnail(cls, slice_data: SliceData, is_preview: bool = True, add_b
if not SettingsManager.get_settings().thumbnails_enabled and not SettingsManager.get_settings().klipper_thumbnails_enabled:
foreground = QImage(cls.NO_FOREGROUND_IMAGE_PATH)
elif SettingsManager.get_settings().use_current_model or not is_preview:
foreground = Snapshot.isometricSnapshot(width=600, height=600)
foreground = cls._take_snapshot(width=600, height=600)
else:
foreground = QImage(cls.FOREGROUND_IMAGE_PATH)

Expand Down Expand Up @@ -350,3 +350,17 @@ def _parse_thumbnail_b64jpg(cls, img: QImage, width: int, height: int, img_type:
Logger.log("d", "Exception == " + str(e))

return result + '\r'

@classmethod
def _take_snapshot(cls, width: int, height: int) -> QImage:
"""
Create a snapshot
:param width: Width of snapshot
:param height: Height of snapshot
:return: The snapshot
"""
try:
return Snapshot.isometricSnapshot(width=width, height=height)
except AttributeError:
# Fallback for older Cura versions
return Snapshot.snapshot(width=width, height=height)

0 comments on commit 72460e2

Please sign in to comment.