Page 1 of 1

Capture Photo (templateimage) and Send Later

Posted: Thu Oct 30, 2014 11:09 am
by shoshinsha
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!

Re: Capture Photo (templateimage) and Send Later

Posted: Thu Oct 30, 2014 11:23 am
by LCNeil
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
--

Re: Capture Photo (templateimage) and Send Later

Posted: Fri Oct 31, 2014 4:28 am
by shoshinsha
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

Re: Capture Photo (templateimage) and Send Later

Posted: Fri Oct 31, 2014 8:02 am
by [-hh]
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).

Re: Capture Photo (templateimage) and Send Later

Posted: Fri Oct 31, 2014 9:14 am
by shoshinsha
Hi,
Yup. I just noticed my mistake. Thanks for the help! :D