【发布时间】:2016-05-16 06:23:32
【问题描述】:
我正在使用此链接中的一段代码 - Resize UIImage by keeping Aspect ratio and width,它运行良好,但我想知道是否可以更改它以保留像素的硬边缘。我想将图像的大小加倍并保留像素的硬边。
class func resizeImage(image: UIImage, newHeight: CGFloat) -> UIImage {
let scale = newHeight / image.size.height
let newWidth = image.size.width * scale
UIGraphicsBeginImageContext(CGSizeMake(newWidth, newHeight))
image.drawInRect(CGRectMake(0, 0, newWidth, newHeight))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage
}
在Photoshop中调整大小时有最近邻插值,在iOS中有类似的东西吗?
【问题讨论】:
标签: ios xcode swift image image-resizing