如何将大图像变成小图像,并且质量与原始图像一样好?
我使用尺寸为 80X80 的 imagview 来显示大图像(1024 X 780)。
将大图像放入图像视图时,图像看起来被挤压、压缩,不像质量图像。
我的问题是,如何将大图像变成小图像,并且质量与原始图像一样好?
I am using imagview with size of 80X80 to display large image (1024 X 780).
While placing the large image into the imageview, the image looks squeezed, compressed something not like the quality one.
My question is, how can I make the large image into small with as good quality as the original image ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在图像视图中,请将imageview.mode设为中心,而不是缩放以适合或任何其他。
我相信这将使您的任何缩放图像在 80x80 尺寸下都具有最佳质量。
In the image view, please make the imageview.mode as centre not scale to fit or any other.
I believe this would put ur any scaled image at finest quality in ur 80x80 dimension.
在这种情况下,您应该对要在 ImageView 中显示的图像进行适当的缩放
In this case, you should do proper Scaling of the Image that u want to show in the ImageView
[imageView setContentMode:UIViewContentModeScaleAspectFill];
但是,如果您想多次使用图像,则应该考虑调整图像大小并将其保存在磁盘上。
要调整图像大小:
调整 UIImage 大小的最简单方法?
< a href="https://stackoverflow.com/questions/2645768/uiimage-resize-scale-proportion">UIImage 调整大小(缩放比例)
UIImage:调整大小,然后裁剪
等。
[imageView setContentMode:UIViewContentModeScaleAspectFill];
You should however consider resizing the image and saving it on the disk if you want to use it more then once.
To resize the image:
The simplest way to resize an UIImage?
UIImage resize (Scale proportion)
UIImage: Resize, then Crop
etc..
从 1034x780 变为 80x80 实际上不可能保持质量,因为没有足够的空间来捕捉所有细节。
您可以尝试缩放它:
Going from 1034x780 into 80x80 is virtually impossible to keep the quality, as there isn't enough space to capture all the details.
You can try to scale it:
您可以设置图像模式
[imageView setContentMode:UIViewContentModeScaleAspectFill];
imageView.autoresizingMask = ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight );
[imageView setClipsToBounds:YES];
you can set image mode
[imageView setContentMode:UIViewContentModeScaleAspectFill];
imageView.autoresizingMask = ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight );
[imageView setClipsToBounds:YES];