是否可以将 CIBumpDistortion 过滤器注入到 Mac OS X (Snow Leopard) 上屏幕的特定区域?
我想使用 CIBumpDistortion 暂时扭曲鼠标下方的区域,以增加鼠标指针的可见性。
目前,我有一个透明背景的 NSWindow
,它漂浮在指针下方,并显示一个十字线,当您移动鼠标时该十字线会淡入,当您停止时该十字线会淡出。这工作正常,但凹凸扭曲会让我的应用很棒,而不是足够好。
我尝试使用 CGDisplayCaptureWithOptions(display, kCGCaptureNoFill) ,但这会降低性能并导致鼠标指针卡顿。
这是我想要实现的目标的图像。
请注意,我想要扭曲的区域不在我自己的 NSWindow 内,因此我认为我不能仅对 CIImage
应用转换并显示它(除非你们中的聪明人告诉我,您可以从屏幕的任意区域复制位图?)
提前致谢!
I want to temporarily distort the area under the mouse using a CIBumpDistortion
to increase the visibility of the mouse pointer.
At the moment, I have a transparent-background NSWindow
that floats around under the pointer and shows a cross-hair that fades in when you move the mouse, and out when you stop. This is working okay, but a Bump Distortion would make my app awesome instead of good enough.
I tried to use CGDisplayCaptureWithOptions(display, kCGCaptureNoFill)
, but that reduces the performance to a crawl and makes the mouse pointer stutter.
Here's an image of approximately what I'm trying to achieve.
Note, the area I want to distort is not inside my own NSWindow
, so I don't think I can just apply a transformation to a CIImage
and display that (unless one of you clever folks shows me that you can copy a bitmap from an arbitrary area of the screen?)
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以做!
获取窗口的
windowNumber
,并使用 CGWindowList 创建其下所有内容的 CGImage 屏幕截图。然后,从 CGImage 创建一个 CIImage,通过过滤器运行它,并将输出图像设置为窗口显示的图像。如果您仅在鼠标移动或屏幕在光标周围区域重绘时执行此操作(您可以为后者注册屏幕刷新回调),则可以非常有效地执行此操作。
Can do!
Get your window's
windowNumber
, and use CGWindowList to create a CGImage screenshot of everything under it. Then, create a CIImage from the CGImage, run it through the filter, and set the output image as what your window displays.Providing you only do this when the mouse moves or the screen redraws in the area around the cursor (you can register a screen refresh callback for the latter), you can do this quite effficiently.