mobilepickphoto help :(

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
vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

mobilepickphoto help :(

Post by vedus » Tue Dec 17, 2013 10:04 pm

i have the sqlite database and i want to store 1 photo for every customer.
So when i go and edit in the customer, i choose the picture but..
this code i use to get the photo.

Code: Select all

on mouseUp
  set the lockloc of the templateimage to true
      set the width of the templateimage to "140"
     set the height of the templateimage to "195"
    set the left of the templateimage to "410"
    set the top of the templateimage to "664"
  mobilePickPhoto "album"
  if the result is text then
    put the result into tData
  --put the text of last image into tData
  put base64encode("tData") into Tbase
  put Tbase into fld "customer_photo"
  end if
end mouseUp
the problem is when i get the picture the field "customer_photo" have the same text like this ( SFAdfdgsfgsdf== )
the above is for ios..
the field in the sqlite is simple text NO blob
where i do wrong here?
the working code i use in mac environment is this bellow

Code: Select all

on mouseUp
  -->>
local tChosenFile
  answer file "Please choose the folder"
      if there is a file tChosenFile then 

    put it into tChosenFile
    put URL ("binfile:" & tChosenFile) into image "imagetest"
    put base64encode(url("binfile:" & tChosenFile)) into tBase64ImgData
    put tBase64ImgData into fld "customer_photo"

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: mobilepickphoto help :(

Post by vedus » Tue Dec 17, 2013 10:43 pm

after some test i figure out i don't pass the binary data how is possible to pass the binary data in ios environment?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mobilepickphoto help :(

Post by Klaus » Tue Dec 17, 2013 11:46 pm

Hi Vedus,

I highly recommend to read up "mobilepickphot" in the dictionary,
especially what "THE RESULT" returns in different situations! 8)
And please also look up "base64encode".

And you cannot display an image in a FIELD this way if that is what you want.

What you need to display the stored image is an empty image object on a card
and put the retrieved data from the database into this image like this after
base64DEcoding the data:
...
## Given the data from the database in in the variable -> tImageFromDB
put base64DEcode(tImageFromDB) into tActualImage
set the text of img "your empty image object here!" to tActualImage
...

Try this to take the new picture and read my comments:

Code: Select all

on mouseUp
   set the lockloc of the templateimage to true
   set the width of the templateimage to "140"
   set the height of the templateimage to "195"
   set the left of the templateimage to "410"
   set the top of the templateimage to "664"
   mobilePickPhoto "album"

   ## THE RESULT will be EMPTY only on success!
   ## It will be CANCEL if the user clicked Cancel etc...
   if the result <> EMPTY then
      answer "Error:" && the result
      exit mouseup
   end if
   
   ## mobilePickPhoto will create a NEW image on the current card 
   ## with all the properties set to the TEMPLATEIMAGE
   put the text of last image into tData
   put base64encode("tData") into Tbase
   ## Now oyu can store Tbase into your database
   
   ## You might want to have an EMPTY image object to "transfer" the "mobile picked" photo to!
    set the text of img "your customer photo here" to tData
   
   ## Now clean up and delete the last image created by mobilpickphoto:
   delete last img
 end mouseUp
Best

Klaus

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: mobilepickphoto help :(

Post by vedus » Wed Dec 18, 2013 12:51 am

hi klaus again :)
about the dictionary i have read it,there is nothing to read but only what can we pick with mobilepickphoto (camera,album,library) i search the internet if i find any guide but still nothing :(
or i miss something??
about the code.
if you see in my post i have include the code i use in the desktop (mac) environment and is working to store the picture data and retrieve the data :)
the code u write for me above i get the same results..
I will try to make it more simple if i can...
i pick the photo

Code: Select all

mobilePickPhoto "album"
if we have error we get it

Code: Select all

   if the result <> EMPTY then
      answer "Error:" && the result
      exit mouseup
   end if
we get the binary data from the image file (if i am right with the <text>)

Code: Select all

put the text of last image into tData
//or
put the text of templateimage into tData
returns a text string representing the binary data.

Code: Select all

put base64encode("tData") into Tbase
i put the data into database field

Code: Select all

put tBase into fld "customer_photo"
i have an empty image that i use in the "mac" version with name "cPhoto"
the problem Now is..
every picture i choose with mobilepickphoto the data i get in the field "customer_photo" is the same for every picture.
i have attach the screenshots from ipad simulator take a look the photos in the right and the text in the left.
Is 2 different photos,but the text field have the same binary data
p1.jpg
p2.jpg

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mobilepickphoto help :(

Post by Klaus » Wed Dec 18, 2013 3:12 am

Hi vedus,

Code: Select all

put base64encode("tData") into Tbase
very bad idea to put QUOTES around your variable! 8)

This will do:

Code: Select all

put base64encode(tData) into Tbase
See ma, no quotes! :D


Best

Klaus

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: mobilepickphoto help :(

Post by vedus » Wed Dec 18, 2013 1:41 pm

Klaus wrote:Hi vedus,

Code: Select all

put base64encode("tData") into Tbase
very bad idea to put QUOTES around your variable! 8)

This will do:

Code: Select all

put base64encode(tData) into Tbase
See ma, no quotes! :D


Best

Klaus
thank you that make the different :)
now is working.
i have a last question because i don't find any similar about this in the forums.
with mobilepickphoto we have the album the library and the camera.
because i use the the ios simulator i don't know if the user when click the btn can choose the "album" only??
is limit by simulator or i need <script> to make the user choose "album" or "camera"?
thank you :)

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mobilepickphoto help :(

Post by Klaus » Wed Dec 18, 2013 1:47 pm

Oh, come on, the DICTIONARY leaves doubt about the "mobilepickphoto" syntax! 8)

Post Reply