Skip to content

Make qimage_to_array() work on big endian #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 7, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/superqt/utils/_img_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import TYPE_CHECKING

from qtpy.QtGui import QImage
Expand Down Expand Up @@ -37,4 +38,8 @@
arr = np.frombuffer(b, np.uint8).reshape(h, w, c)

# reverse channel colors for numpy
return arr.take([2, 1, 0, 3], axis=2)
# On big endian we need to specify a different order
if sys.byteorder == "big":
return arr.take([1, 2, 3, 0], axis=2)

Check warning on line 43 in src/superqt/utils/_img_utils.py

View check run for this annotation

Codecov / codecov/patch

src/superqt/utils/_img_utils.py#L43

Added line #L43 was not covered by tests
else:
return arr.take([2, 1, 0, 3], axis=2)
Loading