Screenshot save in the image gallery

Hi! i’m trying to to take a screenshot using ofsaveimage and then save it in to the image gallery of the phone but i don’t know how to access to that directory path some ones knows it?

This is the code so far

string fileName = “screenshot”+ofToString(10+snapCounter)+".png";

string fileName = "screenshot/" + ofToString(10+snapCounter) + ".png";

Isn’t working.
But the phone i’m using dosn’t have a sdcard maybe is trying to save it to the sdcard?
Do i have to specify where?

@lkkd Do you want to save the screen to the Android’s Screenshots gallery and generate a thumbnail for the Gallery app?

Or do you only need to get the path of the gallery? (with the path, you can save your screen to the pictures directory, but a thumbnail will not be generated automatically).

Or do you want to save the screen to your ofDataDirectory and generate a thumbnail on the gallery app for it?

Hi @Rancs
I want to save it in the screenshot gallery and generate a thumbnail.


Hey @lkkd,

I wrote a simple addon for that. I think it will do the job. Can you try it? You can find it at

ps. please note that I didn’t test the addon if no “pictures” or “pictures/screenshots” gallery available, because my own gallery is plenty with necessary images.

1 Like

Hey! cool, thats great!

I will try it in a bit i let you know.

Awesome ! i got the example running.
Thanks you very much !

Hi @Rancs ! Hope everything is going well.

I was trying the screenshot addon is working pretty well. I change the orientation in one view (OF_ORIENTATION_90_LEFT) and i got a glitch image looks like si trying to take the screenshot with vertical ratio you is there is a quick fix for this?

The screenshot is taken by oF’s core ofSaveScreen(path) method. There might be a bug in this method.

Can you try that please:
1- Comment out the line#66 of the ofxAndroidScreenToGallery.cpp:

// ofSaveScreen(screenshotfilepath);

2- Instead, add these lines:

ofImage screenshot;
screenshot.grabScreen(0, 0, ofGetWidth(), ofGetHeight());
ofSaveImage(screenshot.getPixelsRef(), screenshotfilepath, OF_IMAGE_QUALITY_BEST);

Hope that might be a quick solution for the issue.


Got it! but still having the same result.

I tested it now and it works here. There are no glitches. The screenshot orientation changing correctly when I turn the device.

Do you orientate the screen by ofSetOrientation() command or by automatic orientation?

Really? i use setorientation()
how did you did it?

You don’t need to do something special for the orientation. When you turn an Android device by hand, it automatically change the screen orientation.

works perfect, thanks!