-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix ImagingAccess for I;16N on big-endian #7921
Conversation
Looks like the issue with |
Why you feel I would think we are already testing this at Pillow/Tests/test_image_access.py Lines 186 to 192 in d31148b
|
Because I didn't know that test existed. It looks like it will work with all of the modes though, so I'll update that instead. |
I recognise this is relatively minor, but I would rather not add pixel size to Tests/helper.py just for use in a single test. |
It can be used for more tests in the future. I'm trying to keep my pull requests small so they actually get merged in a reasonable time frame. |
Such as? Apart from the scenario where a user manually constructs data for I would rather think of the test suite as testing the inputs and outputs of Pillow, and not containing data specific to our internals that most users don't need to know. |
I don't see an alternative. We need to know the pixel size of each mode for this test, so the pixel sizes need to be included in the list of mode names. There could be a separate list just for this test, but that defeats the point of having a common list of modes, and there would need to be another check that the two lists always have the same modes. |
I agree with @radarhere, let's not move it now just in case, we can move it later when we need to move it, which might never happen (re: https://wiki.c2.com/?YouArentGonnaNeedIt).
Yes, this is the way, thank you :) |
I thought of another way to do it. It's not efficient, but I suppose at least it's only being done in this one test. |
So it looks like when getting BGR 15/16 data the values are scaled to be 0-255, Pillow/src/libImaging/Access.c Lines 90 to 108 in 33a73b5
but when setting that data the values aren't scaled Lines 607 to 623 in 33a73b5
Though that doesn't explain why my original test passed. |
No wait, that can't be it, because this is only failing on big-endian. |
Does anyone know what the endianness of BGR;15 and BGR;16 is supposed to be? |
It seems like BGR;15 and BGR;16 are always treated as little-endian, which would explain why they're not working on a big-endian machine, but I haven't yet found a place where they're being treated as native-endian rather than explicitly little-endian. |
I added some logging in another branch and found some things. First, the original RGB Hopper pixel data for the failing pixel is On a little-endian machine I found this: The pixel values were changed a bit due to the RGB to BGR;15 conversions, but they're close enough. On a big-endian machine I found this: The pixel values are correct for that byte data, but the bytes are reversed. Also, the first bit (which is nothing in BGR;15) is set at the start, but not the end. |
All tests should be passing now. Some of the code was reading/writing RGB instead of BGR, and |
Should I rebase this, or can it be merged? |
I don't see any need to rebase - there's no merge conflict. If #7978 is merged, I'm not a fan of the BGR;* changes here, as I think introducing changes to BGR;* modes at the same time as deprecating them is not helpful. |
So, what, I have to wait until you finally remove the BGR modes before you'll accept this fix for I;16N? |
I wasn't suggesting that this wait until the deprecation period ended, only that this wait until the question of deprecation was resolved with #7978 being accepted or rejected. If you would like this to move ahead faster than that, then my suggestion would to be mark the BGR;* cases as failures for now - see Yay295#17. If #7978 is rejected, then the BGR;* changes here can be revisited. |
Rebased on main with a commit to ignore the BGR test failures instead of the commits to fix them. |
I found that BGR;16 doesn't actually fail, and have created Yay295#18 |
Fix ImagingAccess for I;16N on big-endian
Also changed the image mode info to use a
NamedTuple
.The test currently fails for
BGR;15
andBGR;16
.