views:

323

answers:

2

Hi,

I'm using OpenGL to grab the contents of the Mac OSX screen - thsi works very well, except it does not grab the mouse cursor graphic. I need to somewhow get that cursor graphic, either as part of my screen capture routine, or separately.

My question is either:

  • How can I ensure that the mouse cursor image is included with the OpenGL screen grab?

or

  • How can I get the current mouse cursor image as a simple RGBA bitmap?

I'm developing under Mac OSX 10.6, using C++ / Carbon.

Cheers,

+2  A: 

You can use I/O Kit to read the pixels for the current cursor. See IOFramebufferShared.h and IOGraphicsLib.h for some of the relevant API.

Peter Hosey
Thomi
This should get you started: https://bitbucket.org/boredzo/mouseflashlight/src/tip/NSCursor+PRHCurrentGlobalCursor.h https://bitbucket.org/boredzo/mouseflashlight/src/tip/NSCursor+PRHCurrentGlobalCursor.m The missing piece is that it doesn't actually copy the pixels; for that app, just the size and hot spot were enough.
Peter Hosey
A: 

Hi Peter,

Can u provide some sample code for capture mouse cursor with screen

Amit Gupta
Hi, Amit. I think you should post this question as a comment under Peter's answer rather than as an answer under Thomi's question.
Adrian Lopez
Hi,Adrian. Can u provide some sample code
Amit Gupta