Is it possible, without saving to photo gallery, to pass image data from the success result of Ti.Media.showCamera to a new window so that it can be assigned to an imageview's image property?
Kitchensink demo camera_overlay.js shows assigning the event.media object to the imageview image property in the same window. But can't see anywhere how to pass event.media to a new window.
1 Answer
not the most elegant solution, but it does work.. better solution described at bottom
1) Create a new Titanium Project
2) Paste this code after the tabGroup.open() statement
// create image view var imageView = Titanium.UI.createImageView({ }); // add view to the window win2.add(imageView); // create an eventListener on the open of win2 that // will assign the image to the window on the open // event. win2.addEventListener('open', function(e){ win2.imageView.image = win2.imageBlob; }); Titanium.Media.openPhotoGallery({ allowEditing:true, success: function(event) { var cropRect = event.cropRect; var image = event.media; // save the imageBlog on the window along with the view // this shows that the window could be in a separate .js win2.imageBlob = event.media; win2.imageView = imageView; }, 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'); } else { a.setMessage('Unexpected error: ' + error.code); } // show alert a.show(); } });If it were me, I would save the imageblob to a temp file and then fire an event with the file name being passed to the window/or imageView that I want to render the image.
I would do it that way because the Camera is known to be a memory hog on the iPhone and the app will start trying to purge things from memory which might cause additional problems for you.
Your Answer
Think you can help? Login to answer this question!