-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
[DisplayServer] Implement screen_get_pixel
method for LinuxBSD/X11, macOS and Windows.
#74087
Conversation
The |
584082c
to
184bd09
Compare
…acOS and Windows.
Thanks! My understanding would be that this feature could be used to fix #74048 properly? |
Love this method! |
HDC dc = GetDC(0); | ||
COLORREF col = GetPixel(dc, p.x, p.y); | ||
if (col != CLR_INVALID) { | ||
return Color(float(col & 0x000000FF) / 256.0, float((col & 0x0000FF00) >> 8) / 256.0, float((col & 0x00FF0000) >> 16) / 256.0, 1.0); | ||
} | ||
ReleaseDC(NULL, dc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we don't call ReleaseDC(...)
if the color is valid?
And why we don't check that GetDC(0)
is not NULL
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not wrong, window's style class uses CS_OWNDC flag, meaning the DC is unique and shared for all drawing operations.
screen_get_pixel
method for LinuxBSD/X11, macOS and Windows.
Adds function to get screen pixel color. A base for better
ColorPicker
eyedropper implementation.