Inherits from | |
Conforms to | |
Framework | Library/Frameworks/QuartzCore.framework |
Availability | Mac OS X v10.4 and later |
Companion guide | |
Declared in | CIImage.h |
Related sample code |
The CIImage
class represents an image. Core Image images are immutable. You use CIImage
objects in conjunction with other Core Image classes, such as CIFilter
, CIContext
, CIVector
, and CIColor
, to take advantage of the built-in Core Image filters when processing images. You can create CIImage
objects with data supplied from a variety of sources, including Quartz 2D images, Core Video image buffers (CVImageBufferRef
), URL-based objects, and NSData
objects.
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.
Core Image defines methods for creating and initializing images. Additional methods that support drawing and initializing an image with an NSBitmapImageRep
object are defined in CIImage Additions Reference.
+ emptyImage
+ imageWithColor:
+ imageWithBitmapData:bytesPerRow:size:format:colorSpace:
+ imageWithCGImage:
+ imageWithCGImage:options:
+ imageWithCGLayer:
+ imageWithCGLayer:options:
+ imageWithContentsOfURL:
+ imageWithContentsOfURL:options:
+ imageWithCVImageBuffer:
+ imageWithCVImageBuffer:options:
+ imageWithData:
+ imageWithData:options:
+ imageWithImageProvider:size:format:colorSpace:options:
+ imageWithTexture:size:flipped:colorSpace:
– initWithColor:
– initWithBitmapData:bytesPerRow:size:format:colorSpace:
– initWithCGImage:
– initWithCGImage:options:
– initWithCGLayer:
– initWithCGLayer:options:
– initWithContentsOfURL:
– initWithContentsOfURL:options:
– initWithCVImageBuffer:
– initWithCVImageBuffer:options:
– initWithData:
– initWithData:options:
– initWithImageProvider:size:format:colorSpace:options:
– initWithTexture:size:flipped:colorSpace:
Creates and returns an empty image object.
+ (CIImage *)emptyImage
An image object.
CIImage.h
Creates and returns an image object from bitmap data.
+ (CIImage *)imageWithBitmapData:(NSData *)d bytesPerRow:(size_t)bpr size:(CGSize)size format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs
The bitmap data for the image. This data must be premultiplied.
The number of bytes per row.
The dimensions of the image.
The format and size of each pixel. You must supply a pixel format constant. See “Pixel Formats”
.
The color space that the image is defined in. If this value is nil
, the image is not color matched. Pass nil
for images that don’t contain color data (such as elevation maps, normal vector maps, and sampled function tables).
An image object.
CIImage.h
Creates and returns an image object from a Quartz 2D image.
+ (CIImage *)imageWithCGImage:(CGImageRef)image
A Quartz 2D image (CGImageRef
) object. For more information, see Quartz 2D Programming Guide and CGImage Reference.
An image object initialized with the contents of the Quartz 2D image.
CIImage.h
Creates and returns an image object from a Quartz 2D image using the specified color space.
+ (CIImage *)imageWithCGImage:(CGImageRef)image options:(NSDictionary *)d
A Quartz 2D image (CGImageRef
) object. For more information, see Quartz 2D Programming Guide and CGImage Reference.
A dictionary that contains a color space key (kCIImageColorSpace
) whose value is a CGColorSpace
object. (See CGColorSpaceRef
.)
An image object initialized with the contents of the Quartz 2D image and the specified color space.
CIImage.h
Creates and returns an image object from the contents supplied by a CGLayer
object.
+ (CIImage *)imageWithCGLayer:(CGLayerRef)layer
A CGLayer
object. For more information see Quartz 2D Programming Guide and CGLayer Reference.
An image object initialized with the contents of the layer object.
CIImage.h
Creates and returns an image object from the contents supplied by a CGLayer
object, using the specified options.
+ (CIImage *)imageWithCGLayer:(CGLayerRef)layer options:(NSDictionary *)d
A CGLayer
object. For more information see Quartz 2D Programming Guide and CGLayer Reference.
A dictionary that contains options for creating an image object. You can supply such options as a pixel format and a color space. See “Pixel Formats.”
An image object initialized with the contents of the layer object and set up with the specified options.
CIImage.h
Creates and returns an image of infinite extent that is initialized the specified color.
+ (CIImage *)imageWithColor:(CIColor *)color
A color object.
The image object initialized with the color represented by the CIColor
object.
CIImage.h
Creates and returns an image object from the contents of a file.
+ (CIImage *)imageWithContentsOfURL:(NSURL *)url
The location of the file.
An image object initialized with the contents of the file.
CIImage.h
Creates and returns an image object from the contents of a file, using the specified options.
+ (CIImage *)imageWithContentsOfURL:(NSURL *)url options:(NSDictionary *)d
The location of the file.
A dictionary that contains options for creating an image object. You can supply such options as a pixel format and a color space. See “Pixel Formats.”
An image object initialized with the contents of the file and set up with the specified options.
CIImage.h
Creates and returns an image object from the contents of CVImageBuffer
object.
+ (CIImage *)imageWithCVImageBuffer:(CVImageBufferRef)imageBuffer
A CVImageBuffer
object. For more information, see Core Video Programming Guide and Core Video Reference.
An image object initialized with the contents of the image buffer object.
CIImage.h
Creates and returns an image object from the contents of CVImageBuffer
object, using the specified options.
+ (CIImage *)imageWithCVImageBuffer:(CVImageBufferRef)imageBuffer options:(NSDictionary *)dict
A CVImageBuffer
object. For more information, see Core Video Programming Guide and Core Video Reference.
A dictionary that contains options for creating an image object. You can supply such options as a color space. (The pixel format is supplied by the CVImageBuffer
object.)
An image object initialized with the contents of the image buffer object and set up with the specified options.
CIImage.h
Creates and returns an image object initialized with the supplied image data.
+ (CIImage *)imageWithData:(NSData *)data
The data object that holds the contents of an image file (such as TIFF, GIF, JPG, or whatever else the system supports). The image data must be premultiplied.
An image object initialized with the supplied data, or nil
if the method cannot create an image representation from the contents of the supplied data object.
CIImage.h
Creates and returns an image object initialized with the supplied image data, using the specified options.
+ (CIImage *)imageWithData:(NSData *)data options:(NSDictionary *)d
A pointer to the image data. The data must be premultiplied
A dictionary that contains options for creating an image object. You can supply such options as a pixel format and a color space. See “Pixel Formats”
.
An image object initialized with the supplied data and set up with the specified options.
CIImage.h
Creates and returns an image object initialized with data provided by an image provider.
+ (CIImage *)imageWithImageProvider:(id)p size:(size_t)width :(size_t)height format(CIFormat)f colorSpace:(CGColorSpaceRef)cs options:(NSDictionary *)dict
A data provider that implements the CIImageProvider
informal protocol. Core Image retains this data until the image is deallocated.
The width of the image.
The height of the image.
A pixel format constant. See “Pixel Formats”
.
The color space that the image is defined in. If the this value is nil
, the image is not color matched. Pass nil
for images that don’t contain color data (such as elevation maps, normal vector maps, and sampled function tables).
A dictionary that specifies image-creation options, which can be kCIImageProviderTileSize
or kCIImageProviderUserInfo
. See CIImageProvider Protocol Reference for more information on these options.
An image object initialized with the data from the data provider. Core Image does not populate the image object until the object needs the data.
CIImageProvider.h
Creates and returns an image object initialized with data supplied by an OpenGL texture.
+ (CIImage *)imageWithTexture:(unsigned int)name size:(CGSize)size flipped:(BOOL)flag colorSpace:(CGColorSpaceRef)cs
An OpenGL texture. Because CIImage
objects are immutable, the texture must remain unchanged for the life of the image object. See the discussion for more information.
The dimensions of the texture.
YES
to have Core Image flip the contents of the texture vertically.
The color space that the image is defined in. If the colorSpace
value is nil
, the image is not color matched. Pass nil
for images that don’t contain color data (such as elevation maps, normal vector maps, and sampled function tables).
An image object initialized with the texture data.
When using a texture to create a CIImage
object, the texture must be valid in the Core Image context (CIContext
) that you draw the CIImage
object into. This means that one of the following must be true:
The texture must be created using the CGLContext
object that the CIContext
is based on.
The context that the texture was created in must be shared with the CGLContext
that the CIContext
is based on.
Note that textures do not have a retain and release mechanism. This means that your application must make sure that the texture exists for the life cycle of the image. When you no longer need the image, you can delete the texture.
Core Image ignores the texture filtering and wrap modes (GL_TEXTURE_FILTER
and GL_TEXTURE_WRAP
) that you set through OpenGL. The filter and wrap modes are overridden by what the CISampler object specifies when you apply a filter to the CIImage
object.
CIImage.h
Returns a filter shape object that represents the domain of definition of the image.
- (CIFilterShape *)definition
A filter shape object.
CIImage.h
Returns a rectangle that specifies the extent of the image.
- (CGRect)extent
A rectangle that specifies the extent of the image in working space coordinates.
CIImage.h
Returns a new image that represents the original image after applying an affine transform.
- (CIImage *)imageByApplyingTransform:(CGAffineTransform)matrix
An affine transform.
The transformed image object.
CIImage.h
Returns a new image that represents the original image after cropping to a rectangle.
- (CIImage *)imageByCroppingToRect:(CGRect)r
An image object cropped to the specified rectangle.
CIImage.h
Initializes an image object with bitmap data.
- (id)initWithBitmapData:(NSData *)d bytesPerRow:(size_t)bpr size:(CGSize)size format:(CIFormat)f colorSpace:(CGColorSpaceRef)c
The bitmap data to use for the image. The data you supply must be premultiplied.
The number of bytes per row.
The size of the image data.
A pixel format constant. See “Pixel Formats”
.
The color space that the image is defined in and must be a Quartz 2D color space (CGColorSpaceRef
). Pass nil
for images that don’t contain color data (such as elevation maps, normal vector maps, and sampled function tables).
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object with a Quartz 2D image.
- (id)initWithCGImage:(CGImageRef)image
A Quartz 2D image (CGImageRef
) object. For more information, see Quartz 2D Programming Guide and CGImage Reference.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object with a Quartz 2D image, using the specified options.
- (id)initWithCGImage:(CGImageRef)image options:(NSDictionary *)d
A Quartz 2D image (CGImageRef
) object. For more information, see Quartz 2D Programming Guide and CGImage Reference.
A dictionary that contains options for creating an image object. You can supply such options as a pixel format and a color space. See “Pixel Formats”
.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object from the contents supplied by a CGLayer object.
- (id)initWithCGLayer:(CGLayerRef)layer
A CGLayer object. For more information see Quartz 2D Programming Guide and CGLayer Reference.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object from the contents supplied by a CGLayer object, using the specified options.
- (id)initWithCGLayer:(CGLayerRef)layer options:(NSDictionary *)d
A CGLayer object. For more information see Quartz 2D Programming Guide and CGLayer Reference.
A dictionary that contains options for creating an image object. You can supply such options as a pixel format and a color space. See “Pixel Formats”
.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image with the specified color.
- (id)initWithColor:(CIColor *)color
A color object.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object from the contents of a file.
- (id)initWithContentsOfURL:(NSURL *)url
The location of the file.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object from the contents of a file, using the specified options.
- (id)initWithContentsOfURL:(NSURL *)url options:(NSDictionary *)d
The location of the file.
A dictionary that contains options for creating an image object. You can supply such options as a pixel format and a color space. See “Pixel Formats”
.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object from the contents of CVImageBuffer object.
- (id)initWithCVImageBuffer:(CVImageBufferRef)imageBuffer
A CVImageBuffer object. For more information, see Core Video Programming Guide and Core Video Reference.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object from the contents of CVImageBuffer object, using the specified options.
- (id)initWithCVImageBuffer:(CVImageBufferRef)imageBuffer options:(NSDictionary *)dict
A CVImageBuffer object. For more information, see Core Video Programming Guide and Core Video Reference.
A dictionary that contains options for creating an image object. You can supply such options as a color space. (The pixel format is supplied by the CVImageBuffer
object.)
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object with the supplied image data.
- (id)initWithData:(NSData *)data
The image data. The data you supply must be premultiplied.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object with the supplied image data, using the specified options.
- (id)initWithData:(NSData *)data options:(NSDictionary *)d
The image data. The data you supply must be premultiplied.
A dictionary that contains options for creating an image object. You can supply such options as a pixel format and a color space. See “Pixel Formats”
.
The initialized image object or nil
if the object could not be initialized.
CIImage.h
Initializes an image object with data provided by an image provider, using the specified options.
- (id)initWithImageProvider:(id)p size:(size_t)width:(size_t)height format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs options:(NSDictionary *)dict
A data provider that implements the CIImageProvider
informal protocol. Core Image retains this data until the image is deallocated.
The width of the image data.
The height of the image data.
A pixel format constant. See “Pixel Formats”
.
The color space of the image. If this value is nil
, the image is not color matched. Pass nil
for images that don’t contain color data (such as elevation maps, normal vector maps, and sampled function tables).
A dictionary that specifies image-creation options, which can be kCIImageProviderTileSize
or kCIImageProviderUserInfo
. See CIImageProvider Protocol Reference for more information on these options.
The initialized image object or nil
if the object could not be initialized.
Core Image does not populate the image until it actually needs the data.
CIImageProvider.h
Initializes an image object with data supplied by an OpenGL texture.
- (id)initWithTexture:(unsigned int)name size:(CGSize)size flipped:(BOOL)flag colorSpace:(CGColorSpaceRef)cs
An OpenGL texture. Because CIImage
objects are immutable, the texture must remain unchanged for the life of the image object. See the discussion for more information.
The dimensions of the texture.
YES
to have Core Image flip the contents of the texture vertically.
The color space that the image is defined in. This must be a Quartz color space (CGColorSpaceRef
). If the colorSpace
value is nil
, the image is not color matched. Pass nil
for images that don’t contain color data (such as elevation maps, normal vector maps, and sampled function tables).
The initialized image object or nil
if the object could not be initialized.
When using a texture to create a CIImage
object, the texture must be valid in the Core Image context (CIContext
) that you draw the CIImage
object into. This means that one of the following must be true:
The texture must be created using the CGLContext
object that the CIContext
is based on.
The context that the texture was created in must be shared with the CGLContext
that the CIContext
is based on.
Note that textures do not have a retain and release mechanism. This means that your application must make sure that the texture exists for the life cycle of the image. When you no longer need the image, you can delete the texture.
Core Image ignores the texture filtering and wrap modes (GL_TEXTURE_FILTER
and GL_TEXTURE_WRAP
) that you set through OpenGL. The filter and wrap modes are overridden by what the CISampler object specifies when you apply a filter to the CIImage
object.
CIImage.h
Image data pixel formats.
extern CIFormat kCIFormatARGB8; extern CIFormat kCIFormatRGBA16; extern CIFormat kCIFormatRGBAf;
CIFormat
The data type for a pixel format.
kCIFormatARGB8
A 32 bit-per-pixel, fixed-point pixel format.
kCIFormatRGBA16
A 64 bit-per-pixel, fixed-point pixel format.
kCIFormatRGBAf
A 128 bit-per-pixel, floating-point pixel format.
CIImage.h
A key for the color space of an image.
extern NSString *kCIImageColorSpace;
kCIImageColorSpace
The key for a color space. The value you supply for this dictionary key must be a CGColorSpaceRef
data type. For more information on this data type see CGColorSpace Reference. Typically you use this option when you need to load an elevation, mask, normal vector, or RAW sensor data directly from a file without color correcting it. This constant specifies to override Core Image, which, by default, assumes that data is in GenericRGB.
CIImage.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-31)