Getting message in console: “CreateWrappedSurface() failed for a dataprovider-backed CGImageRef.”

对着背影说爱祢 提交于 2019-12-03 08:12:06

Finally figured out the answer. Curious by the error I studied up on how CIImage works (https://uncorkedstudios.com/blog/image-filters-with-core-graphics)

I noticed that the CGImageRef is dataprovider-backed with premultiplied values (RGB and A)

I thought to myself that the CGImage I am loading into a CIImage (using [CIImage imageWithCGImage:originalCGImage]; is only RGB and not RGBA). Sure enough, I was creating this image by taking a snapshot of a view using the standard UIGraphicsBeginImageContextWithOptions and I had the opaque parameter set to "YES".

I simply changed:

UIGraphicsBeginImageContextWithOptions(bounds, YES, 1.0f);

to

UIGraphicsBeginImageContextWithOptions(bounds, NO, 1.0f);

So that I am now creating a RGBA image, not an RGB image.

Now I convert my CGImage to CIImage and the CIImage NOW has proper dataprovider backing and the error goes away.


NOTE:

I was using a CIClamp filter for gaussian blur purposes, and with opaque set to NO the clamp doesn't work as effectively. I decided to just keep the opaque at YES and ignore the log warnings, they don't seem to actually do anything.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!