1

Full error is "Failed to render 921600 pixels because a CIKernel's ROI function did not allow tiling." every time I try to transform a ciImage with a translation.

Code is simply:

    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

Doing a translation causes the error and makes me entire screen gray instead of rendering the image otherwise normally.

Related thread, with no resolutions related to how I would be able to translate my ciImage: iOS 10: CIKernel's ROI function did not allow tiling

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Chewie The Chorkie
  • 4,896
  • 9
  • 46
  • 90

1 Answers1

1

Forgive me for the lateness, but I just ran across the same error and may have some help. I was using a different filter (CIShadedMaterial) and worked around it by trimming my image down to a smaller size. Here's my code:

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!
    }

Usage:

myImage = myImage.resizeToBoundingSquare(640)
  • I was using 4096 originally and realized I left that in.
  • Credit really needs to go to Simon Gladman for this. I couldn't find the exact place where I found that using 640x640 is "good enough" but this link is "close enough".