forked from mattneub/Programming-iOS-Book-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyVignetteFilter.m
31 lines (20 loc) · 886 Bytes
/
MyVignetteFilter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#import "MyVignetteFilter.h"
@interface MyVignetteFilter ()
@property (nonatomic, strong) CIImage* inputImage;
@end
@implementation MyVignetteFilter
-(CIImage *)outputImage {
CGRect inextent = self.inputImage.extent;
CIFilter* grad = [CIFilter filterWithName:@"CIRadialGradient"];
CIVector* center = [CIVector vectorWithX:inextent.size.width/2.0
Y:inextent.size.height/2.0];
[grad setValue:center forKey:@"inputCenter"];
[grad setValue:@85 forKey:@"inputRadius0"];
[grad setValue:@100 forKey:@"inputRadius1"];
CIImage *gradimage = [grad valueForKey: @"outputImage"];
CIFilter* blend = [CIFilter filterWithName:@"CIBlendWithMask"];
[blend setValue:self.inputImage forKey:@"inputImage"];
[blend setValue:gradimage forKey:@"inputMaskImage"];
return blend.outputImage;
}
@end