Capturing & Saving Images on Android

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Gene
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 75
Joined: Wed Mar 09, 2011 6:48 pm
Location: Northern California

Capturing & Saving Images on Android

Post by Gene » Mon Mar 02, 2015 6:26 pm

Hi,

Possibly someone can give me a little direction here to get me over the hump with using the camera on Android. I simply want to capture and image with the camera, then be able to save it and retrieve it later. I've tried to research the topic but have come up with sketchy information on how to handle image capture, and exactly what to do with the template image and image objects. It's a little like trying to figure out what a fly is seeing by being able to examine only a random sample of a few individual lenses.

Here is the code I've been experimenting with. It yields good results and returns an image as expected and displays it, but two or three subsequent attempts at capturing images from the camera without rebooting the app result making the process dysfunctional. That is, I get slow response or no response from the process. I suspect I'm not deleting the old images and quickly depleting resources, but I'm not sure about that or what to do about it.

"myimage.jpg" is an image object created with the same dimensions as the template image.

on mouseUp
set the lockloc of the templateimage to true
set the width of the templateimage to "300"
set the height of the templateimage to "400"
set the left of the templateimage to "10"
set the top of the templateimage to "10"
mobilePickPhoto "camera"
put the result into image "myimage.jpg"
reset the templateImage
end mouseUp

Thank you for the help!

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Capturing & Saving Images on Android

Post by Klaus » Mon Mar 02, 2015 7:02 pm

Hi Gene,

-> mobilePickPhoto "camera"
will create a NEW image object on your code based on "the templateimage"!
"the result" will return TEXT in these cases (from the dictionary 8) ):
-------------------------------------------------------------------------------------------------
If the source type is not available on the target device, the command returns with result source not available.
If the user cancels the pick, the command returns with result cancel.
Otherwise a new image object is created on the current card of the default stack containing the chosen image.
..............................................................................................
So you should check if the RESULT <> EMPTY, which means one of the above mentioned cases happened.
Otherwise a new image should appear on your card.

So maybe you want something like this:

Code: Select all

on mouseUp
  set the lockloc of the templateimage to true
  set the width of the templateimage to "300"
  set the height of the templateimage to "400"
  set the left of the templateimage to "10"
  set the top of the templateimage to "10"
  mobilePickPhoto "camera"

  lock screen
  put last img into img "myimage.jpg"
  
  ## Get rid of newly created image
  delete last image
  
  reset the templateImage
  unlock screen
end mouseUp
Best

Klaus

Gene
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 75
Joined: Wed Mar 09, 2011 6:48 pm
Location: Northern California

Re: Capturing & Saving Images on Android

Post by Gene » Tue Mar 31, 2015 5:41 pm

A belated "thank you," Klaus. I finally waded through the problem using the direction you provided. As you know, it's not always a direct answer that solves an issue, but just being pointed in the right direction is of enormous help.

joelaud
Posts: 3
Joined: Mon Nov 02, 2015 2:27 am

Re: Capturing & Saving Images on Android

Post by joelaud » Sun Nov 15, 2015 3:02 am

A deep and heart felt thanks. This has been deviling me for several hours. Time and again I find the Forum one of the most important parts of this work.
Joel Aud

Post Reply

Return to “Android Deployment”