screen grab on iPhone


I’m trying to get a screenGrab of an ofxiPhone app and save it to the iphone photo library.

I have tried to use the ofImage with the grabScreen and saveImage methods but it doesn’t seems to work.

How should I do it ?

Thank you


haven’t tried it myself, but have you tried…

[quote author=“ofxiPhoneExtras.h”]// save current opengl screen to photos app
// based on code from
void ofxiPhoneScreenGrab(id delegate);[/quote]

this seems to do it:

ofxiPhoneAppDelegate * delegate = ofxiPhoneGetAppDelegate();  

so in the touchdown, for example:

void testApp::touchDown(ofTouchEventArgs &touch){  
if (touch.x>0 && touch.x<50 && touch.y>0 && touch.y<50){  
        ofxiPhoneAppDelegate * delegate = ofxiPhoneGetAppDelegate();  

will make screenshot if you tap in the top left corner.

from what I remember, you don’t even need to pass in a delegate. Just pass NULL. the delegate is for when you want to be notified that the save is complete. For that you create an objective C class which has the method ‘saveComplete’ which gets called when the save is complete. See for more info.

is there any way to test this in the simulator or does it just work on the hardware?


Hey guys,

I just ran this inside void testApp::touchUp on my iPhone4 and it saves directly to my camera roll.

Just awesome! Now all I have to do is be able to upload to my server. -_-

Thanks for the code!