Priority: P3: Somewhat important
Affects Version/s: 5.12.2
Fix Version/s: None
When using QImage.scanLine to access a QImage scanline by scanline, there's no way to cast that result to QRgb* to access it in a byte-order-independent manner like the C++ docs says:
Warning: If you are accessing 32-bpp image data, cast the returned pointer to QRgb* (QRgb has a 32-bit size) and use it to read/write the pixel value. You cannot use the uchar* pointer directly, because the pixel format depends on the byte order on the underlying platform. Use qRed(), qGreen(), qBlue(), and qAlpha() to access the pixels.
Would be good if there was some way to get a view of the bytes as an array of ints instead, that can be used with qRed(..), qGreen(..) et.c.
Bonus of course if it's still fast, since that's one of the points of using scanLine in the first place
To clarify, consider this C++ snippet:
Here's the "same" in Python:
And it prints.
This was just to illustrate the point. The result is obviously wrong, because the scan line has not been cast to an array of ints, it's still an array of bytes. One can access the individual bytes of course and take out the r,g,b components that way, but it's not portable as the byte-order is platform dependent.