Image

public class Image: View, NSCopying

A Image provides a view-based container for displaying a single image. You can create images from files, from other image objects, or from raw image data you receive.

  • C4Shape’s contents are drawn on a ShapeLayer.

    Declaration

    Swift

    public var imageLayer: ImageLayer
  • Initializes an empty Image

    Declaration

    Swift

    public override init()
  • Undocumented

    Declaration

    Swift

    public class Image: View, NSCopying
  • Initializes a new Image using the specified filename from the bundle (i.e. your project), it will also grab images from the web if the filename starts with http. let img = Image("logo") canvas.add(img) - parameter name: The name of the image included in your project, or a web address.

    Declaration

    Swift

    convenience public init?(_ name: String)

    Parameters

    name

    The name of the image included in your project, or a web address.

  • Initializes a new Image using the specified filename from the bundle (i.e. your project), it will also grab images from the web if the filename starts with http. let img = Image("http://www.c4ios.com/images/logo@2x.png", scale: 2.0) canvas.add(img) - parameter name: The name of the image included in your project, or a web address.

    Declaration

    Swift

    convenience public init?(_ name: String, scale: Double)

    Parameters

    name

    The name of the image included in your project, or a web address.

  • Initializes a new Image using an existing Image (basically like copying). let a = Image("logo") canvas.add(a) let b = Image(image: a) b.center = canvas.center canvas.add(b) - parameter image: A Image.

    Declaration

    Swift

    convenience public init(copy image: Image)

    Parameters

    image

    A Image.

  • Initializes a new Image using a UIImage. if let uii = UIImage(named:"logo") { let img = Image(uiimage: uii) canvas.add(img) } - parameter uiimage: A UIImage object.

    Declaration

    Swift

    convenience public init(uiimage: UIImage)

    Parameters

    uiimage

    A UIImage object.

  • Initializes a new Image using a UIImage, with option for specifying the scale of the image. if let uii = UIImage(named:"logo") { let img = Image(uiimage: uii, scale: 2.0) canvas.add(img) } - parameter uiimage: A UIImage object. - parameter scale: A Double should be larger than 0.0

    Declaration

    Swift

    convenience public init(uiimage: UIImage, let scale: Double)

    Parameters

    uiimage

    A UIImage object.

    scale

    A Double should be larger than 0.0

  • Initializes a new Image using a CGImageRef. let cgi = CGImageCreate() let img = Image(cgimage: cgi) canvas.add(img) Example - parameter cgimage: A CGImageRef object.

    Declaration

    Swift

    convenience public init(cgimage: CGImageRef)

    Parameters

    cgimage

    A CGImageRef object.

  • Initializes a new Image using a CGImageRef, with option for specifying the scale of the image. let cgi = CGImageCreate() let img = Image(cgimage: cgi, scale: 2.0) canvas.add(img) - parameter cgimage: A CGImageRef object. - parameter scale: The scale of the image.

    Declaration

    Swift

    convenience public init(cgimage: CGImageRef, scale: Double)

    Parameters

    cgimage

    A CGImageRef object.

    scale

    The scale of the image.

  • Initializes a new Image using a CIImage. Use this method if you’re working with the output of a CIFilter. - parameter ciimage: A CIImage object.

    Declaration

    Swift

    convenience public init(ciimage: CIImage)

    Parameters

    ciimage

    A CIImage object.

  • Initializes a new Image using a CIImage, with option for specifying the scale of the image. Use this method if you’re working with the output of a CIFilter. - parameter ciimage: A CIImage object. - parameter scale: The scale of the image.

    Declaration

    Swift

    convenience public init(ciimage: CIImage, scale: Double)

    Parameters

    ciimage

    A CIImage object.

    scale

    The scale of the image.

  • Initializes a new Image using raw data. Use this if you download an image as data you can pass it here to create an image. See the body of init(url:) to see how to download an image as data. - parameter data: An NSData object.

    Declaration

    Swift

    convenience public init(data: NSData)

    Parameters

    data

    An NSData object.

  • Initializes a new Image using raw data, with option for specifying the scale of the image. Use this if you download an image as data you can pass it here to create an image. See the body of init(url:) to see how to download an image as data. - parameter data: An NSData object. - parameter scale: The scale of the image.

    Declaration

    Swift

    convenience public init(data: NSData, scale: Double)

    Parameters

    data

    An NSData object.

    scale

    The scale of the image.

  • Initializes a new Image from an URL. if let url = NSURL(string: "http://www.c4ios.com/images/logo@2x.png") { let img = Image(url: url) canvas.add(img) } - parameter url: An NSURL object.

    Declaration

    Swift

    convenience public init(url: NSURL)

    Parameters

    url

    An NSURL object.

  • Initializes a new Image from an URL, with option for specifying the scale of the image. if let url = NSURL(string: "http://www.c4ios.com/images/logo@2x.png") { let img = Image(url: url, scale: 2.0) canvas.add(img) } - parameter url: An NSURL object. - parameter scale: The scale of the image.

    Declaration

    Swift

    convenience public init(url: NSURL, scale: Double)

    Parameters

    url

    An NSURL object.

    scale

    The scale of the image.

  • Initializes a new Image using raw data. This method differs from Image(data:...) in that you can pass an array of raw data to the initializer. This works if you’re creating your own raw images by changing the values of individual pixels. Pixel data should be RGBA. - parameter pixels: An array of raw pixel data. - parameter size: The size {w, h} of the image you’re creating based on the pixel array.

    Declaration

    Swift

    convenience public init(pixels: [Pixel], size: Size)

    Parameters

    pixels

    An array of raw pixel data.

    size

    The size {w, h} of the image you’re creating based on the pixel array.

  • Initializes a new Image using another image. - parameter c4image: An Image around which the new image is created.

    Declaration

    Swift

    convenience public init(c4image: Image)

    Parameters

    c4image

    An Image around which the new image is created.

  • Initializes a new copy of the receiver. - parameter zone: This parameter is ignored. Memory zones are no longer used by Objective-C. - returns: a new instance that’s a copy of the receiver.

    Declaration

    Swift

    public func copyWithZone(zone: NSZone) -> AnyObject

    Parameters

    zone

    This parameter is ignored. Memory zones are no longer used by Objective-C.

    Return Value

    a new instance that’s a copy of the receiver.

  • Returns a UIImage representation of the receiver. - returns: A UIImage object.

    Declaration

    Swift

    public var uiimage: UIImage

    Return Value

    A UIImage object.

  • Returns a CGImageRef representation of the receiver. - returns: A CGImageRef object.

    Declaration

    Swift

    public var cgimage: CGImageRef

    Return Value

    A CGImageRef object.

  • Returns a CIImage representation of the receiver. Generally, this would be used to work with filters. - returns: A CIImage object.

    Declaration

    Swift

    public var ciimage: CIImage

    Return Value

    A CIImage object.

  • An object that provides the contents of the layer. Animatable. The default value of this property is nil. If you are using the layer to display a static image, you can set this property to the CGImageRef containing the image you want to display. Assigning a value to this property causes the layer to use your image rather than create a separate backing store.

    Declaration

    Swift

    public var contents: CGImage
  • The current rotation value of the view. Animatable. - returns: A Double value representing the cumulative rotation of the view, measured in Radians.

    Declaration

    Swift

    public override var rotation: Double

    Return Value

    A Double value representing the cumulative rotation of the view, measured in Radians.

  • A variable that provides access to the width of the receiver. Animatable. The default value of this property is defined by the image being created. Assigning a value to this property causes the receiver to change the width of its frame. If the receiver’s contrainsProportions variable is set to true the receiver’s height will change to match the new width.

    Declaration

    Swift

    public override var width: Double
  • A variable that provides access to the height of the receiver. Animatable. The default value of this property is defined by the image being created. Assigning a value to this property causes the receiver to change the height of its frame. If the receiver’s contrainsProportions variable is set to true the receiver’s width will change to match the new width.

    Declaration

    Swift

    public override var height: Double
  • Assigning a value of true to this property will cause the receiver to scale its entire frame whenever its width or height variables are set. The default value of this property is false.

    Declaration

    Swift

    public var constrainsProportions: Bool = false
  • The original size of the receiver when it was initialized.

    Declaration

    Swift

    public var originalSize: Size
  • The original width/height ratio of the receiver when it was initialized.

    Declaration

    Swift

    public var originalRatio: Double
  • Crops the receiver’s contents to the specified frame within the receiver’s coordinate space.

    Declaration

    Swift

    public func crop(rect: Rect)

    Parameters

    rect

    a Rect

  • Applies a fiter to the receiver’s contents.

    Declaration

    Swift

    public func apply(filter: Filter)

    Parameters

    filter

    a Filter

  • Applies an array of fiters to the receiver’s contents.

    Declaration

    Swift

    public func apply(filters filters: [Filter])

    Parameters

    filters

    an array of Filter objects

  • Applies a generator to the receiver’s contents.

    Declaration

    Swift

    public func generate(generator: Generator)

    Parameters

    generator

    a Generator