Image Manipulation Filter like white Balance, Exposure, split Tone etc on IOS

风流意气都作罢 提交于 2019-11-30 05:24:34
esilver

As the author of ios-image-filters, I can tell you that our project has a levels method that you can use to modify white balance. It is implemented as a category on UIImage and mimics Photoshop filters, so calling it is as straightforward as:

[self.imageView.image levels:0 mid:128 white:255];

Moreover, it's compatible with iOS 3 & 4, not just iOS 5. It's open source and has no dependencies, so it should be easy to modify if you don't find the filter you need.

Ingve

Starting with iOS 5, Core Image filters are available.

A very simplified example, assuming you have added a UIImageView IBOutlet named imageView in Interface Builder, and set it up with an image file.

  1. Add the CoreImage framework.
  2. #import <CoreImage/CoreImage.h>
  3. In viewDidLoad, add the following:

    CIImage *inputImage = [[CIImage alloc] initWithImage:self.imageView.image];
    CIFilter *exposureAdjustmentFilter = [CIFilter filterWithName:@"CIExposureAdjust"];
    [exposureAdjustmentFilter setDefaults];
    [exposureAdjustmentFilter setValue:inputImage forKey:@"inputImage"];
    [exposureAdjustmentFilter setValue:[NSNumber numberWithFloat:5.0f] forKey:@"inputEV"];
    CIImage *outputImage = [exposureAdjustmentFilter valueForKey:@"outputImage"];
    CIContext *context = [CIContext contextWithOptions:nil];
    self.imageView.image = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];
    

Another option might be to use the filters from the GitHub ios-image-filters project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!