Search code examples
iosgpuimage

Moving GPUImage Layer with Finger


I have a base GPUImagePicture (Layer 1) and then another GPUImagePicture (Layer 2) that I have added a bunch of filters to.

When I put them together into one image they look fine but what I would like to do is move Layer 2 with my finger to different positions on Layer 1. Is this possible without using something like Cocos2D?


Solution

  • Try to add an GPUImageTransformFilter with an affine transform set correctly to translation to one of your GPUImagePicture before blending.
    If you need to make a more sophisticated manipulation I think that you should extract from one of the original image the correct portion, redraw in a transparent background image (same size of the first one) and then blend.
    To build the affine transform to apply you can easily use a UIPanGestureRecognizer on a touch detecting overlay view.