Просмотр исходного кода

Fix picking pixel on integer indices

The QImage.pixel() function should only get integers.
In theory an input position of -2,-2 would get rounded to 0 now. However that shouldn't occur because the user can't click outside of the window. And if it does occur, it's not really a problem either that it's theoretically picking a position inside of the window when you click slightly next to it.

Fixes #10785.
Karl Nilsson 3 лет назад
Родитель
Сommit
e0e227404f
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      cura/PickingPass.py

+ 2 - 2
cura/PickingPass.py

@@ -72,8 +72,8 @@ class PickingPass(RenderPass):
 
         window_size = self._renderer.getWindowSize()
 
-        px = (0.5 + x / 2.0) * window_size[0]
-        py = (0.5 + y / 2.0) * window_size[1]
+        px = int((0.5 + x / 2.0) * window_size[0])
+        py = int((0.5 + y / 2.0) * window_size[1])
 
         if px < 0 or px > (output.width() - 1) or py < 0 or py > (output.height() - 1):
             return -1