我试图使用CGBitmapContextCreate&amp ;;来缩放图像。 CGContextDrawImage和我遇到了一些我无法理解的错误。
继承我的代码
let ciImage = CIImage(image: imageView.image)
let cgImage = convertCIImageToCGImage(ciImage)
let width = 50
let height = (width / CGImageGetWidth(cgImage)) * CGImageGetHeight(cgImage)
let bitsPerComponent = CGImageGetBitsPerComponent(cgImage)
let bytesPerRow = CGImageGetBytesPerRow(cgImage)
let colorSpace = CGImageGetColorSpace(cgImage)
let bitmapInfo = CGImageGetBitmapInfo(cgImage)
let context = CGBitmapContextCreate(nil, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo)
CGContextSetInterpolationQuality(context, kCGInterpolationHigh)
CGContextDrawImage(context, CGRect(origin: CGPointZero, size: CGSize(width: CGFloat(width), height: CGFloat(height))), cgImage)
scaledImage = UIImage(CGImage: CGBitmapContextCreateImage(context)!)!
我即将收到错误
<Error>: CGContextSetInterpolationQuality: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
我知道为什么会出现这个错误?