Capture Photo (templateimage) and Send Later

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Capture Photo (templateimage) and Send Later

Post by shoshinsha » Thu Oct 30, 2014 11:09 am

Hi Guys,

I am trying to build an app that allows user to capture photo via Camera or choose from Library, then send the photo thru email.
My problem is that the photo capturing is on card 1, and once the user proceeds to card 2, he/she will first key in some details (e.g. name, mobile), then only he/she will click the [Send] button to send the details together with the image.
Is there a way to "pass" the templateimage on card 1 to be sent on card 2?

Thanks in advance!

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Capture Photo (templateimage) and Send Later

Post by LCNeil » Thu Oct 30, 2014 11:23 am

Hi Shoshinsha,

You should be able to reference the image directly on your 1st card. For example if you have an image object on your second card, the syntax for setting its contents to the data of the image on the first card could be-

Code: Select all

set the text of image 1 of this card to the the text of image 1 of card 1
Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.runrev.com
--

shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Re: Capture Photo (templateimage) and Send Later

Post by shoshinsha » Fri Oct 31, 2014 4:28 am

Thanks Neil!
I'm able to do the image reference to the next card. But I could not get the image "attached" to the mail when using mobileComposeMail.
On the Mail, it's only showing the recipient email address, the subject and the email content.
Not sure what goes wrong... :(

Script on Card 1 (Capture image):

Code: Select all

on snap_pic
   set the lockloc of the templateimage to true
   set the width of templateimage to "300"
   set the height of the templateimage to "400"
   set the left of templateimage to "10"
   set the top of templateimage to "10"
   mobilePickPhoto "camera", 300, 400
   wait 1 second ##I have to put this in so that the app won't black out and not responding after taking pic 
   put the last image into image 1 of card 1
end snap_pic
Script on Card 2 (Send email with attachment of the pic captured)

Code: Select all

on openCard
   set the text of image 1 of card 1 to the text of image 1 of this card
end openCard

on send_pic
   put image 1 into tAttachment["data"]
   put "image/jpeg" into tAttachment["type"]
   put "cam pic" into tAttachment["name"]
   put "Name: " & fld "name" & cr & "Mobile: " & fld "mobile" into tMsg
   mobileComposeMail "Test Send Pic","test@email.com",,,tMsg,tAttachment
end send_pic

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Capture Photo (templateimage) and Send Later

Post by [-hh] » Fri Oct 31, 2014 8:02 am

You interchanged the code of Neil ...

You could also reference directly the image without copying it (don't need the openCard handler).

Code: Select all

put the text of image 1 of card 1 into tAttachment["data"]
This doesn't work if image 1 of card 1 is referenced (has a non-empty filename).
shiftLock happens

shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Re: Capture Photo (templateimage) and Send Later

Post by shoshinsha » Fri Oct 31, 2014 9:14 am

Hi,
Yup. I just noticed my mistake. Thanks for the help! :D

Post Reply