Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there! Does someone know how to implement EyeDropper without a transparent window?
Please suggest.
How to prevent losing window's focus? How to get pixel from Screen on OS X. For example, on WinAPI I can use GetPixel.

I am using c++, Qt.

Thank you, very match !!!!!

What I have tried:

On OS X I tried to use CGWindowListCreateImage, but it also grabs cursor.
I suppose on WinApi I should use SetHook.
Posted
Updated 24-Apr-18 1:01am

1 solution

The coding should be similar than in that Q & A on Stackoverflow.

Access to the pixel you get with CGBitmapContextGetData. Read also for further information about the API.

For that you need to draw the image in an own context.
C++
UIGraphicsBeginImageContextWithOptions(rc.size, true, 1.0);
CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]);
CGContextFillRect(context, rc);

[image drawAtPoint:CGPointMake(-rc.origin.x, -rc.origin.y)];

// here you have pixel access
BYTE *data = CGBitmapContextGetData(context);/* 4 for A, R, G, B */
//clean up
UIGraphicsEndImageContext();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900