问题描述
我应该何时使用每个?
推荐答案
NSImage是一种抽象数据类型,可以表示许多不同类型的图像,以及图像的多个表示。当实际类型的图像对于你想要做的事情不重要时,它通常是有用的。它也是AppKit在其API(NSImageView等)中接受的唯一的图像类。
NSImage is an abstract data type that can represent many different types of images, as well as multiple representations of an image. It is often useful when the actual type of image is not important for what you're trying to do. It is also the only image class that AppKit will accept in its APIs (NSImageView and so forth).
CGImage只能表示位图。如果你需要下来和脏的实际位图数据,CGImage是一个合适的类型使用。 CoreGraphics中的操作(如混合模式和屏蔽)需要CGImageRefs。 CGImageRefs可用于创建NSBitmapImageRefs,然后可以将其添加到NSImage。
CGImage can only represent bitmaps. If you need to get down and dirty with the actual bitmap data, CGImage is an appropriate type to use. The operations in CoreGraphics, such as blend modes and masking, require CGImageRefs. CGImageRefs can be used to create NSBitmapImageRefs, which can then added to an NSImage.
我认为文档最好描述一个CIImage:
I think the documentation describes a CIImage best:
CIImages是使用各种GPU-优化的Core Image过滤器,但是,像CGImageRefs,它们也可以转换为NSBitmapImageReps。
CIImages are the type required to use the various GPU-optimized Core Image filters that come with Mac OS X, but, like CGImageRefs, they can also be converted to NSBitmapImageReps.
这篇关于NSImage vs.CIImage vs.CGImage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!