钛移动图像处理 [英] Titanium mobile image processing

查看:171
本文介绍了钛移动图像处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图像视图,在获取图像并设置图像视图后,我遇到了一个简单的问题。

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.

无论如何要实现这个目标吗?我已经查看了imagefactory,但运气不好。

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

谢谢

推荐答案

这里有一种方法可以使imageView与图像完全一致,因此不会出现裁剪或模糊。为此需要使用临时图像

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;

谢谢

这篇关于钛移动图像处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆