Class

NSImageRep

A semiabstract superclass that provides subclasses that you use to draw an image from a particular type of source data.

Declaration

@interface NSImageRep : NSObject

Overview

The NSImageRep class is called “semiabstract” because it has some instance variables and implementation of its own, in addition to defining subclasses. Although an NSImageRep subclass can be used directly, it is typically accessed through an NSImage object, which manages a group of image representations, choosing the best one for the current output device.

Topics

Creating an Image Representation

+ imageRepsWithContentsOfFile:

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

+ imageRepsWithPasteboard:

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

+ imageRepsWithContentsOfURL:

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

+ imageRepWithContentsOfFile:

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

+ imageRepWithPasteboard:

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

+ imageRepWithContentsOfURL:

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

Determining the Supported Image Types

+ canInitWithData:

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

+ canInitWithPasteboard:

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

imageTypes

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

imageUnfilteredTypes

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

+ imageFileTypes

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

Deprecated
+ imagePasteboardTypes

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

Deprecated
+ imageUnfilteredFileTypes

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

Deprecated
+ imageUnfilteredPasteboardTypes

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

Deprecated

Accessing the Size of the Image

size

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

Specifying Information About the Representation

bitsPerSample

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

colorSpaceName

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

alpha

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

opaque

A Boolean value indicating whether the image is opaque.

pixelsHigh

The height of the image, measured in pixels.

pixelsWide

The width of the image, measured in pixels.

layoutDirection

The layout direction for the image.

Device-Specific Value

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

Getting a CGImage

- CGImageForProposedRect:context:hints:

Returns a CGImage capturing the drawing of the receiver.

Drawing the Image

- draw

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

- drawAtPoint:

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

- drawInRect:

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

- drawInRect:fromRect:operation:fraction:respectFlipped:hints:

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

NSImageHintKey

Constants for the keys to include in a hints dictionary when drawing the image.

Managing NSImageRep Subclasses

+ imageRepClassForType:

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

+ imageRepClassForData:

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

+ imageRepClassForFileType:

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

Deprecated
+ imageRepClassForPasteboardType:

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

Deprecated
registeredImageRepClasses

Returns an array containing the registered NSImageRep classes.

+ registerImageRepClass:

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

+ unregisterImageRepClass:

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

Notifications

NSImageRepRegistryDidChangeNotification

Posted whenever the NSImageRep class registry changes.

Relationships

Inherits From

Conforms To

See Also

Images

Providing Images for Different Appearances

Supply image resources that work for light and dark appearances and for high-contrast environments.

NSImage

A high-level interface for manipulating image data.

NSImageDelegate

A set of optional methods that you can use to respond to drawing failures and manage incremental loads.