NSImage vs.CIImage vs.CGImage? [英] NSImage vs. CIImage vs. CGImage?

查看:223
本文介绍了NSImage vs.CIImage vs.CGImage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该何时使用每个?

推荐答案

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:


虽然CIImage对象具有与其关联的图像数据,但它不是图像。您可以将CIImage对象视为图像配方.CIImage对象具有生成映像所需的所有信息,但Core Image实际上不会渲染图像,直到它被告知这样做。这个延迟评估方法允许Core Image尽可能高效地运行。

Although a CIImage object has image data associated with it, it is not an image. You can think of a CIImage object as an image "recipe." A CIImage object has all the information necessary to produce an image, but Core Image doesn’t actually render an image until it is told to do so. This "lazy evaluation" method allows Core Image to operate as efficiently as possible.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆