image capture on android devices

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
GPJMA
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 38
Joined: Sun Jan 01, 2012 11:48 pm
Location: Brisbane Autralia

image capture on android devices

Post by GPJMA » Tue Nov 12, 2013 9:14 pm

Hello all.
I have been looking around the forum for some info on image capture on Android....most of what I find is a bit old.
Is anyone around the forum using live code successfully to capture images into an app?
I would appreciate any help in this area. Image capture on iOS is not a problem but I cant get it right with any Android device.
Thanks in anticipation
gpjma

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: image capture on android devices

Post by Mark » Wed Nov 13, 2013 2:15 am

Hi gpjma,

A standard export snapshot command works. For example, something like this:

Code: Select all

on mouseUp
   createImage
end mouseUp

on createImage
   if there is an image "Test" then delete image "Test"
   export snapshot from this cd to myPict as PNG
   set the text of the templateImage to myPict
   put rescale(the formattedwidth of the templateImage,the formattedHeight of the templateImage,100,100) into myWH
   set the rect of the templateImage to 0,0 & comma & myWH
   set the loc of the templateImage to the loc of this cd
   set the showBorder of the templateImage to true
   set the name of the templateImage to "Test"
   create img
end createImage

function rescale theImgWidth,theImgHeight,theCdWidth,theCdHeight
  if theCdWidth/theImgWidth < theCdHeight/theImgHeight then
    put theCdWidth / theImgWidth into myRatio
  else
    put theCdHeight / theImgHeight into myRatio
  end if
  put theImgWidth * myRatio into myNewWidth
  put theImgHeight * myRatio into myNewHeight
  return myNewWidth,myNewHeight
end rescale
Many more variations are possible.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

GPJMA
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 38
Joined: Sun Jan 01, 2012 11:48 pm
Location: Brisbane Autralia

Re: image capture on android devices

Post by GPJMA » Wed Nov 13, 2013 8:48 am

Hi Mark
Many thanks for the reply.
I have tried a few methods but have one issue or another.
My app requires the user to take a photo and log it with a report nothing too difficult I guess.
I will let you know how I get on.
Thanks again.
Grahame

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: image capture on android devices

Post by Mark » Wed Nov 13, 2013 10:16 am

Hi Grahame,

I understand it now. You need access to the camera. That's something completely different from what I wrote of course. Doesn't the mobilePickMedia command work for you? Could you write a little more about what you have tried so far?+

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

GPJMA
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 38
Joined: Sun Jan 01, 2012 11:48 pm
Location: Brisbane Autralia

Re: image capture on android devices

Post by GPJMA » Wed Nov 13, 2013 9:05 pm

Hi Mark
Thanks.
Yes that's what I want to do but the code snippet you gave me will come in handy in another part of the program.
I will get back with what I am trying in a day or so as I am traveling between work sites at the moment.
Many thanks again for taking the time.
Cheers
Grahame

Post Reply

Return to “Android Deployment”