Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Undo CIImageAccumulator

I have painting app witch works like that:


  • On mouseDown/mouseDragged event I draw a point in event location with CIRadialGradient
  • Take CIRadialGradient outputImage and use it in CICompositeSourceOver filter as inputImage (inputBackground at beggining is empty CIImage)
  • Set CICompositeSourceOver outputImage as brushAccumulator image (later brushAccumulator image is used as inputBackgroundImage in CICompositeSourceOver filter)
  • Set brushAccumulator image as CIBlendWithMask inputMaskImage
  • Set CIBlendWithMask outputImage as mainImageAccumulator image
  • Draw mainImageAccumulator to screen


And I want to implement undo method. Firstly I thought I could use brushAccumulator.image (CIImage) as undo object (add it to mutableArray, then when undo method is invoked set brushAccumulator image to one of mutableArray objects) but I found that:

A CIImage is not an image that contains pixels, it is simply the result of a series of instructions to build it, the output of a CIFilter for example. So if you copy the CIImage you just copy those instructions, which when modified would modify the ouput.


So I thought I could make NSBitmapImageRep from brushAccumulator's image and store it to NSMutableArray. But I met problems with updating brushAccumulator. I set the new CIImage wich is made from one of NSBitmapImageRep from NSMutableArray as brushAccumulator image, but brushAccumulator image doesn't changes.


What could you offer me to achieve undo/redo effect, while my painting app is based on CIImageAccumulator (similar to CIMicroPaint sample code)?

OS X Mountain Lion (10.8)

Posted on Jan 31, 2013 3:02 AM

Reply

There are no replies.

Undo CIImageAccumulator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.