Page 1 of 1

Capturing & Saving Images on Android

Posted: Mon Mar 02, 2015 6:26 pm
by Gene
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!

Re: Capturing & Saving Images on Android

Posted: Mon Mar 02, 2015 7:02 pm
by Klaus
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

Re: Capturing & Saving Images on Android

Posted: Tue Mar 31, 2015 5:41 pm
by Gene
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.

Re: Capturing & Saving Images on Android

Posted: Sun Nov 15, 2015 3:02 am
by joelaud
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