Search code examples
iphoneios

Could anyone tell me why UIImage.ciimage is null


I found that in IOS UIImage can change to CIImage.and there is a property CIImage in UIImage. and when i use the UIImage,UIImage object is not null but UIImage.ciimage is null ,why?

forgive my stupid question if someone can help me ,thank you very much.


ADD

for example, the code like below return null:

UIImage *image = [UIImage imageNamed:@"test.jpg"];
CIImage *ciImage = image.CIImage

but if in this way CIImage is not null:

UIImage *image = [UIImage imageNamed:@"test.jpg"];
CIImage *myImage = [[CIImage alloc] initWithCGImage:image.CGImage options:nil];

Solution

  • It is because this UIImage is not in fact a CIImage. In other words, UIImage's CIImage is not nil only if the UIImage is backed by a CIImage already (e.g. because it was generated by imageWithCIImage:). You can't use this to magically turn the UIImage into a CIImage, as you seem to be hoping to do.

    The documentation is actually pretty clear on this. Always worth a read.