Take A Picture, Preview and Upload
I am trying to create a form using the twitpix example.
Where I take a photo from the camera and or the photo albumn.
I then trying to assign it to the imageView as a preview,
once the user fills 1 text field for the message, it sends to twitpix.
It's not working, how do you assign the imageView the taken image, and then send the full sized image to the server?
I tried toImage, and toBlog and its not the right sized image.
Titanium.Media.showCamera({
success:function(event)
{
var image = event.media;
// set image view
imageView.image = image;
},
cancel:function()
{
},
error:function(error)
{
// create alert
var a = Titanium.UI.createAlertDialog({title:'Camera'});
// set message
if (error.code == Titanium.Media.NO_CAMERA)
{
a.setMessage('Device does not have video recording capabilities');
}
else
{
a.setMessage('Unexpected error: ' + error.code);
}
// show alert
a.show();
},
saveToPhotoGallery:true,
allowImageEditing:true
2 Answers
-
to save the image to the app's directory:
var image = event.media; var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, "savedImage.jpg"); f.write(image);
rocksteady,
danno~ -
I was able to get it working, by putting my listeners inside the success function.
The problem now is no matter what I do to clear it, if i want to rerun the function the image view has the previous image stuck inside of it.