1

I am having a problem to add filter in CALayer.... here is the code but at the very end there is a line where we adding filter On CALayer..

CIImage *inputImage = [[CIImage alloc]initWithImage:[UIImage imageNamed:@"%d.jpg"]];
CIFilter *minimumComponent = [ CIFilter filterWithName:@"CIMinimumComponent"];
[minimumComponent setValue:inputImage forKey:@"inputImage"];
[minimumComponent setDefaults];

CIImage *outputImage = [minimumComponent valueForKey:@"outputImage"];
CIContext *context = [CIContext contextWithOptions:nil];
imageLayer = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];

I guess here is the error

imageLayer = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];

here is the link where i get the idea ...

Community
  • 1
  • 1
sudeveloepr
  • 183
  • 1
  • 1
  • 7
  • What is/isn't happening? What is the error? Also, what is imageLayer? It seems like you're trying to set a `UIImage` into a `CALayer`? Can you please show more code. (Also, do you have an image called "%d.jpg")? – Fogmeister Feb 18 '14 at 11:21

1 Answers1

1

OK, first off I'm not 100% certain what the error you are getting is but I'd suggest changing to something like this...

CIImage *outputImage = [minimumComponent valueForKey:@"outputImage"];
UIImage *uiImage = [UIImage imageWithCIImage:outputImage];
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
  • the error is at the where I mentioned, "incompatible pointer type assigning to 'CAlayer' _strong from UIImage". – sudeveloepr Feb 18 '14 at 11:57
  • @sudeveloepr OK, yeah. Look at my comment on your Q. You are trying to assign a `UIImage` to a `CALayer` which is exactly what I thought. You can't do that, they are two entirely different sorts of objects. You need to put the `UIImage` in a `UIImageView` or something like that. – Fogmeister Feb 18 '14 at 11:59