吸管OS X,获胜 [英] Eyedropper OS X, win

查看:133
本文介绍了吸管OS X,获胜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!有人知道如何在没有透明窗口的情况下实施EyeDropper吗?

请建议。

如何防止丢失窗口的焦点?如何在OS X上从Screen获取像素。例如,在WinAPI上我可以使用GetPixel。



我使用的是c ++,Qt。



谢谢,非常匹配!!!!!



我的尝试:



在OS XI上尝试使用CGWindowListCreateImage,但它也抓住了光标。

我想在WinApi上我应该使用SetHook。

解决方案

编码应该类似于 Q& A on Stackoverflow



访问您获得的像素 cGBitmapContextGetData 。阅读有关API的更多信息。



为此,您需要在自己的上下文中绘制图像。

 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)];

// 此处您有像素访问权限
BYTE *数据= CGBitmapContextGetData(context); / * 4代表A,R,G,B * /
// 清理
UIGraphicsEndImageContext();


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.

解决方案

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.

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();


这篇关于吸管OS X,获胜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆