NSImage

NSImage Mac OS X 10.0

This class is the general interface to images in the AppKit. Instances of NSImage usually have one or more image representations (instances of the class NSImageRep or one of its subclasses) associated with them. The purpose of keeping multiple image representations is so the image data can be rendered on a variety of devices, with each image representation providing rendering functionality for a specific device.

figs/cocn_1540.gif

@interface NSImage : NSObject <NSCoding, NSCopying>
 // Convenience Constructors
   + (NSArray *)imageFileTypes;
   + (id)imageNamed:(NSString *)name;
   + (NSArray *)imagePasteboardTypes;
   + (NSArray *)imageUnfilteredFileTypes;
   + (NSArray *)imageUnfilteredPasteboardTypes;
 // Initializers
   - (id)initByReferencingFile:(NSString *)fileName;
   - (id)initByReferencingURL:(NSURL *)url;
   - (id)initWithContentsOfFile:(NSString *)fileName;
   - (id)initWithContentsOfURL:(NSURL *)url;
   - (id)initWithData:(NSData *)data;
   - (id)initWithPasteboard:(NSPasteboard *)pasteboard;
   - (id)initWithSize:(NSSize)aSize;
 // Accessor Methods
   - (void)setSize:(NSSize)aSize;
   - (NSSize)size;
   - (void)setPrefersColorMatch:(BOOL)flag;
   - (BOOL)prefersColorMatch;
   - (void)setCacheMode:(NSImageCacheMode)mode;
   - (NSImageCacheMode)cacheMode;
   - (void)setUsesEPSOnResolutionMismatch:(BOOL)flag;
   - (BOOL)usesEPSOnResolutionMismatch;
   - (void)setFlipped:(BOOL)flag;
   - (void)setBackgroundColor:(NSColor *)aColor;
   - (NSColor *)backgroundColor;
   - (void)setDelegate:(id)anObject;
   - (id)delegate;
   - (void)setCachedSeparately:(BOOL)flag;
   - (void)setCacheDepthMatchesImageDepth:(BOOL)flag;
   - (BOOL)cacheDepthMatchesImageDepth;
   - (BOOL)setName:(NSString *)string;
   - (NSString *)name;
   - (void)setScalesWhenResized:(BOOL)flag;
   - (BOOL)scalesWhenResized;
   - (void)setMatchesOnMultipleResolution:(BOOL)flag;
   - (BOOL)matchesOnMultipleResolution;
   - (void)setDataRetained:(BOOL)flag;
 // Class Methods
   + (BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard;
 // Instance Methods
   - (void)addRepresentation:(NSImageRep *)imageRep;
   - (NSData *)TIFFRepresentation;
   - (NSData *)TIFFRepresentationUsingCompression:(NSTIFFCompression)comp factor:(float)aFloat;
   - (void)addRepresentations:(NSArray *)imageReps;
   - (void)cancelIncrementalLoad;
   - (void)compositeToPoint:(NSPoint)point fromRect:(NSRect)rect operation:(NSCompositingOperation)op;
   - (void)compositeToPoint:(NSPoint)point fromRect:(NSRect)rect operation:(NSCompositingOperation)op
        fraction:(float)delta;
   - (void)compositeToPoint:(NSPoint)point operation:(NSCompositingOperation)op;
   - (void)compositeToPoint:(NSPoint)point operation:(NSCompositingOperation)op fraction:(float)delta;
   - (NSImageRep *)bestRepresentationForDevice:(NSDictionary *)deviceDescription;
   - (void)dissolveToPoint:(NSPoint)point fraction:(float)aFloat;
   - (void)dissolveToPoint:(NSPoint)point fromRect:(NSRect)rect fraction:(float)aFloat;
   - (void)drawAtPoint:(NSPoint)point fromRect:(NSRect)fromRect operation:(NSCompositingOperation)op
        fraction:(float)delta;
   - (void)drawInRect:(NSRect)rect fromRect:(NSRect)fromRect operation:(NSCompositingOperation)op
        fraction:(float)delta;
   - (BOOL)drawRepresentation:(NSImageRep *)imageRep inRect:(NSRect)rect;
   - (BOOL)isCachedSeparately;
   - (BOOL)isDataRetained;
   - (BOOL)isFlipped;
   - (BOOL)isValid;
   - (void)lockFocus;
   - (void)lockFocusOnRepresentation:(NSImageRep *)imageRepresentation;
   - (void)recache;
   - (void)removeRepresentation:(NSImageRep *)imageRep;
   - (NSArray *)representations;
   - (void)unlockFocus;
 // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
 // Methods Implementing NSCopying
   - (id)copyWithZone:(NSZone *)zone;
// Methods Implemented by the Delegate
   - (void)image:(NSImage*)image didLoadPartOfRepresentation:(NSImageRep*)rep withValidRows:(int)rows;
   - (void)image:(NSImage*)image didLoadRepresentation:(NSImageRep*)rep 
        withStatus:(NSImageLoadStatus)status;
   - (void)image:(NSImage*)image didLoadRepresentationHeader:(NSImageRep*)rep;
   - (void)image:(NSImage*)image willLoadRepresentation:(NSImageRep*)rep;
   - (NSImage *)imageDidNotDraw:(id)sender inRect:(NSRect)aRect;



    Part II: API Quick Reference
    Chapter 13. Foundation Classes