Dha*_*val 3 iphone image-processing iphone-sdk-3.0 ipad ios
我想删除红眼效果表单照片,但没有得到任何样本可以任何人帮助我使用演示代码或代码片段?
谢谢.
使用下面category的UIImage:
@interface UIImage (Utitlities)
-(UIImage*)redEyeCorrection;
@end
Run Code Online (Sandbox Code Playgroud)
@implementation UIImage (Utitlities)
-(UIImage*)redEyeCorrection
{
CIImage *ciImage = [[CIImage alloc] initWithCGImage:self.CGImage];
// Get the filters and apply them to the image
NSArray* filters = [ciImage autoAdjustmentFiltersWithOptions:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:kCIImageAutoAdjustEnhance]];
for (CIFilter* filter in filters)
{
[filter setValue:ciImage forKey:kCIInputImageKey];
ciImage = filter.outputImage;
}
// Create the corrected image
CIContext* ctx = [CIContext contextWithOptions:nil];
CGImageRef cgImage = [ctx createCGImage:ciImage fromRect:[ciImage extent]];
UIImage* final = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
return final;
}
@end
Run Code Online (Sandbox Code Playgroud)
用法:下面给出的示例代码
UIImage *redEyeImage = [UIImage imageNamed:@"redEye.jpg"];
if (redEyeImage) {
UIImage *newRemovedRedEyeImage = [redEyeImage redEyeCorrection];
if (newRemovedRedEyeImage) {
imgView.image = newRemovedRedEyeImage;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1550 次 |
| 最近记录: |