Type Method

imageWithTexture:size:flipped:colorSpace:

Creates and returns an image object initialized with data supplied by an OpenGL texture.

Declaration

+ (CIImage *)imageWithTexture:(unsigned int)name size:(CGSize)size flipped:(BOOL)flipped colorSpace:(CGColorSpaceRef)colorSpace;

Parameters

name

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

The dimensions of the texture.

flag

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

cs

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

Return Value

An image object initialized with the texture data.

Discussion

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 Core Image context is based on.

  • The context that the texture was created in must be shared with the CGLContext that the Core Image context 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.

See Also

Creating an Image

+ emptyImage

Creates and returns an empty image object.

+ imageWithColor:

Creates and returns an image of infinite extent whose entire content is the specified color.

+ imageWithBitmapData:bytesPerRow:size:format:colorSpace:

Creates and returns an image object from bitmap data.

+ imageWithCGImage:

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

+ imageWithCGImage:options:

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

+ imageWithCGLayer:

Creates and returns an image object from the contents supplied by a CGLayer object.

Deprecated
+ imageWithCGLayer:options:

Creates and returns an image object from the contents supplied by a CGLayer object, using the specified options.

Deprecated
+ imageWithContentsOfURL:

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

+ imageWithContentsOfURL:options:

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

+ imageWithCVImageBuffer:

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

+ imageWithCVImageBuffer:options:

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

+ imageWithCVPixelBuffer:

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

+ imageWithCVPixelBuffer:options:

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

+ imageWithData:

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

+ imageWithData:options:

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

+ imageWithImageProvider:size::format:colorSpace:options:

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

+ imageWithTexture:size:flipped:options:

Creates and returns an image object initialized with data supplied by an OpenGL texture.

Deprecated
+ imageWithMTLTexture:options:

Creates and returns an image object with data supplied by a Metal texture.

+ imageWithIOSurface:

Creates and returns an image from the contents of an IOSurface.

+ imageWithIOSurface:options:

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software