UIImageView scaling/interpolation

梦想的初衷 提交于 2019-11-30 12:21:39

You would need to set the magnificationFilter property on the view's layer to the nearest neighbour filter:

[[view layer] setMagnificationFilter:kCAFilterNearest]

Make sure you include the line

#import  <QuartzCore/CALayer.h>

At the top of the file containing the call to setMagnificationFilter or it won't compile.

Swift

imageView.layer.magnificationFilter = kCAFilterNearest
imageView.layer.shouldRasterize = true

There are two ways you could do this. You can either implement a rescaling algrorithm without interpolation. If this is to much work you could rescale the image in another application like gimp or photoshop. This would work unless you needed to change the size dynamically in your application.

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