Levels tool point pickers don't work correctly when "sample merged" is selected
Environment/Versions
- GIMP version: 2.10.22 - 2.10.36
- Package: Installer from gimp.org
- Operating System: Windows 10 22H2
Description of the bug
The issue occurs when using the "pick black point", "pick white point" or any of the other pickers on this menu. I will mostly refer to the black point, but it also happens with the others. After clicking the point in the image, the correct value will briefly be selected, but then it'll be reset to default. On the down-click it selects the value sampled from the image, then upon letting go of the left mouse button it'll reset.
Simplified example for testing:
Screenshots aren't very useful for this bug but here:
When the left mouse button is held, it'll show 33 as the black point, but when it's let go it goes back to 0.
Attempting to choose the "black" on the image as the white point has an interesting result too, notice the midpoint:
When testing with a real example, it doesn't quite reset to 0 (in the black point's case), it slowly goes up from 0 as you continue clicking. White point slowly goes down. Neither seem like they'd overshoot the sampled value, they seem to approach it asymptotically.
Reproduction
Is the bug reproducible? Yes, I can reproduce it every time.
Reproduction steps:
- Open the simplified image (or any image where the black levels are easy to see)
- Duplicate the layer
- Open the levels tool
- Choose to pick the black point, make sure "sample merged" is checked.
- Try to pick the point on the image.
…
Expected result: The black point should be sampled from where I clicked on the image, resulting in 33.
Actual result: The black point picked is 0.
Additional information
So I wrote this issue based completely on the present 2.10.36, and then went back and checked every version for when this issue started happening, stopping at 2.10.22 because that's when the "sample merged" option was added. This has probably been an issue ever since the option was introduced. It doesn't quite make sense for the level operations to sample from the merged image, so a sensible choice could be to somehow disallow those two to be used together. Nevertheless it's still a bug and it happens even with images/layers without alpha channels (I stumbled upon it because the "sample merged" option was checked accidentally)