Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Add an image from CoverflowView to Photo gallery

I've created a coverflowView with 40 different images which works fine. However, when a user clicks on one of these images I'd like it to save the image to the Photo Gallery - and this isn't working. I get a "Result of expression 'Titanium.Filesystem' [undefined] is not an object."; error message. Code below.

Is there anyone out there who has done something similar (or can work out what I'm doing wrong?). Any help much appreciated. Thanks. John

var win = Titanium.UI.currentWindow;

var images = [];
for (var c=0;c<40;c++)
{
    images[c]='../images/imageview/'+c+'.jpg';
}

// create coverflow view with images
var view = Titanium.UI.createCoverFlowView({
    images:images,
    backgroundColor:'#000'
});


// click listener - save the image to the photogallery when image is clicked.
view.addEventListener('click',function(e)
{
  if (e.index == 0) {
                    var f = Titanium.Filesystem.getFile('../images/imageview/'+c+'.jpg');
                    Titanium.Media.saveToPhotoGallery(f);
                    Ti.UI.createAlertDialog({title:'Image Saved',message:'This image has been saved to your photo gallery.', buttonNames:['Close']}).show();
                } else { }
});

win.add(view);
— asked November 25th 2010 by John Howell
  • coverflowview
  • gallery
  • iphone
  • photo
0 Comments

4 Answers

  • We're having the same problem, just even simpler:

        var current = Ti.UI.createImageView({image: url});
        var blobImage = current.toImage();
         var file = Titanium.Filesystem.createTempFile();
    
         file.write(blobImage);
         return file.nativePath;
    

    This isn't an answer, just some support for your question. The above should work pretty well to my knowledge.

    Ti Dev: 1.2.1,
    Ti Framework: 1.4.2 (and tried 1.5.0 continuous),
    SDK: 4.2

    — answered December 8th 2010 by Ken Hanson
    permalink
    1 Comment
    • Hi Ken, couple of things, did you get this working in the end? And would you care to share any more of that code, I am having trouble getting a blob image into coverflow, by the looks of it you seem to be most of the way there, but without seeing the rest of the context, im unsure what your doing with some of your variables?

      — commented December 21st 2010 by Ian Tearle
  • Acutally, just last ditch did something, and this is likely the voodoo it takes to make things work with Titanium, but I changed the SDK from Continuous 1.5.0 to 1.4.2, did a build, stopped it, changed it back to continuous, and now it works.

    Like I said, voodoo.

    So do that, rub your belly and pat your head 3x and maybe you'll have the same luck we did =p

    Oi, Appcelerator is a fickle beast sometimes :(

    — answered December 8th 2010 by Ken Hanson
    permalink
    0 Comments
  • Actually is sort of a bug, I get this error with numerous things sometimes (scrollviews, labels you name it) just delete everything in the build folder and rebuild it fully that should work with these kind of errors

    — answered December 8th 2010 by Patrick van Zadel
    permalink
    0 Comments
  • maybe a little late but if you delete the build folder and let it make this again everything seems to work :)

    — answered May 3rd 2012 by Sven Louckx
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.