Im having a trouble with Core image. what I'm doing is getting an image from a UIImageView and then use some code i found in tutorials (I'm new to core Image) but then I want to put the sepia image back into the same same UIImageView when ever I try to put the new image into the view it just disappears I have tested to see if the image view contains an image and it does but it is not visible. any suggestions on what to do?
EDIT: okay I got the sepia filter to work so then I tried posterize and i had the same problem the image just disappears. Here is the code:
CIImage *beginImage = [CIImage imageWithCGImage:[image_view.image CGImage]];
context = [CIContext contextWithOptions:nil];
filter = [CIFilter filterWithName:@"CIColorPosterize" keysAndValues:kCIInputImageKey, beginImage,@"inputLevels",[NSNumber numberWithFloat:0.8], nil];
CIImage *outputImage = [filter outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newImg = [UIImage imageWithCGImage:cgimg];
[image_view setImage:newImg];
CGImageRelease(cgimg);
Try something like this (let say you have an UIImageView *myImageView)
CIImage *beginImage = [CIImage imageWithCGImage:[myImageView.image CGImage]];
CIContext *context = [CIContext contextWithOptions:nil];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues: kCIInputImageKey, beginImage, @"inputIntensity", [NSNumber numberWithFloat:0.8], nil];
CIImage *outputImage = [filter outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newImg = [UIImage imageWithCGImage:cgimg];
[myImageView setImage:newImg];
CGImageRelease(cgimg);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With