views:

11

answers:

1

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!

+3  A: 

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?)

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.

Peter Hosey
That's fantastic. You've opened up a whole new world for me :-)BTW - nice amount of detail. I had to go find out what you meant in certain cases, and I learnt a ton of new stuff while I was looking. Much better than copy/paste code fragments! Thanks!
Grant