Titanium Community Questions & Answer Archive

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

resize images in cover flow

I have a problem, i need to dynamically insert images into a cover flow view but i don't know their dimensions.

I was thinking to create a label put the image as background and than use the toImage() and pass it to the images array in the cower flow view.

I couldn't get this working, is there a fix or another method to achieve this?

thanks

— asked March 22nd 2010 by Daniele Sangalli
  • coverflow
  • resize
0 Comments

7 Answers

  • var arrayOfImageUrls = theImageURLs;
    var imagesForCoverFlow= [];
    
    for (var i = 0; i < arrayOfImageUrls.length;i++) {
        imagesForCoverFlow.push({image: arrayOfImageUrls[i], width: 123, height:    123});
    }
    
    var coverFlow = Ti.UI.createCoverFlow({
        images: imagesForCoverFlow;
    });
    
    window.add(coverFlow);
    
    — answered May 20th 2011 by James Adams
    permalink
    1 Comment
    • This is working thanks !

      — commented March 15th 2013 by Ludovic Lecerf
  • you could use a generate View and set the backgroundImage to it the same way.

    — answered March 22nd 2010 by Jeff Haynie
    permalink
    0 Comments
  • Here is a resize function I wrote that takes an image view processes it and gives the height to resize proportionally according to width, let me know if it helps
    <br /><br />

    function resizeImage(image, nWidth)
    {
    var blob = myImage.toBlob();
    if(blob.width <= nWidth){
    return blob.height;
    }else{
    var nHeight = (blob.height / blob.width) * nWidth;
    return nHeight;
    }
    };

    — answered March 22nd 2010 by Christopher Reding
    permalink
    0 Comments
  • did you ever get this working? please post a solution if you did - thanks!

    — answered April 3rd 2010 by david hoare
    permalink
    0 Comments
  • Sorry guys if I didn't come back on this sooner. I tried this:

    var image = Titanium.UI.createImageView({
            height:100,
            width:100,
            backgroundImage: imageURL
            });
    
    var image = img.toImage();
    
    var images [counter] = image;
    
    var view = Titanium.UI.createCoverFlowView({
        images:images,
        backgroundColor:'#000'
    });
    

    But I cant see anything in the coverflow. Am I missing something?
    Thanks

    — answered April 8th 2010 by Daniele Sangalli
    permalink
    0 Comments
  • i really can get this working:

    var image = Titanium.UI.createImageView({
            height:100,
            width:100,
            backgroundImage: imageURL 
            });
    
    var image = img.toBlob();
    
    var images [counter] = image;
    
    var view = Titanium.UI.createCoverFlowView({
        images:images,
        backgroundColor:'#000'
    });
    

    with img.toBlob() it doesn't load the image while with or img.toImage() it crashes. Any ideas on this?

    Thanks

    — answered April 18th 2010 by Daniele Sangalli
    permalink
    0 Comments
  • Is there a solution available already?

    — answered May 9th 2011 by Nicky Vandevoorde
    permalink
    1 Comment
    • try:

      img[0]=Ti.UI.createImageView({backgroundImage:&#39;pic.png&#39;,height:100,width:100}).toImage();

      — commented May 14th 2011 by Adam Paxton
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.