init(texture:size:flipped:colorSpace:)
Initializes an image object with data supplied by an OpenGL texture.
Declaration
init(texture name: UInt32, size: CGSize, flipped: Bool, colorSpace: CGColorSpace?)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.
- flipped:
trueto have Core Image flip the coordinates of the texture vertically to convert between OpenGL and Core Image coordinate systems. - colorSpace:
The color space that the image is defined in. This must be a Quartz color space (Cgcolorspace). If the
colorSpacevalue isnil, the image is not color matched. Passnilfor images that don’t contain color data (such as elevation maps, normal vector maps, and sampled function tables).
Return Value
The initialized image object.
Discussion
When you use 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
CGLContextobject that the CIContext is based on.The context that the texture was created in must be shared with the
CGLContextthat 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.