Save image to phone

How can we save an image to the user's phone? Say if the user is viewing a photo gallery, and they want to save one of the images into their own photo library. Is this possible with Corona?

Currently, the only way for Corona to save an image to the photo library is via the display.captureScreen() function. Please see the following API documentation...

http://developer.anscamobile.com/reference/index/displaycapturescreen

I'd also really like a way to save an image that is in the app to the users photo library. I have a small app I would like to make but it requires that the user can save an image that is bigger than what can be seen on screen, so capture screen wont work for me. I guess I could link to a web site with the image but that would not be as optimal.

borgb,

Out of interest, where are you getting this large image from?

In the documentation for display.captureScreen (http://developer.anscamobile.com/node/2467) it states this:
"Note: display.captureScreen doesn't work with most Android devices. [case #3332]"

I also saw on the release notes for build #622 this:
"Android: Added media.show() camera and photo library support. casenum: 361, 7916"

So does that mean that that this works on Android now?

jn19,

We used to have problems with display.captureScreen() on many Android devices, but that has been fixed. Looks like we forgot to update the documentation. Thanks for bringing that up to our attention.

And yes, we finally support the Android camera and photo library!!! This is our first revision of it on Android, so if you have any feedback about these features, then please feel free to tell us. Thanks!

ok, I will try it out. What would be much more useful is if display.save() could also save to the photo library, because it is rare that what we actually need to save is a screen capture.

It seems like Ansca should be able to do this with similar code as is used to save the screen capture?

Joshua:
It would be for a small app where the user could flip through images and download the one he wants to use for a background to his photo library. The reason i need larger images is because of the iPad and how it needs images to be larger than the screen so it dosent rescale the image when switching between landscape and portrait.

Regarding having display.save() save to the photo library, we've received that request before. Since you are able to specify the file name via that function, the tricky part is making sure it does not attempt to overwrite another file with the same name that it doesn't have write permission to. The display.captureScreen() function doesn't have this problem because it auto-names the file with a unique name.

That said, this feature is on our to-do list, but no plan on when we'll be implementing it yet.

How about we create a new function such as system.addFileToPhotoLibrary() which you would use like this...

local imageFileName = system.pathForFile("MyImage.jpg", system.DocumentsDirectory)
local photoLibraryFileName = system.addFileToPhotoLibrary(imageFileName)

That would be perfect for what I had in mind :)

Please please add this. Would be fantastic to have!

views:1947 update:2011/10/16 9:47:44
corona forums © 2003-2011