【发布时间】:2018-06-16 10:52:39
【问题描述】:
如果我将图像绘制到 CGContext 中,当我稍后用它制作图像时,它会按预期工作。但是,当我想通过将 X 轴缩放 -1 来镜像该图像时,产生图像的相同代码会产生全白图像 - 即。不起作用。我错过了什么?
let context = CGContext(data: nil, width: Int(aspectFitSize.width), height: Int(aspectFitSize.height), bitsPerComponent: bitsPerComponent, bytesPerRow: bytesPerRow, space: colorSpace, bitmapInfo: bitmapInfo.rawValue)
context.scaleBy(x: -1, y: 1) // <-- this line causes the problem; it's fine without it, but I want to mirror the image...
context.draw(cgImage, in: CGRect.init(origin: .zero, size: aspectFitSize))
let image = context.makeImage()
【问题讨论】:
标签: ios cocoa-touch core-graphics