Skip to content

Instantly share code, notes, and snippets.

@betzerra
Created December 10, 2012 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betzerra/4248239 to your computer and use it in GitHub Desktop.
Save betzerra/4248239 to your computer and use it in GitHub Desktop.
Sepia Image
// Image processing: creating CIImage
NSString *filename = [module.imageFilename stringByDeletingPathExtension];
NSString *fileExtension = [module.imageFilename pathExtension];
NSString *filePath = [[NSBundle mainBundle] pathForResource:filename ofType:fileExtension];
NSURL *fileURL = [NSURL fileURLWithPath:filePath];
CIImage *coreImage = [CIImage imageWithContentsOfURL:fileURL];
CIContext *context = [CIContext contextWithOptions:nil];
// Image processing: applying filter
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"
keysAndValues: kCIInputImageKey, coreImage,
@"inputIntensity", [NSNumber numberWithFloat:0.8], nil];
coreImage = [filter outputImage];
// Image processing: converting CIImage to UIImage
CGImageRef cgimg = [context createCGImage:coreImage fromRect:[coreImage extent]];
UIImage *anImage = [UIImage imageWithCGImage:cgimg];
imageView.image = anImage;
CGImageRelease(cgimg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment