Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Save Wallpaper Image to Camera Roll?
Started by TwistedLogic Aug 29 2013 04:11 PM

- - - - -
6 replies to this topic
wallpaper save camera roll
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

TwistedLogic

[GLOBAL: userInfoPane.html]
TwistedLogic
  • Observer

  • 7 posts
  • Corona SDK

Hey everyone,

 

I'm new to the forum and I'm in no way a coder, so please be gentle :)

 

I'm using Corona (obviously) and Kwik to build my apps.

 

I currently have a 'more' section in my apps that lets the user download wallpapers of the game for their iPad. I've managed to do this by simply setting up a button that takes you to the browser with the image loaded and you have to save it to the camera roll from there. Not the best solution but the only one I could figure out.

Now I've run into the problem (any will) with the new Apple requirements for kids apps and getting "parental permission or using a parental gate" if you have any buttons that leave the app (or in app purchases). So my solution won't work anymore.

 

Having it open in the app and taking a screen shot that saves to the camera roll works but then the image quality is horrible. Plus as we know, wallpapers on the iPad need to be square so when rotating it doesn't cut and distort the image.

 

Anyway, I'm hoping someone can tell me how or if I can... have the large square wallpaper image that is 'stored' in the app get downloaded and saved to camera roll on the click of the button?

 

Hoping someone can help!!

Cheers,

Warwick



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi Warwick,

I think putting these images (wallpapers) in the app would be a better solution. Then, using "media.save", you could save it to the photo lib. This would likely solve both issues you mention (low quality images, and Apple not wanting link out to external site).

 

http://docs.coronalabs.com/api/library/media/save.html

 

Hope this helps,

Brent Sorrentino



[TOPIC: post.html]
#3

TwistedLogic

[GLOBAL: userInfoPane.html]
TwistedLogic
  • Observer

  • 7 posts
  • Corona SDK

Hey Brent,

 

Thanks for the reply. That looks very promising, even to the point that I might be able to do it haha.

I'll give it a crack.

Thanks a lot of the help!

Cheers,

Warwick



[TOPIC: post.html]
#4

TwistedLogic

[GLOBAL: userInfoPane.html]
TwistedLogic
  • Observer

  • 7 posts
  • Corona SDK

Ok, so it wasn't as straight forward as I thought  :) figures.

I'm not sure if you are familiar with how Kwik works but it lets me do a lot of things without writing code myself.

Anyway, normally you setup an image to be a button, then add other elements within that button eg. add sound to play or reload or whatever.

I created my button and added an 'external code' element and pasted in the following code...

 

media.save( "world.jpg"system.ResourceDirectory )

 

The button does nothing  :(

What have I missed adding in? Any ideas?

Thanks for the help.

 

Warwick



[TOPIC: post.html]
#5

TwistedLogic

[GLOBAL: userInfoPane.html]
TwistedLogic
  • Observer

  • 7 posts
  • Corona SDK

So this is what I've got so far....
- A button that has the code    media.save( "abc.jpg", system.DocumentsDirectory )
- The images are in the build folder, same place as the .lua's

When I run the app in the Corona simulator I get the following error....

File: ...tedLogic/Documents/Kwik/Monkey_Spot/build/page_9.lua
Line: 740

ERROR: media.save() File ((null)) does not exist.

stack traceback:
   [C]: ?
   [C]: in function 'save'
   ...tedLogic/Documents/Kwik/Monkey_Spot/build/page_9.lua:740: in function 'but_savewp1'
   ...tedLogic/Documents/Kwik/Monkey_Spot/build/page_9.lua:591: in function <...tedLogic/Documents/Kwik/Monkey_Spot/build/page_9.lua:590>
   ?: in function <?:218>

I have no idea what I've done wrong... But it's not showing that anything has been saved (nothing in the Corona Terminal)
Feel like I'm so close to getting this to work... last thing to fix before I can submit it again.

Thanks for the help so far!
Cheers



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,904 posts
  • Enterprise

Can you post some code?



[TOPIC: post.html]
#7

TwistedLogic

[GLOBAL: userInfoPane.html]
TwistedLogic
  • Observer

  • 7 posts
  • Corona SDK

Well it's sorted now.

 

The problem was the system.DocumentsDirectory I didn't need it in there.

So it's working now and I submitted the app this morning. Fingers crossed there aren't any other issues.

Thanks for the help.

 

Cheers




[topic_controls]
[/topic_controls]