谁能告诉我为什么UIImage.ciimage为null [英] Could anyone tell me why UIImage.ciimage is null
问题描述
我发现在IOS中 UIImage 可以改为 CIImage 。在UIImage中有一个属性CIImage。当我使用UIImage时,UIImage对象不为null但 UIImage.ciimage
为空,为什么?
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
例如,下面的代码返回null:
for example, the code like below return null:
UIImage *image = [UIImage imageNamed:@"test.jpg"];
CIImage *ciImage = image.CIImage
但如果以这种方式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];
推荐答案
这是因为这个UIImage实际上不是CIImage 。换句话说,UIImage的 CIImage
只有在UIImage已经由CIImage支持时才会为零(例如,因为它是由 imageWithCIImage生成的:
)。您无法使用它来神奇地将UIImage变成CIImage,正如您似乎希望的那样。
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.
这篇关于谁能告诉我为什么UIImage.ciimage为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!