From 490ba873ccceb8767e413f011f94f0c75e0541b3 Mon Sep 17 00:00:00 2001 From: Robert Rupa <40783144+RobertRupa@users.noreply.github.com> Date: Wed, 26 Feb 2025 03:55:01 +0100 Subject: [PATCH] Color image with better resolution Now Image is an PNG with better resolution and now model on printer LCD is in configured material color. Tested on Adventurer 4 --- plugins/GXWriter/GXWriter.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/GXWriter/GXWriter.py b/plugins/GXWriter/GXWriter.py index f2bd097..caa173b 100644 --- a/plugins/GXWriter/GXWriter.py +++ b/plugins/GXWriter/GXWriter.py @@ -104,18 +104,16 @@ def _parse_gcode_info(self, gx, gcode): def _createSnapshot(self, g, *args): Logger.log("i", "Creating thumbnail image ...") try: - # Convert the image to grayscale, and back to 24bits so it renders properly - # in printer. + # Convert the image to 24bits so it renders properly in printer. qt_format_ctx = QtGui.QImage.Format if qt_version == 6 else QtGui.QImage qt_openmode_ctx = QtCore.QIODeviceBase.OpenModeFlag if qt_version == 6 else QtCore.QIODevice - img = Snapshot.snapshot(width = 80, height = 60) - img = img.convertToFormat(qt_format_ctx.Format_Grayscale8) + img = Snapshot.snapshot(width = 320, height = 320) img = img.convertToFormat(qt_format_ctx.Format_RGB666) - # Converts the image into BMP byte array. + # Converts the image into PNG byte array. arr = QtCore.QByteArray() buff = QtCore.QBuffer(arr) buff.open(qt_openmode_ctx.WriteOnly) - img.save(buff, format="BMP") + img.save(buff, 'PNG') g.bmp = arr.data() except Exception: Logger.logException("w", "Failed to create snapshot image")