Having problems with getting photo in Android
Posted: Thu Sep 11, 2014 1:59 pm
Maybe I am doing it wrong but I cannot seem to get mobilePickPhoto to work correct on android.
My camera gets active and I can take the photo but after selecing save I get an error in my stack.
I made a test Stack for learning puposes based on the existing tutorials and what I have found in this forum but nothing seems to work.
So here is my cry for help.
The button code is shown below. In the attachment is the test stack I made.
Regards,
Paul
================================
on mouseUp
# the X, Y dimensions for an image are not supported on Android and are ignored
global tEnvironment,tPlatform
switch tPlatform
case "android"
# When a picture is taken using mobilpicphoto it creates a new "image" object to contain the picture.
set the name of the templateimage to "TheTakenPicture" // The templateimage is just that. A template for the image object. When you set properties for the templateimage and then create a new image object it uses the settings you specified. So in the case of this really cool script, it sets the location (loc) of the template image to a hidden spot off screen. So when the picture is taken it appears in that location.
set the loc of the templateimage to -1000,-1000 // Will hide the image offscreen in this case I want to see it therefore I place into the image object: image "The_Image" .
# set the vis of the templateImage to false // This is an alternative way to hide the taken image if you do not want it to show immediately on the card.
set the width of the templateImage to 294 // Image Size. A way to set X, Y dimensions for an image in android devices
set the height of the templateImage to 238 // Image Size. A way to set X, Y dimensions for an image in android devices
mobilePickPhoto "camera" // Opens the device camera software and lets you take a picture after which it goes bach to your card.
break
case "iOS"
mobilePickPhoto "camera", 294, 238
break
case "Win32"
Answer "You have just simulated taking a picture with the Default Cam"
break
end switch
if the result is empty // IF 01
then // IF 01
# Put the last image into image "The_Image" // This statement does not work ?? Camera can take picture but then the result is error. According to tutorial this should work?
set the text of image "The_Image" to the last image of this card // I already have an empty image object ("The_Image") to hold the data. When you set the text of image "The_Image" to the text of another image it copies the data from one image (in this case the last image taken & autosaved) and stuffs it into the other.
set the visible of image "The_Image" to true
wait 0 millisecs with messages #Wait 0 seconds with messages (again, read up on it in the dictionary) is what it appears to be. The current handler is paused. The "with messages" part means that other things waiting in the message queue can be worked on while waiting.
# Save image in a personal specified location as PNG
set the defaultfolder to specialfolderpath("documents")
export image "The_Image" of this card to URL("binfile:" & "./" & "tempic" ) as PNG // relative pathing with defaultfolder. in a path . means the current folder (so whatever the defaultfolder is set to) .. would mean up 1 folder. So, since the defaultfolder is already pointing to the documents folder, putting a file in ./filename.png will create a file named filename.png in the users documents folder.
# URL means you are going to define what type of data transfer it is, in this case its a binary file. (like on the web, http: is a hypertext transfer protocol page, ftp: is file transfer protocol) LC has file: and binfile: So you are exporting the image to URL of type binfile:
put the last image into tAttachment["data"] // Put image into a aray variable (E.G. for saving into a database)
put "image/jpeg" into tAttachment["type"]
put "CamDefaultPicture" into tAttachment["name"]
delete the last image of this card // Since no new images have been created, the "delete the last image of this card" line will remove it.
mobileExportImageToAlbum tAttachment["data"] //Other way to save the captured image in
mobileComposeMail "Camera Example", getRecipient(),,,, tAttachment // Send Image via E-Mail
else // IF 01
put the result into field "The_Result" // Show whats in the result if not empty
Answer "There is a problem with mobilePickPhoto command, the result is :" & the result
end if // IF 01
end mouseUp
=====================================
My camera gets active and I can take the photo but after selecing save I get an error in my stack.
I made a test Stack for learning puposes based on the existing tutorials and what I have found in this forum but nothing seems to work.
So here is my cry for help.
The button code is shown below. In the attachment is the test stack I made.
Regards,
Paul
================================
on mouseUp
# the X, Y dimensions for an image are not supported on Android and are ignored
global tEnvironment,tPlatform
switch tPlatform
case "android"
# When a picture is taken using mobilpicphoto it creates a new "image" object to contain the picture.
set the name of the templateimage to "TheTakenPicture" // The templateimage is just that. A template for the image object. When you set properties for the templateimage and then create a new image object it uses the settings you specified. So in the case of this really cool script, it sets the location (loc) of the template image to a hidden spot off screen. So when the picture is taken it appears in that location.
set the loc of the templateimage to -1000,-1000 // Will hide the image offscreen in this case I want to see it therefore I place into the image object: image "The_Image" .
# set the vis of the templateImage to false // This is an alternative way to hide the taken image if you do not want it to show immediately on the card.
set the width of the templateImage to 294 // Image Size. A way to set X, Y dimensions for an image in android devices
set the height of the templateImage to 238 // Image Size. A way to set X, Y dimensions for an image in android devices
mobilePickPhoto "camera" // Opens the device camera software and lets you take a picture after which it goes bach to your card.
break
case "iOS"
mobilePickPhoto "camera", 294, 238
break
case "Win32"
Answer "You have just simulated taking a picture with the Default Cam"
break
end switch
if the result is empty // IF 01
then // IF 01
# Put the last image into image "The_Image" // This statement does not work ?? Camera can take picture but then the result is error. According to tutorial this should work?
set the text of image "The_Image" to the last image of this card // I already have an empty image object ("The_Image") to hold the data. When you set the text of image "The_Image" to the text of another image it copies the data from one image (in this case the last image taken & autosaved) and stuffs it into the other.
set the visible of image "The_Image" to true
wait 0 millisecs with messages #Wait 0 seconds with messages (again, read up on it in the dictionary) is what it appears to be. The current handler is paused. The "with messages" part means that other things waiting in the message queue can be worked on while waiting.
# Save image in a personal specified location as PNG
set the defaultfolder to specialfolderpath("documents")
export image "The_Image" of this card to URL("binfile:" & "./" & "tempic" ) as PNG // relative pathing with defaultfolder. in a path . means the current folder (so whatever the defaultfolder is set to) .. would mean up 1 folder. So, since the defaultfolder is already pointing to the documents folder, putting a file in ./filename.png will create a file named filename.png in the users documents folder.
# URL means you are going to define what type of data transfer it is, in this case its a binary file. (like on the web, http: is a hypertext transfer protocol page, ftp: is file transfer protocol) LC has file: and binfile: So you are exporting the image to URL of type binfile:
put the last image into tAttachment["data"] // Put image into a aray variable (E.G. for saving into a database)
put "image/jpeg" into tAttachment["type"]
put "CamDefaultPicture" into tAttachment["name"]
delete the last image of this card // Since no new images have been created, the "delete the last image of this card" line will remove it.
mobileExportImageToAlbum tAttachment["data"] //Other way to save the captured image in
mobileComposeMail "Camera Example", getRecipient(),,,, tAttachment // Send Image via E-Mail
else // IF 01
put the result into field "The_Result" // Show whats in the result if not empty
Answer "There is a problem with mobilePickPhoto command, the result is :" & the result
end if // IF 01
end mouseUp
=====================================