Saving/Opening Pictures

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jrarickGAec4d
Posts: 4
Joined: Mon Dec 05, 2011 5:32 pm

Saving/Opening Pictures

Post by jrarickGAec4d » Wed Dec 07, 2011 2:43 pm

I THINK I understand the nature of the "sandbox". But does that extend to the "Camera Roll"?

1) I need to be able to take a picture of a student/athlete and save it SOMEWHERE, keeping track of it's name and location.

2) I need to be able to open a card and display the student's picture.

Here are my questions:

A) Can I save a picture anywhere else but the camera roll? How? (And am I able to know the name of the picture that is saved?)

B) Once a picture is saved to a folder (and I have kept track of it's name and location), can I use the name of the picture and display it again on a different card? How?

Thank you all in advance.

Jack Rarick
Coach's Video Assistant

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Saving/Opening Pictures

Post by Mark » Wed Dec 07, 2011 3:32 pm

Hi Jack,

You can save a picture in the documents folder of your app. If you have some kind of a database in you app (this could be a simple text file even) then you can just store the file name with the student name/id.

One way to save a picture is to export an image object to a variable, e.g.

Code: Select all

export img x to myVar as PNG
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: Saving/Opening Pictures

Post by tzenobite » Fri Dec 09, 2011 5:31 pm

hi, i have a similar question: if i make a stack as a sort of photo album, how i can let the user choose an image and copy it to the camera roll? i guess i have to use some ios command to do this
thanks in advance
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Saving/Opening Pictures

Post by bn » Fri Dec 09, 2011 6:49 pm

Hi tzenobite,

from the iOS Release Notes under the Help Menu:
Saving photos to the users album
You can save an image to the user's photo album by using:
iphoneExportImageToAlbum imageTextOrControl Where imageTextOrControl is one of:
• the binary data of an image (the 'text') in PNG, GIF or JPEG format
• a long id of an image object containing an image in PNG, GIF or JPEG format The command will return empty in the result if exporting succeeded. Otherwise it will return one
of:
• could not find image – the image object could not be found • not an image – the object was not an image • not a supported format – the image object in not of PNG, GIF or JPEG format • export failed – an error occurred while trying to save the image to the album
If the device has a camera, the image is saved to the Camera Roll, other wise it is saved to the Saved Photos album.
Note: When running in the simulator, there needs to be at least one image in the photo album for exporting to succeed. You can add images to the photo album in a simulator by dragging an image on the simulator window, and saving the image to album from Safari (click and hold on the image to bring up an alert with the option).
You may want to have a look at those iOS Release Notes.

Kind regards

Bernd

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: Saving/Opening Pictures

Post by tzenobite » Fri Dec 09, 2011 8:52 pm

many thanks!
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

Post Reply