0

For a few days now I've been diligently researching how to get swiping between images with filters working. There is a post that has my exact same issue: Swipe between filtered images

Basically I need to swipe between filtered images just like it happens in snapchat, where the filter is progressively overlaid as the swipe occurs like this: https://www.youtube.com/watch?v=j75d7Khf6iM

But the answer did not give example code and my efforts have been to no avail.

I have tried the following:

1) I first tried creating 2 images. The 2nd one would be the image filtered and the first would be the original image. I wanted to apply an alpha mask at 100% for image 2 and 0% for image 1. As the user swipes I would reduce the alpha mask on image 2 and increase the image mask for image 1. However when I try to follow all the example code I came across I run into an issue. My CGImage is always nil (because my original image was not created with CGImage data and I'm not sure how to get the CGImage data)

    CGRect rect = CGRectMake(0, 0, 500, 500); 
    CGImageRef imageRef = CGImageCreateWithImageInRect(_picture.image.CGImage, rect);
    UIImage*result = [UIImage imageWithCGImage:imageRef];
    _picture.image = result; CGImageRelease(imageRef);
    //does not work, CGImage is null

2) I was going to crop the image, regardless of a mask, but every time I do, the size and scale does not match what I try to code.

If you could provide a bit more solution than the answer given (referenced above) I would be most appreciative. I am having an issue creating an alpha mask without using a another UIimage (I want to just create a rectangle that serves as the area to not draw on the image), and I am unsure how to get the CGImage data. If you can help with this or have any advice how to design this code I would be very grateful!

Thank you!

Community
  • 1
  • 1
Aggressor
  • 13,323
  • 24
  • 103
  • 182

0 Answers0