Class: CIImage

Inherits:
NSObject show all

Overview

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.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Class Method Details

+ (CIImage) emptyImage

Creates and returns an empty image object.

Returns:

+ (CIImage) imageWithBitmapData(d, bytesPerRow:bpr, size:size, format:f, colorSpace:cs)

Creates and returns an image object from bitmap data.

Parameters:

  • d (NSData)

    The bitmap data for the image. This data must be premultiplied.

  • bpr (size_t)

    The number of bytes per row.

  • size (CGSize)

    The dimensions of the image.

  • f (CIFormat)

    The format and size of each pixel. You must supply a pixel format constant. See “Pixel Formats”.

  • cs (CGColorSpaceRef)

    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).

Returns:

+ (CIImage) imageWithCGImage(image)

Creates and returns an image object from a Quartz 2D image.

Parameters:

  • image (CGImageRef)

    A Quartz 2D image (CGImageRef) object. For more information, see Quartz 2D Programming Guide and CGImage Reference.

Returns:

  • (CIImage)

    An image object initialized with the contents of the Quartz 2D image.

+ (CIImage) imageWithCGImage(image, options:d)

Creates and returns an image object from a Quartz 2D image using the specified color space.

Parameters:

  • image (CGImageRef)

    A Quartz 2D image (CGImageRef) object. For more information, see Quartz 2D Programming Guide and CGImage Reference.

  • d (Hash)

    A dictionary that contains a color space key (kCIImageColorSpace) whose value is a CGColorSpace object. (See CGColorSpaceRef.)

Returns:

  • (CIImage)

    An image object initialized with the contents of the Quartz 2D image and the specified color space.

+ (CIImage) imageWithColor(color)

Creates and returns an image of infinite extent that is initialized the specified color.

Parameters:

  • color (CIColor)

    A color object.

Returns:

  • (CIImage)

    The image object initialized with the color represented by the CIColor object.

+ (CIImage) imageWithContentsOfURL(url)

Creates and returns an image object from the contents of a file.

Parameters:

  • url (NSURL)

    The location of the file.

Returns:

  • (CIImage)

    An image object initialized with the contents of the file.

+ (CIImage) imageWithContentsOfURL(url, options:d)

Creates and returns an image object from the contents of a file, using the specified options.

Parameters:

  • url (NSURL)

    The location of the file.

  • d (Hash)

    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” and “Color Space Key.”

Returns:

  • (CIImage)

    An image object initialized with the contents of the file and set up with the specified options.

+ (CIImage) imageWithCVPixelBuffer(buffer)

Creates and returns an image object from the contents of CVPixelBuffer object.

Parameters:

  • buffer (CVPixelBufferRef)

    A CVPixelBuffer object.

Returns:

  • (CIImage)

    An image object initialized with the contents of the image buffer object.

+ (CIImage) imageWithCVPixelBuffer(buffer, options:dict)

Creates and returns an image object from the contents of CVPixelBuffer object, using the specified options.

Parameters:

  • buffer (CVPixelBufferRef)

    A CVPixelBuffer object.

  • dict (Hash)

    A dictionary that contains options for creating an image object. You can supply such options as a color space. See “Color Space Key.” (The pixel format is supplied by the CVPixelBuffer object.)

Returns:

  • (CIImage)

    An image object initialized with the contents of the image buffer object and set up with the specified options.

+ (CIImage) imageWithData(data)

Creates and returns an image object initialized with the supplied image data.

Parameters:

  • data (NSData)

    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.

Returns:

  • (CIImage)

    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) imageWithData(data, options:d)

Creates and returns an image object initialized with the supplied image data, using the specified options.

Parameters:

  • data (NSData)

    A pointer to the image data. The data must be premultiplied

  • d (Hash)

    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” and “Color Space Key.”

Returns:

  • (CIImage)

    An image object initialized with the supplied data and set up with the specified options.

+ (CIImage) imageWithImageProvider(p, size:width, :height, formatf, colorSpace:cs, options:dict)

Creates and returns an image object initialized with data provided by an image provider.

Parameters:

  • p (Object)

    A data provider that implements the CIImageProvider informal protocol. Core Image maintains a strong reference to this object until the image is deallocated.

  • width (size_t)

    The width of the image.

  • height (size_t)

    The height of the image.

  • f (CIFormat)

    A pixel format constant. See “Pixel Formats”.

  • cs (CGColorSpaceRef)

    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).

  • dict (Hash)

    A dictionary that specifies image-creation options, which can be kCIImageProviderTileSize or kCIImageProviderUserInfo. See CIImageProvider Protocol Reference for more information on these options.

Returns:

  • (CIImage)

    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.

+ (CIImage) imageWithTexture(name, size:size, flipped:flag, colorSpace:cs)

Creates and returns an image object initialized with data supplied by an OpenGL texture. 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.

Parameters:

  • name (unsigned int)

    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.

  • size (CGSize)

    The dimensions of the texture.

  • flag (Boolean)

    YES to have Core Image flip the coordinates of the texture vertically to convert between OpenGL and Core Image coordinate systems.

  • cs (CGColorSpaceRef)

    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).

Returns:

  • (CIImage)

    An image object initialized with the texture data.

Instance Method Details

- (CGRect) extent

Returns a rectangle that specifies the extent of the image.

Returns:

  • (CGRect)

    A rectangle that specifies the extent of the image in working space coordinates.

- (CIImage) imageByApplyingTransform(matrix)

Returns a new image that represents the original image after applying an affine transform.

Parameters:

Returns:

  • (CIImage)

    The transformed image object.

- (CIImage) imageByCroppingToRect(r)

Returns a new image that represents the original image after cropping to a rectangle.

Returns:

  • (CIImage)

    An image object cropped to the specified rectangle.

- (Object) initWithBitmapData(d, bytesPerRow:bpr, size:size, format:f, colorSpace:c)

Initializes an image object with bitmap data.

Parameters:

  • d (NSData)

    The bitmap data to use for the image. The data you supply must be premultiplied.

  • bpr (size_t)

    The number of bytes per row.

  • size (CGSize)

    The size of the image data.

  • f (CIFormat)

    A pixel format constant. See “Pixel Formats”.

  • c (CGColorSpaceRef)

    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).

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithCGImage(image)

Initializes an image object with a Quartz 2D image.

Parameters:

  • image (CGImageRef)

    A Quartz 2D image (CGImageRef) object. For more information, see Quartz 2D Programming Guide and CGImage Reference.

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithCGImage(image, options:d)

Initializes an image object with a Quartz 2D image, using the specified options.

Parameters:

  • image (CGImageRef)

    A Quartz 2D image (CGImageRef) object. For more information, see Quartz 2D Programming Guide and CGImage Reference.

  • d (Hash)

    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” and “Color Space Key.”

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithColor(color)

Initializes an image with the specified color.

Parameters:

  • color (CIColor)

    A color object.

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithContentsOfURL(url)

Initializes an image object by reading an image from a URL.

Parameters:

  • url (NSURL)

    The location of the image file to read.

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithContentsOfURL(url, options:d)

Initializes an image object by reading an image from a URL, using the specified options.

Parameters:

  • url (NSURL)

    The location of the image file to read.

  • d (Hash)

    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”.

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithCVPixelBuffer(buffer)

Initializes an image object from the contents of CVPixelBuffer object.

Parameters:

  • buffer (CVPixelBufferRef)

    A CVPixelBuffer object.

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithCVPixelBuffer(buffer, options:dict)

Initializes an image object from the contents of CVPixelBuffer object using the specified options.

Parameters:

  • buffer (CVPixelBufferRef)

    A CVPixelBuffer object.

  • dict (Hash)

    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 CVPixelBuffer object.)

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithData(data)

Initializes an image object with the supplied image data.

Parameters:

  • data (NSData)

    The image data. The data you supply must be premultiplied.

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithData(data, options:d)

Initializes an image object with the supplied image data, using the specified options.

Parameters:

  • data (NSData)

    The image data. The data you supply must be premultiplied.

  • d (Hash)

    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”.

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithImageProvider(p, size:width, format:f, colorSpace:cs, options:dict)

Initializes an image object with data provided by an image provider, using the specified options. Core Image does not populate the image until it actually needs the data.

Parameters:

  • p (Object)

    A data provider that implements the CIImageProvider informal protocol. Core Image maintains a strong reference to this object until the image is deallocated.

  • width (size_t)

    The width of the image data.

  • height (size_t)

    The height of the image data.

  • f (CIFormat)

    A pixel format constant. See “Pixel Formats”.

  • cs (CGColorSpaceRef)

    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).

  • dict (Hash)

    A dictionary that specifies image-creation options, which can be kCIImageProviderTileSize or kCIImageProviderUserInfo. See CIImageProvider Protocol Reference for more information on these options.

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.

- (Object) initWithTexture(name, size:size, flipped:flag, colorSpace:cs)

Initializes an image object with data supplied by an OpenGL texture. 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 CIContextis 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.

Parameters:

  • name (unsigned int)

    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.

  • size (CGSize)

    The dimensions of the texture.

  • flag (Boolean)

    YES to have Core Image flip the coordinates of the texture vertically to convert between OpenGL and Core Image coordinate systems.

  • cs (CGColorSpaceRef)

    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).

Returns:

  • (Object)

    The initialized image object or nil if the object could not be initialized.