欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新
页面位置 : > > > 内容正文

iOS 图像处理-调整图像亮度

来源: 开发者 投稿于  被查看 38279 次 评论:87

iOS 图像处理-调整图像亮度


- (UIImage*) getBrighterImage:(UIImage *)originalImage
{
    UIImage *brighterImage;
    CIContext *context = [CIContext contextWithOptions:nil];
    CIImage *inputImage = [CIImage imageWithCGImage:originalImage.CGImage];

    CIFilter *lighten = [CIFilter filterWithName:@CIColorControls];
    [lighten setValue:inputImage forKey:kCIInputImageKey];
    [lighten setValue:@(0.3) forKey:@inputBrightness];
    
    CIImage *result = [lighten valueForKey:kCIOutputImageKey];
    CGImageRef cgImage = [context createCGImage:result fromRect:[inputImage extent]];
    brighterImage = [UIImage imageWithCGImage:cgImage];
    CGImageRelease(cgImage);
    
    return brighterImage;
}

 

 

用户评论