Copyright ã1994 by NeXT Computer, Inc.  All Rights Reserved.

NSImageRep 

Inherits From:	NSObject

Conforms To:	NSCoding, NSCopying
NSObject (NSObject)

Declared In:	AppKit/NSImageRep.h 

Class Description

NSImageRep is an abstract superclass; 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's typically used through an NSImage object.  An NSImage manages a group of representations, choosing the best one for the current output device.

There are four subclasses defined in the Application Kit:

Subclass	Source Data

NSBitmapImageRep	Tag Image File Format (TIFF) and other bitmap data
NSEPSImageRep	Encapsulated PostScript code (EPS)
NSCustomImageRep	A delegated method that can draw the image
NSCachedImageRep	A rendered image, usually in an off-screen window

You can define other NSImageRep subclasses for objects that render images from other types of source information.  New subclasses must be added to the NSImageRep class registry by invoking the registerImageRepClass: class method.  The NSImageRep subclass informs the registry of the data types it can support through its imageUnfilteredFileTypes,  imageUnfilteredPasteboardTypes, and canInitWithData: class methods.  Once an NSImageRep subclass is registered, an instance of that subclass is created anytime NSImage encounters the type of data handled by that subclass.

Creating an NSImageRep

+ (id)imageRepWithContentsOfFile:(NSString *)filename
	In subclasses that respond to imageFileTypes and imageRepWithData:, returns an object that has been initialized with the data in filename.  NSImageRep's implementation returns an instance of the appropriate registered subclass.

+ (NSArray *)imageRepsWithContentsOfFile:(NSString *)filename
	In subclasses that respond to imageFileTypes and imageRepWithData: (or imageRepWithData:), returns an array of objects that have been initialized with the data in filename.  NSImageRep's implementation returns an array of objects (each an instance of the appropriate registered subclass) that have been initialized with the data in filename.

+ (id)imageRepWithPasteboard:(NSPasteboard *)pasteboard
	In subclasses that respond to imagePasteboardTypes and imageRepWithData:, returns an object that has been initialized with the data in pasteboard.  NSImageRep's implementation returns an instance of the appropriate registered subclass.

+ (NSArray *)imageRepsWithPasteboard:(NSPasteboard *)pasteboard
	In subclasses that respond to imagePasteboardTypes and imageRepsWithData: (or imageRepWithData:), returns an array of objects that have been initialized with the data in pasteboard.  NSImageRep's implementation returns an array of objects (each an instance of the appropriate registered subclass) that have been initialized with the data in pasteboard.

Checking Data Types 

+ (BOOL)canInitWithData:(NSData *)data	Overridden in subclasses to return YES if the receiver can initialize itself from data.

+ (BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard
	Overridden in subclasses to returnYES if the receiver can initialize itself from pasteboard.

+ (NSArray *)imageFileTypes	Returns an array of strings representing all file types.

+ (NSArray *)imagePasteboardTypes	Returns an array of strings representing all pasteboard types.

+ (NSArray *)imageUnfilteredFileTypes	Returns an array of strings representing directly supported file types.

+ (NSArray *)imageUnfilteredPasteboardTypes 	Returns an array of strings representing directly supported
		pasteboards.

Setting the Size of the Image 

- (void)setSize:(NSSize)aSize	Sets the size of the image.

- (NSSize)size	Returns the size of the image.

Specifying Information about the Representation 

- (int)bitsPerSample	Returns the number of bits per pixel in each component.

- (NSString *)colorSpaceName	Returns the name of the image's color space.

- (BOOL)hasAlpha	Returns whether there is a coverage component.

- (BOOL)isOpaque	Returns whether the representation is opaque.

- (int)pixelsHigh	Returns the height specified in the image data.

- (int)pixelsWide	Returns the width specified in the image data.

- (void)setAlpha:(BOOL)flag	Informs the receiver whether there is a coverage component.

- (void)setBitsPerSample:(int)anInt	Informs the receiver there are anInt bits/pixel in a component.

- (void)setColorSpaceName:(NSString *)aString	Informs the receiver of the image's color space.

- (void)setOpaque:(BOOL)flag	Informs the receiver of the image's opacity.

- (void)setPixelsHigh:(int)anInt	Informs the receiver that its data is for an image anInt pixels high.

- (void)setPixelsWide:(int)anInt	Informs the receiver that its data is for an image anInt pixels wide.

Drawing the Image 

- (BOOL)draw	Implemented by subclasses to draw the image.

- (BOOL)drawAtPoint:(NSPoint)aPoint	Modifies current coordinates so the image is drawn at aPoint.

- (BOOL)drawInRect:(NSRect)aRect	Modifies current coordinates so the image is drawn in aRect.

Managing NSImageRep Subclasses 

+ (Class)imageRepClassForData:(NSData *)data	Returns the NSImageRep subclass that handles data of type data.

+ (Class)imageRepClassForFileType:(NSString *)type
	Returns the NSImageRep subclass that handles data of file type type.

+ (Class)imageRepClassForPasteboardType:(NSString *)type
	Returns the NSImageRep subclass that handles data of pasteboard type type.

+ (void)registerImageRepClass:(Class)imageRepClass
	Adds imageRepClass to the registry of available NSImageRep classes. This method posts the NSImageRepRegistryChangedNotification notification with the receiving object to the default notification center.

+ (NSArray *)registeredImageRepClasses	Returns the names of the registered NSImageRep classes.

+ (void)unregisterImageRepClass:(Class)imageRepClass
	Removes imageRepClass from the registry of available NSImageRep classes. This method posts the NSImageRepRegistryChangedNotification notification with the receiving object to the default notification center.