Search code examples
iosanimationios7core-graphicsappstore-approval

Is this use of dispatch queues and CIFilters likely to get my app rejected?


I've been looking around all day at various ways to apply a single CIFilter dynamically in an animation.

I'm looking to apply a strong CIPixellation filter to an image and gradually animate out to the original image, without using something like an alpha fade, which just wouldn't have the desired animation effect.

I looked at Brad's GPUImage, but importing MB's of framework into a very simple app scared me off slightly, even though it looks like it would be a perfect fit.

So then the only thing left to do felt a little bit hacky and cheaty, so I'm asking; Would the below code be likely to get my app rejected? And if so, on what grounds?

Cheers.

- (void)pixellateImage:(UIImage *)image fromValue:(int)from toValue:(int)to

{

dispatch_queue_t bgQueue = dispatch_queue_create("bgqueue", NULL);

for (int i = from; i >= to; i--) {

    dispatch_async(bgQueue, ^{
        CIContext *context  = [CIContext contextWithOptions:nil];

        CIImage *ciImage = [[CIImage alloc] initWithImage:[UIImage imageNamed:@"c3po"]];

        CIFilter *blur = [CIFilter filterWithName:@"CIPixellate"];

        [blur setValue:ciImage forKey:kCIInputImageKey];
        [blur setValue:[NSNumber numberWithInt:i] forKey:@"inputScale"];

        CGImageRef imageRef = [context createCGImage:blur.outputImage fromRect:[blur.outputImage extent]];

        UIImage *returnImage = [UIImage imageWithCGImage:imageRef];

        CGImageRelease(imageRef);

        dispatch_async(dispatch_get_main_queue(), ^{
            self.imageView.image = returnImage;
        });
    });
}

}


Solution

  • As long as you aren't using private API's, hacky code won't get you rejected.