lkkd
May 17, 2016, 7:32pm
#1
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
screenShotImg.grabScreen(0,0,ofGetWindowWidth(),ofGetWindowHeight());
string fileName = “screenshot”+ofToString(10+snapCounter)+".png";
screenShotImg.saveImage(fileName);
string fileName = "screenshot/" + ofToString(10+snapCounter) + ".png";
ofSaveScreen(fileName);
lkkd
June 10, 2016, 7:14pm
#3
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?
Rancs
June 15, 2016, 9:45pm
#4
@lkkd Do you want to save the screen to the Android’s Screenshots gallery and generate a thumbnail for the Gallery app?
Rancs
June 15, 2016, 10:08pm
#5
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).
Rancs
June 15, 2016, 10:17pm
#6
Or do you want to save the screen to your ofDataDirectory and generate a thumbnail on the gallery app for it?
lkkd
June 15, 2016, 10:45pm
#7
Hi @Rancs
I want to save it in the screenshot gallery and generate a thumbnail.
Thanks!
Rancs
June 16, 2016, 2:04am
#8
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
https://github.com/noyanc/ofxAndroidScreenToGallery
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
lkkd
June 16, 2016, 3:40am
#9
Hey! cool, thats great!
I will try it in a bit i let you know.
Thanks!
lkkd
June 16, 2016, 4:57am
#10
Awesome ! i got the example running.
Thanks you very much !
lkkd
June 21, 2016, 4:59pm
#11
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?
Rancs
June 21, 2016, 10:46pm
#12
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.
lkkd
June 22, 2016, 12:38am
#13
Thanks!
Got it! but still having the same result.
Rancs
June 22, 2016, 12:55am
#14
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?
lkkd
June 22, 2016, 1:06am
#15
Really? i use setorientation()
how did you did it?
Rancs
June 22, 2016, 9:14am
#16
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.