控制台"CIKernel's ROI function did not allow tiling"中的快速错误



完整错误是"无法渲染921600像素,因为Cikernel的ROI函数不允许铺平。"每次我尝试通过翻译转换一个CIIMAGE。

代码简单:

    var flippedGradient = gradient.transformed(by:CGAffineTransform(scaleX: -1, y: 1))
    flippedGradient = gradient.transformed(by:CGAffineTransform(translationX: flippedGradient.extent.width, y: 0)) // causes error
    // mask hue 2 with gradient with transparent background
    let alphaMaskBlend2 = CIFilter(name: "CIBlendWithAlphaMask",
                                   withInputParameters: [kCIInputImageKey: hue2,
                                                         kCIInputBackgroundImageKey: transBGCI,
                                                         kCIInputMaskImageKey:flippedGradient])?.outputImage

进行翻译会导致错误,并使我整个屏幕灰色,而不是正常呈现图像。

相关线程,没有与我如何翻译我的ciimage的分辨率:iOS 10:Cikernel的ROI功能不允许平铺

请原谅我的迟到,但是我遇到了相同的错误, May 有一些帮助。我正在使用其他过滤器(CIShadedMaterial(,并通过将图像缩小到较小的尺寸来解决它。这是我的代码:

extension UIImage {
    func resizeToBoundingSquare(_ boundingSquareSideLength : CGFloat) -> UIImage {
        let imgScale = self.size.width > self.size.height ? boundingSquareSideLength / self.size.width : boundingSquareSideLength / self.size.height
        let newWidth = self.size.width * imgScale
        let newHeight = self.size.height * imgScale
        let newSize = CGSize(width: newWidth, height: newHeight)
        UIGraphicsBeginImageContext(newSize)
        self.draw(in: CGRect(x: 0, y: 0, width: newWidth, height: newHeight))
        let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext();
        return resizedImage!
    }

用法:

myImage = myImage.resizeToBoundingSquare(640)
  • 我最初使用4096,意识到我把它留在。
  • 为此,信用确实需要去西蒙·格拉德曼(Simon Gladman(。我找不到 Exact 的位置,我发现使用640x640"足够好",但此链接"足够接近"。

最新更新