Skip to content
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 byte to float color conversion in DisplayServerWindows::screen_get_pixel #79350

Conversation

kleonc
Copy link
Member

@kleonc kleonc commented Jul 11, 2023

255 should be mapped to 1.0, it was mapped to 255.0 / 256.0.

byte / 255.0 is how we convert in most places I think (e.g. in Color or Image).

Fixes #79348.

No incorrect conversion spotted for Linux / MacOS:

return Color(float(c.red) / 65535.0, float(c.green) / 65535.0, float(c.blue) / 65535.0, 1.0);

CGFloat components[4];
[color getRed:&components[0] green:&components[1] blue:&components[2] alpha:&components[3]];
return Color(components[0], components[1], components[2], components[3]);

@kleonc kleonc added bug platform:windows topic:core cherrypick:4.0 cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Jul 11, 2023
@kleonc kleonc added this to the 4.2 milestone Jul 11, 2023
@kleonc kleonc requested a review from a team as a code owner July 11, 2023 19:41
Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should divide by 255 as this PR does.

platform/windows/display_server_windows.cpp Outdated Show resolved Hide resolved
@kleonc kleonc force-pushed the screen_to_pixel_byte_to_float_conversion_fix branch from 1cf4881 to 9d45dd8 Compare July 12, 2023 19:31
@YuriSizov YuriSizov merged commit 88c1e0d into godotengine:master Jul 21, 2023
13 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

@kleonc kleonc deleted the screen_to_pixel_byte_to_float_conversion_fix branch July 21, 2023 17:05
@YuriSizov
Copy link
Contributor

Cherry-picked for 4.1.2.

@YuriSizov YuriSizov removed the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Color Picker Eyedropper does not pick the same Color as getting the Color from the image data
4 participants