I needed to get something that would grab pixels below the OF app (ie, screen grab) for a student. this is my first attempt which wraps some cocoa code for that…
here’s a shot of it in action (showing the pixels directly below the OF app window in a texture):
I’ve uploaded the app - but to compile this code, you’ll need to compile for 10.5 and also, add the appkit framework.
the code is pretty simple. the .h file (with corresponding .m) exposes this function:
unsigned char * pixelsBelowWindow(int x, int y, int w, int h);
that returns BGRA array of pixels in the rectangle x,y,w,h. I manually convert that to RGBA for opengl uploading, but you can do what ever you want with those pixels – process them, manipulate them, etc.
I’ve noticed it work pretty well in some cases (ie, live updating in realtime on top of quicktime videos, etc), and flickers sometimes with things like youtube videos (which might be blitted to the screen in a different way?). give it a try and let me know. Also, it’s not thoroughly tested so it might be radically inefficient.