Browse Source

Fix crash in image reader and ensure it actually works

CURA-9125
Jaime van Kessel 2 years ago
parent
commit
ddb3ed1693
2 changed files with 5 additions and 5 deletions
  1. 4 4
      plugins/ImageReader/ImageReader.py
  2. 1 1
      plugins/ImageReader/ImageReaderUI.py

+ 4 - 4
plugins/ImageReader/ImageReader.py

@@ -63,7 +63,7 @@ class ImageReader(MeshReader):
         aspect = height / width
 
         if img.width() < 2 or img.height() < 2:
-            img = img.scaled(width, height, Qt.IgnoreAspectRatio)
+            img = img.scaled(width, height, Qt.AspectRatioMode.IgnoreAspectRatio)
 
         height_from_base = max(height_from_base, 0)
         base_height = max(base_height, 0)
@@ -84,15 +84,15 @@ class ImageReader(MeshReader):
 
             width = int(max(round(width * scale_factor), 2))
             height = int(max(round(height * scale_factor), 2))
-            img = img.scaled(width, height, Qt.IgnoreAspectRatio)
+            img = img.scaled(width, height, Qt.AspectRatioMode.IgnoreAspectRatio)
 
         width_minus_one = width - 1
         height_minus_one = height - 1
 
         Job.yieldThread()
 
-        texel_width = 1.0 / (width_minus_one) * scale_vector.x
-        texel_height = 1.0 / (height_minus_one) * scale_vector.z
+        texel_width = 1.0 / width_minus_one * scale_vector.x
+        texel_height = 1.0 / height_minus_one * scale_vector.z
 
         height_data = numpy.zeros((height, width), dtype = numpy.float32)
 

+ 1 - 1
plugins/ImageReader/ImageReaderUI.py

@@ -85,7 +85,7 @@ class ImageReaderUI(QObject):
             Logger.log("d", "Creating ImageReader config UI")
             path = os.path.join(PluginRegistry.getInstance().getPluginPath("ImageReader"), "ConfigUI.qml")
             self._ui_view = Application.getInstance().createQmlComponent(path, {"manager": self})
-            self._ui_view.setFlags(self._ui_view.flags() & ~Qt.WindowCloseButtonHint & ~Qt.WindowMinimizeButtonHint & ~Qt.WindowMaximizeButtonHint)
+            self._ui_view.setFlags(self._ui_view.flags() & ~Qt.WindowType.WindowCloseButtonHint & ~Qt.WindowType.WindowMinimizeButtonHint & ~Qt.WindowType.WindowMaximizeButtonHint)
             self._disable_size_callbacks = False
 
     @pyqtSlot()