Photo

public class Photo : Hashable, CustomStringConvertible

Represents an image in a way amenable to the processing we will do on them.

Specification Properties:

  • image : UIImage - the underlying image the photo captures
  • name : String? - The optional name of the photo
  • size : Size - the width and height of the photo
  • pixels : [[Pixel]] - the photo is conceptually a 2d array of pixels

Abstract Invariant:

  • size is the same as image.size, but truncated to integral dimensions.
  • pixels[x,y] is a Pixel with the same color as the image and point (x,y)

This is an immutable class.

  • Optional name for the image (possibly useful for debugging).

    Declaration

    Swift

    public let name: String?
  • The underlying image on which the Photo is based.

    Declaration

    Swift

    public let image: UIImage
  • width and height of the photo.

    Declaration

    Swift

    public let size: Size
  • Create a new photo for an image.

    • Effects: makes a new Photo for the image

    Declaration

    Swift

    public init(_ image : UIImage, named name: String? = nil)

    Parameters

    image

    the image for the photo

    name

    the optional name for the image (useful for debugging)

  • A PhotoSlice for the entire Photo.

    Declaration

    Swift

    public var asSlice: PhotoSlice { get }
  • The Pixel value for (x,y).

    Requires: x,y must be within the bounds of the photo.

    Declaration

    Swift

    public subscript(x: Int, y: Int) -> Pixel { get }
  • Declaration

    Swift

    public var description: String { get }
  • Declaration

    Swift

    public var hashValue: Int { get }
  • Declaration

    Swift

    public static func == (lhs: Photo, rhs: Photo) -> Bool