简体   繁体   中英

How To Remove a CIFilter Like CISepiaTone

I am working on a photo editing app for 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. I have scoured the web for tutorials or answers on how to remove a CIFilter, such as CISepiaTone from an image. 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." I need help with how I would put that idea into code, so that I can remove a CIFilter. Any answers, suggestions, code, or comments are much aprreciated!

You need to look into 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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