简体   繁体   English

如何删除像CISepiaTone这样的CIFilter

[英]How To Remove a CIFilter Like CISepiaTone

I am working on a photo editing app for iOS. 我正在为iOS开发照片编辑应用程序。 The user needs to be able to not only apply a CIFilter to an image, which I have implemented successfully, but also remove that same CIFilter from their image, which is where I've run into problems. 用户不仅需要将CIFilter应用于我已经成功实现的图像,还需要从其图像中删除相同的CIFilter,这是我遇到问题的地方。 I have scoured the web for tutorials or answers on how to remove a CIFilter, such as CISepiaTone from an image. 我在网上搜寻了有关如何从图像中删除CIFilter(例如CISepiaTone)的教程或答案。 I haven't been able to find anything helpful. 我还找不到任何有用的东西。 The most I've found is this vague answer: "If you're using a CIFilter like CISepiaTone, you can essentially "remove" it by resetting it's value back to its initial value." 我发现的最模糊的答案是:“如果使用的是CISepiaTone这样的CIFilter,则可以通过将其值重置为初始值来“删除”它。 I need help with how I would put that idea into code, so that I can remove a CIFilter. 我需要有关如何将该想法放入代码中的帮助,以便可以删除CIFilter。 Any answers, suggestions, code, or comments are much aprreciated! 非常感谢任何答案,建议,代码或评论!

You need to look into NSUndoManager. 您需要研究NSUndoManager。 You call it when a user does an action that you would like to be able to undo. 当用户执行您希望能够撤消的操作时,可以调用它。 It keeps a stack of versions so you can go back to what ever stage you want. 它保留了一堆版本,因此您可以返回所需的任何阶段。 I am sure you can find a tutorial or an example here on SO. 我相信您可以在SO上找到教程或示例。

Consider keeping a copy of the original image for the desired undo. 考虑保留原始图像的副本以进行所需的撤消。 I have an implementation that lets users choose between different filters using a slider. 我有一个允许用户使用滑块在不同过滤器之间进行选择的实现。 When the slider is at the left stop, I replace the latest filtered image with the original image. 当滑块位于左止点时,我将最新过滤的图像替换为原始图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM