This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func resizeVI(size:CGSize) -> UIImage? { | |
let cgImage = self.CGImage! | |
var format = vImage_CGImageFormat(bitsPerComponent: 8, bitsPerPixel: 32, colorSpace: nil, | |
bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.First.rawValue), | |
version: 0, decode: nil, renderingIntent: CGColorRenderingIntent.RenderingIntentDefault) | |
var sourceBuffer = vImage_Buffer() | |
defer { | |
sourceBuffer.data.dealloc(Int(sourceBuffer.height) * Int(sourceBuffer.height) * 4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func resizeCG(size:CGSize) -> UIImage? { | |
let bitsPerComponent = CGImageGetBitsPerComponent(self.CGImage) | |
let bytesPerRow = CGImageGetBytesPerRow(self.CGImage) | |
let colorSpace = CGImageGetColorSpace(self.CGImage) | |
let bitmapInfo = CGImageGetBitmapInfo(self.CGImage) | |
let context = CGBitmapContextCreate(nil, Int(size.width), Int(size.height), bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo.rawValue) | |
CGContextSetInterpolationQuality(context, .High) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func resizeUI(size:CGSize) -> UIImage? { | |
UIGraphicsBeginImageContextWithOptions(size, true, self.scale) | |
self.drawInRect(CGRect(origin: CGPointZero, size: size)) | |
let resizedImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return resizedImage | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
class ElasticView: UIView { | |
private let topControlPointView = UIView() | |
private let leftControlPointView = UIView() | |
private let rightControlPointView = UIView() | |
private let bottomControlPointView = UIView() |