Titanium.Desktop.takeScreenshot throws error
If I use Titanium.Desktop.takeScreenshot with the same file more than once, it throws the error can't write file. Look's like this function doesn't free the file-ressource. Can someone reproduce this problem?
2 Answers
-
What do you mean by "with the same file"? Could you post the code you're using for folks to verify? (pastie.org)
-
Seems in win32 the file can't be opened in write mode after the screenshot is taken, so here's a workaround (the original write-locked file can be deleted after titanium exits):
var tmp = Titanium.Filesystem.createTempDirectory().toString() + Titanium.Filesystem.getSeparator() + "screenshot.png"; Titanium.Desktop.takeScreenshot(tmp); Titanium.Filesystem.asyncCopy(tmp, Titanium.Filesystem.getDesktopDirectory(), function(index, total){ alert("Screenshot should be here: " + index); });