mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
![]() QImage's bytes are aligned to memory words per column of pixels. That means that one of these columns contains 99% valid image data, but with several bytes of unassigned noise at the end. How many of these padding bytes there are would depend on the image size, i.e. Cura's window size. In the end, the total number of bytes in the image ends up slightly more than w*h*3. As a result, Cura would crash because it couldn't reshape the image. Reshaping was completely unnecessary anyway, but this random noise was giving false positives also. But how do you then get only the actual pixels from each column of data? We can't just go iterating over this array, as that would be an iteration of thousands of columns which is prohibitively slow in Python. No, we're going to do some Numpy magic. We're going to create a class that pretends to be a Numpy array. Give this class some data and say that this data has a certain pixel size but also a certain STRIDE LENGTH. This stride length can be the length of the actual pixel data. As a result when Numpy sees this object it will read out the data using these strides, all done efficiently within the C code of Numpy. Framerate is fantastic on my computer. No problems at all. Pretty powerful computer though. But also a big 5k screen. Still no problem for Numpy. Seems to be decently efficient. Took me quite a while to figure all of this out. Contributes to issue CURA-7262. |
||
---|---|---|
.. | ||
__init__.py | ||
plugin.json | ||
SolidView.py | ||
xray_overlay.shader |