【发布时间】:2014-08-14 23:44:19
【问题描述】:
我整天都在寻找在动画中动态应用单个 CIFilter 的各种方法。
我希望对图像应用强大的 CIPixellation 过滤器,并逐渐将动画变为原始图像,而不使用像 alpha 淡入淡出这样的东西,这不会产生所需的动画效果。
我查看了 Brad 的 GPUImage,但将 MB 的框架导入一个非常简单的应用程序让我有点害怕,尽管它看起来非常适合。
所以剩下要做的唯一一件事感觉有点老套和作弊,所以我在问;下面的代码可能会导致我的应用被拒绝吗?如果是这样,基于什么理由?
干杯。
- (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;
});
});
}
}
【问题讨论】:
标签: ios animation ios7 core-graphics appstore-approval