Titanium mobile image processing

蓝咒 提交于 2020-01-06 12:51:08

问题


I have an image view, and after getting the image and setting the image view I am having a simple problem.

Depending on if it is landscape or portrait, and if the image view is a square, the image view will not be filled. The only way I can achieve this using a landscape photo is to essentially crop it, otherwise it is stretched.

The trouble is - by cropping the photo into a square that I can then resize - I end up losing the areas that I have cropped, making way for an incomplete photo.

Alternatively, I could force the image to fill the view, but it will end up being stretched in the process.

Is there anyway to achieve this? I have already looked at imagefactory, but haven't had much luck.

Thanks


回答1:


Here goes a method for making an imageView exactly of image so it does not get crop or blur.You have to use a temporary image for this purpose

var imageTemp = Ti.UI.createImageView({
  image : someFile.read(),
  height:'auto',
  width:'auto'
});
Ti.API.info( "height=" + imageTemp.size.height);
Ti.API.info( "width=" + imageTemp.size.width);
imageTemp = null;

Thanks



来源:https://stackoverflow.com/questions/23430778/titanium-mobile-image-processing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!