Taking screenshots on Android

Is it possible to take screenshots on Android?

What I want to achieve is:
- take a screenshot and save it (using the same code as in Sample.lua, but saving to user documents dir)
- then load/display it on demand

Everything seems to work fine, but I get a black picture when trying to display the saved screenshot.

Can you download the image back to your computer and verify whether it has proper content? If it has, then possible problem may be lack of support for non-power-of-two textures.

I know that non-power-of-two textures are not supported on my device.

EDIT: you’re right, this might be a non-power-of-two issue (image size is 1024x564 for a 1024x600 device, I think that bottom black bar is cropped from screenshot).

Is there a way to ‘convert’ the screenshot to power-of-two?

There is the Image::Resize() function which can be used.

Resizing performed successfully, thanks for exposing PowerOfTwo functions to lua.
Unfortunately still black picture on Android.

Here is the code used:

		local screenshot = Image()
		graphics:TakeScreenShot(screenshot)
		screenshot:Resize(NextPowerOfTwo(screenshot.width), NextPowerOfTwo(screenshot.height)) -- 'Convert' to power-of-two
		screenshot:SavePNG(fileSystem:GetUserDocumentsDir() .. "Screenshot.png")