Class

NSImageRep

The NSImageRep class is a semiabstract superclass (“semi” because it has some instance variables and implementation of its own). Each of its subclasses knows how to draw an image from a particular kind of source data. While an NSImageRep subclass can be used directly, it is typically through an NSImage object. An NSImage object manages a group of image representations, choosing the best one for the current output device.

Symbols

Creating an NSImageRep

class func imageReps(withContentsOfFile: String)

Creates and returns an array of image representation objects initialized using the contents of the specified file.

class func imageReps(with: NSPasteboard)

Creates and returns an array of image representation objects initialized using the contents of the pasteboard.

class func imageReps(withContentsOf: URL)

Creates and returns an array of image representation objects initialized using the contents of the specified URL.

init?(contentsOfFile: String)

Creates and returns an image representation object using the contents of the specified file.

init?(pasteboard: NSPasteboard)

Creates and returns an image representation object using the contents of the specified pasteboard.

init?(contentsOf: URL)

Creates and returns an image representation object using the data at the specified URL

Determining the Supported Image Types

class func canInit(with: Data)

Returns a Boolean value indicating whether the receiver can initialize itself from the specified data.

class func canInit(with: NSPasteboard)

Returns a Boolean value indicating whether the receiver can initialize itself from the data on the specified pasteboard.

class func imageTypes()

Returns an array of UTI strings identifying the image types supported by the receiver, either directly or through a user-installed filter service.

class func imageUnfilteredTypes()

Returns an array of UTI strings identifying the image types supported directly by the receiver.

class func imageFileTypes()

Returns the file types supported by NSImageRep or one of its subclasses.

Deprecated
class func imagePasteboardTypes()

Returns the pasteboard types supported by NSImageRep or one of its subclasses.

Deprecated
class func imageUnfilteredFileTypes()

Returns the list of file types supported directly by the receiver.

Deprecated
class func imageUnfilteredPasteboardTypes()

Returns the list of pasteboard types supported directly by the receiver.

Deprecated

Accessing the Size of the Image

var size: NSSize

The size of the image representation, measured in points in the user coordinate space.

Specifying Information About the Representation

var bitsPerSample: Int

The number of bits per sample in the object (if the object is a planar image, this property contains the number of bits per sample per plane).

var colorSpaceName: String

The name of the color space used by the image data.

var hasAlpha: Bool

A Boolean value indicating whether the image data has an alpha channel.

var isOpaque: Bool

A Boolean value indicating whether the image is opaque.

var pixelsHigh: Int

The height of the image, measured in pixels.

var pixelsWide: Int

The width of the image, measured in pixels.

Drawing the Image

func draw()

Implemented by subclasses to draw the image in the current coordinate system.

func draw(at: NSPoint)

Draws the receiver's image data at the specified point in the current coordinate system.

func draw(in: NSRect)

Draws the image, scaling it (as needed) to fit the specified rectangle.

func draw(in: NSRect, from: NSRect, operation: NSCompositingOperation, fraction: CGFloat, respectFlipped: Bool, hints: [String : Any]?)

Draws all or part of the image in the specified rectangle in the current coordinate system.

Managing NSImageRep Subclasses

class func `class`(forType: String)

Returns the NSImageRep subclass that handles image data for the specified UTI.

class func `class`(for: Data)

Returns the NSImageRep subclass that handles the specified type of data.

class func `class`(forFileType: String)

Returns the NSImageRep subclass that handles data with the specified type.

Deprecated
class func `class`(forPasteboardType: String)

Returns the NSImageRep subclass that handles data with the specified pasteboard type.

Deprecated
class func registeredClasses()

Returns an array containing the registered NSImageRep classes.

class func registerClass(AnyClass)

Adds the specified class to the registry of available NSImageRep subclasses.

class func unregisterClass(AnyClass)

Removes the specified NSImageRep subclass from the registry of available image representations.

Constants

Display Device Matching

The following constant is used by NSImageRep to denote an attribute whose value changes to match the display device.

Notifications

static let NSImageRepRegistryDidChange: NSNotification.Name

Posted whenever the NSImageRep class registry changes.

Relationships

Inherits From