Thumbnail for Image-Both Android and Iphone

You must Login before you can answer or comment on any questions.

Hi, I am selecting the photos from image gallery and need to upload only two images as a thumbnail. And want this thumbnail images on a new window. what would be the code for thumbnail? How can i do that, anyone please suggest. here is my code.

function uploadWindow() {

var upload_win = Ti.UI.createWindow({ tabBarHidden : true, navBarHidden : true,

});
upload_win.orientationModes = [Ti.UI.UPSIDE_PORTRAIT, Ti.UI.PORTRAIT];

var header = Ti.UI.createLabel({ text:'MAMA', top:0, color:'#fff', font:{fontSize:30}, height:80, textAlign: 'center' });

upload_win.add(header);

var babyImage = Ti.UI.createImageView({ url:'/images/profile.jpg', top:80, width:250, height:400 });

upload_win.add(babyImage);

babyImage.addEventListener('click',function(e){ Ti.Media.openPhotoGallery({ success:function(e) { if(e.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { babyImage.setImage(e.media); }

           babyImage.setVisible(true);

    },
    cancel: function(){},
    error: function(){},
    mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]
});

});

var done = Ti.UI.createButton({ title:'Done', bottom:'10%', left:'2%', height: 50, width:'40%',

});

upload_win.add(done);

done.addEventListener('click',function(e){

// Here's the view we'll use to do the cropping. 

// It's never displayed either. var cropView = Titanium.UI.createView({ width:100, height:100 });

// Add the image to the crop-view. // Position it left and above origin. cropView.add(babyImage); babyImage.left=50; babyImage.top=200;

// now convert the crop-view to an image Blob var croppedImage = cropView.toImage();

// make an imageView containing the image Blob var imageView = Titanium.UI.createImageView({ image:croppedImage, width: 100, height:100,top:200 });

// add it to the window upload_win.add(imageView);

});

var retake = Ti.UI.createButton({ title:'Retake', bottom:'10%', right:'2%', height: 50, width:'40%',

});

upload_win.add(retake);

retake.addEventListener('click',function(e){ Ti.Media.showCamera({ success:function(e) { if(e.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { babyImage.setImage(e.media); } retake.setVisible(false); /choosePhoto.setVisible(false); confirm.setVisible(true); no.setVisible(true);/ }, cancel: function(){}, error: function(){}, mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO], autohide:true, saveToPhotoGallery:true }); });

return upload_win;

}

Your Answer

Think you can help? Login to answer this question!