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
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);
-
you could use a generate View and set the backgroundImage to it the same way.
-
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;
}
}; -
did you ever get this working? please post a solution if you did - thanks!
-
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 -
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
-
Is there a solution available already?