Up

# NSImage

### Authors

Adam Fedor (`fedor@colorado.edu`)

> Load, manipulate and display images

Copyright: (C) 1996-2016 Free Software Foundation, Inc.

### Contents -

1. Software documentation for the NSImage class
2. Software documentation for the NSBundle(NSImageAdditions) category
3. Software documentation for the NSImage(GSQuartz) category
4. Software documentation for the GSImageDelegateProtocol protocol

# Software documentation for the NSImage class

## NSImage : NSObject

> Declared in:
>   AppKit/NSImage.h

> Conforms to:
>   NSCoding
>   NSCopying

Availability: OpenStep
Description forthcoming.

Instance Variables
Method summary

- -CGImageForProposedRect:context:hints:
- +_standardImageWithName:
- +canInitWithPasteboard:
- +imageFileTypes
- +imageNamed:
- +imagePasteboardTypes
- +imageUnfilteredFileTypes
- +imageUnfilteredPasteboardTypes
- -TIFFRepresentation
- -TIFFRepresentationUsingCompression:factor:
- -addRepresentation:
- -addRepresentations:
- -backgroundColor
- -bestRepresentationForDevice:
- -bestRepresentationForRect:context:hints:
- -cacheDepthMatchesImageDepth
- -cacheMode
- -compositeToPoint:fromRect:operation:
- -compositeToPoint:fromRect:operation:fraction:
- -compositeToPoint:operation:
- -compositeToPoint:operation:fraction:
- -delegate
- -dissolveToPoint:fraction:
- -dissolveToPoint:fromRect:fraction:
- -drawAtPoint:fromRect:operation:fraction:
- -drawInRect:
- -drawInRect:fromRect:operation:fraction:
- -drawInRect:fromRect:operation:fraction:respectFlipped:hints:
- -drawRepresentation:inRect:
- -initByReferencingFile:
- -initWithBitmapHandle:
- -initWithContentsOfFile:
- -initWithContentsOfURL:
- -initWithData:
- -initWithIconHandle:
- -initWithPasteboard:
- -initWithSize:
- -isCachedSeparately
- -isDataRetained
- -isFlipped
- -isValid
- -lockFocus
- -lockFocusOnRepresentation:
- -matchesOnMultipleResolution
- -name
- -prefersColorMatch
- -recache
- -removeRepresentation:
- -representations
- -scalesWhenResized
- -setBackgroundColor:
- -setCacheDepthMatchesImageDepth:
- -setCacheMode:
- -setCachedSeparately:
- -setDataRetained:
- -setDelegate:
- -setFlipped:
- -setMatchesOnMultipleResolution:
- -setName:
- -setPrefersColorMatch:
- -setScalesWhenResized:
- -setSize:
- -setUsesEPSOnResolutionMismatch:
- -size
- -unlockFocus
- -usesEPSOnResolutionMismatch

### _standardImageWithName:

+ (NSImage*) _standardImageWithName: (NSString*)name;
Availability: Not in OpenStep/MacOS-X
Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.

### canInitWithPasteboard:

+ (BOOL) canInitWithPasteboard: (NSPasteboard*)pasteboard;
Availability: OpenStep
Description forthcoming.

### imageFileTypes

+ (NSArray*) imageFileTypes;
Availability: OpenStep
Description forthcoming.

### imageNamed:

+ (id) imageNamed: (NSString*)aName;
Availability: OpenStep
Returns the NSImage named aName. The search is done in the main bundle first and then in the usual images directories.

### imagePasteboardTypes

+ (NSArray*) imagePasteboardTypes;
Availability: OpenStep
Description forthcoming.

### imageUnfilteredFileTypes

+ (NSArray*) imageUnfilteredFileTypes;
Availability: OpenStep
Description forthcoming.

### imageUnfilteredPasteboardTypes

+ (NSArray*) imageUnfilteredPasteboardTypes;
Availability: OpenStep
Description forthcoming.

### TIFFRepresentation

- (NSData*) TIFFRepresentation;
Availability: OpenStep
Description forthcoming.

### TIFFRepresentationUsingCompression: factor:

- (NSData*) TIFFRepresentationUsingCompression: (NSTIFFCompression)comp factor: (float)aFloat;
Availability: OpenStep
Description forthcoming.

### addRepresentation:

- (void) addRepresentation: (NSImageRep*)imageRep;
Availability: OpenStep
Adds the NSImageRep imageRep to the NSImage's representations array.

See Also:

- -addRepresentations:
- -removeRepresentation:

### addRepresentations:

- (void) addRepresentations: (NSArray*)imageRepArray;
Availability: OpenStep
Adds the NSImageRep array imageRepArray to the NSImage's representations array.

See Also:

- -addRepresentation:
- -removeRepresentation:

### backgroundColor

- (NSColor*) backgroundColor;
Availability: OpenStep
Returns the color of the NSImage's background.

See Also:

- -setBackgroundColor:

### bestRepresentationForDevice:

- (NSImageRep*) bestRepresentationForDevice: (NSDictionary*)deviceDescription;
Availability: OpenStep
Finds the best representation for deviceDescription. If deviceDescription is `nil`, it guesses where drawing is taking place and finds the best representation.

### bestRepresentationForRect: context: hints:

- (NSImageRep*) bestRepresentationForRect: (NSRect)rect context: (NSGraphicsContext*)context hints: (NSDictionary*)deviceDescription;
Availability: MacOS-X 10.6.0
Finds the best representation for drawing in the specified rect. context and hints are currently ignored.

### cacheDepthMatchesImageDepth

- (BOOL) cacheDepthMatchesImageDepth;
Availability: OpenStep
Description forthcoming.

### cacheMode

- (NSImageCacheMode) cacheMode;
Availability: OpenStep
Description forthcoming.

### compositeToPoint: fromRect: operation:

- (void) compositeToPoint: (NSPoint)aPoint fromRect: (NSRect)aRect operation: (NSCompositingOperation)op;
Availability: OpenStep
Description forthcoming.

### compositeToPoint: fromRect: operation: fraction:

- (void) compositeToPoint: (NSPoint)aPoint fromRect: (NSRect)srcRect operation: (NSCompositingOperation)op fraction: (CGFloat)delta;
Availability: MacOS-X 10.0.0
Description forthcoming.

### compositeToPoint: operation:

- (void) compositeToPoint: (NSPoint)aPoint operation: (NSCompositingOperation)op;
Availability: OpenStep
Description forthcoming.

### compositeToPoint: operation: fraction:

- (void) compositeToPoint: (NSPoint)aPoint operation: (NSCompositingOperation)op fraction: (CGFloat)delta;
Availability: MacOS-X 10.0.0
Description forthcoming.

### delegate

- (id) delegate;
Availability: OpenStep
Description forthcoming.

### dissolveToPoint: fraction:

- (void) dissolveToPoint: (NSPoint)aPoint fraction: (CGFloat)aFloat;
Availability: OpenStep
Description forthcoming.

### dissolveToPoint: fromRect: fraction:

- (void) dissolveToPoint: (NSPoint)aPoint fromRect: (NSRect)aRect fraction: (CGFloat)aFloat;
Availability: OpenStep
Description forthcoming.

### drawAtPoint: fromRect: operation: fraction:

- (void) drawAtPoint: (NSPoint)point fromRect: (NSRect)srcRect operation: (NSCompositingOperation)op fraction: (CGFloat)delta;
Availability: MacOS-X 10.0.0
Calls -drawAtPoint:fromRect:operation:fraction: with `dstRect` given by `point` and the size of `srcRect`.

### drawInRect:

- (void) drawInRect: (NSRect)rect;
Availability: MacOS-X 10.6.0
Description forthcoming.

### drawInRect: fromRect: operation: fraction:

- (void) drawInRect: (NSRect)dstRect fromRect: (NSRect)srcRect operation: (NSCompositingOperation)op fraction: (CGFloat)delta;
Availability: MacOS-X 10.0.0

Takes the part of the receiver given by `srcRect` and draws it in `dstRect` in the current coordinate system, transforming the image as necessary.

The image is drawn as if it was drawn to a cleared window, then dissolved using the fraction `delta` to another cleared window, and finally composited using `op` to the destination.

Note that compositing and dissolving doesn't work on all devices (printers, in particular).

### drawInRect: fromRect: operation: fraction: respectFlipped: hints:

- (void) drawInRect: (NSRect)dstRect fromRect: (NSRect)srcRect operation: (NSCompositingOperation)op fraction: (CGFloat)delta respectFlipped: (BOOL)respectFlipped hints: (NSDictionary*)hints;
Availability: MacOS-X 10.6.0
Base drawing method in NSImage; all other draw methods call this one
We only use caching on backends that can efficiently draw a rect from the cache onto the current graphics context respecting the CTM, which is currently cairo.

### drawRepresentation: inRect:

- (BOOL) drawRepresentation: (NSImageRep*)imageRep inRect: (NSRect)aRect;
Availability: OpenStep
Description forthcoming.

### initByReferencingFile:

- (id) initByReferencingFile: (NSString*)fileName;
Availability: OpenStep
Initializes and returns a NSImage from the NSString fileName.

### initWithBitmapHandle:

- (id) initWithBitmapHandle: (void*)bitmap;
Availability: MacOS-X 10.0.0
Description forthcoming.

### initWithContentsOfFile:

- (id) initWithContentsOfFile: (NSString*)fileName;
Availability: OpenStep
Initializes and returns a new NSImage from the file fileName. fileName should be an absolute path.

See Also:

- [NSImageRep +imageRepsWithContentsOfFile:]

### initWithContentsOfURL:

- (id) initWithContentsOfURL: (NSURL*)anURL;
Availability: MacOS-X 10.0.0
Description forthcoming.

### initWithData:

- (id) initWithData: (NSData*)data;
Availability: OpenStep
Initializes and returns a new NSImage from the NSData data.

See Also:

- [NSBitmapImageRep +imageRepWithData:]
- [NSEPSImageRep +imageRepWithData:]

### initWithIconHandle:

- (id) initWithIconHandle: (void*)icon;
Availability: MacOS-X 10.0.0
Description forthcoming.

### initWithPasteboard:

- (id) initWithPasteboard: (NSPasteboard*)pasteboard;
Availability: OpenStep
Initializes and returns a new NSImage from the data in pasteboard. The pasteboard types can be whose defined in [NSImageRep +imagePasteboardTypes] or NSFilenamesPboardType

See Also:

- [NSImageRep +imageRepsWithPasteboard:]

### initWithSize:

- (id) initWithSize: (NSSize)aSize;
Availability: OpenStep
Initialize and returns a new NSImage with aSize as specified size.

See Also:

- -setSize:
- -size

### isCachedSeparately

- (BOOL) isCachedSeparately;
Availability: OpenStep
Description forthcoming.

### isDataRetained

- (BOOL) isDataRetained;
Availability: OpenStep
Description forthcoming.

### isFlipped

- (BOOL) isFlipped;
Availability: OpenStep
Description forthcoming.

### isValid

- (BOOL) isValid;
Availability: OpenStep
Description forthcoming.

### lockFocus

- (void) lockFocus;
Availability: OpenStep
Locks the focus on the best representation.

See Also:

- -lockFocusOnRepresentation:

### lockFocusOnRepresentation:

- (void) lockFocusOnRepresentation: (NSImageRep*)imageRep;
Availability: OpenStep
Locks the focus in the imageRep. If imageRep is `nil` this method locks the focus on the best representation.

### matchesOnMultipleResolution

- (BOOL) matchesOnMultipleResolution;
Availability: OpenStep
Description forthcoming.

### name

- (NSString*) name;
Availability: OpenStep
Returns the name of the receiver.

### prefersColorMatch

- (BOOL) prefersColorMatch;
Availability: OpenStep
Returns `YES` if color matching is the preferred representation and `NO` otherwise.

### recache

- (void) recache;
Availability: OpenStep
Description forthcoming.

### removeRepresentation:

- (void) removeRepresentation: (NSImageRep*)imageRep;
Availability: OpenStep
Remove the NSImageRep imageRep from the NSImage's representations array

See Also:

- -addRepresentations:
- -addRepresentation:

### representations

- (NSArray*) representations;
Availability: OpenStep
Description forthcoming.

### scalesWhenResized

- (BOOL) scalesWhenResized;
Availability: OpenStep
Description forthcoming.

### setBackgroundColor:

- (void) setBackgroundColor: (NSColor*)aColor;
Availability: OpenStep
Sets the color of the NSImage's background to aColor.

See Also:

- -backgroundColor

### setCacheDepthMatchesImageDepth:

- (void) setCacheDepthMatchesImageDepth: (BOOL)flag;
Availability: OpenStep
Description forthcoming.

### setCacheMode:

- (void) setCacheMode: (NSImageCacheMode)mode;
Availability: OpenStep
Description forthcoming.

### setCachedSeparately:

- (void) setCachedSeparately: (BOOL)flag;
Availability: OpenStep
Description forthcoming.

### setDataRetained:

- (void) setDataRetained: (BOOL)flag;
Availability: OpenStep
Description forthcoming.

### setDelegate:

- (void) setDelegate: (id)anObject;
Availability: OpenStep
Description forthcoming.

### setFlipped:

- (void) setFlipped: (BOOL)flag;
Availability: OpenStep
Description forthcoming.

### setMatchesOnMultipleResolution:

- (void) setMatchesOnMultipleResolution: (BOOL)flag;
Availability: OpenStep
Description forthcoming.

### setName:

- (BOOL) setName: (NSString*)aName;
Availability: OpenStep
Sets aName as the name of the receiver.

### setPrefersColorMatch:

- (void) setPrefersColorMatch: (BOOL)flag;
Availability: OpenStep
Sets the preferred representation of a NSImage.

See Also:

- -prefersColorMatch
- -bestRepresentationForDevice:

### setScalesWhenResized:

- (void) setScalesWhenResized: (BOOL)flag;
Availability: OpenStep
Description forthcoming.

### setSize:

- (void) setSize: (NSSize)aSize;
Availability: OpenStep
Sets the NSImage size to aSize. Changing the size recreate the cache.

See Also:

- -size
- -initWithSize:

### setUsesEPSOnResolutionMismatch:

- (void) setUsesEPSOnResolutionMismatch: (BOOL)flag;
Availability: OpenStep
Description forthcoming.

### size

- (NSSize) size;
Availability: OpenStep
Returns NSImage size if the size have been set. Returns the size of the best representation otherwise.

See Also:

- -setSize:
- -initWithSize:

### unlockFocus

- (void) unlockFocus;
Availability: OpenStep
Unlocks the focus on the receiver.

See Also:

- -lockFocus

### usesEPSOnResolutionMismatch

- (BOOL) usesEPSOnResolutionMismatch;
Availability: OpenStep
Description forthcoming.

## Instance Variables for NSImage Class

### _cacheMode

@protected NSImageCacheMode _cacheMode;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _color

@protected NSColor* _color;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _delegate

@protected id _delegate;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _fileName

@protected NSString* _fileName;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _lockedView

@protected NSView* _lockedView;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _name

@protected NSString* _name;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _reps

@protected NSMutableArray* _reps;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _size

@protected NSSize _size;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### struct __imageFlags

@protected struct __imageFlags struct __imageFlags;
Availability: OpenStep
Description forthcoming.

# Software documentation for the NSBundle(NSImageAdditions) category

## NSBundle(NSImageAdditions)

> Declared in:
>   AppKit/NSImage.h

Availability: OpenStep
Description forthcoming.
Method summary

- -pathForImageResource:

### pathForImageResource:

- (NSString*) pathForImageResource: (NSString*)name;
Availability: OpenStep
Description forthcoming.

# Software documentation for the NSImage(GSQuartz) category

## NSImage(GSQuartz)

> Declared in:
>   AppKit/NSImage.h

Availability: OpenStep
Description forthcoming.
Method summary

- -CGImageForProposedRect:context:hints:

### CGImageForProposedRect: context: hints:

- (CGImageRef) CGImageForProposedRect: (NSRect*)proposedDestRect context: (NSGraphicsContext*)referenceContext hints: (NSDictionary*)hints;
Availability: MacOS-X 10.6.0
Description forthcoming.

# Software documentation for the GSImageDelegateProtocol protocol

## GSImageDelegateProtocol

> Declared in:
>   AppKit/NSImage.h

Availability: Not in OpenStep/MacOS-X
Description forthcoming.
Method summary

- -imageDidNotDraw:inRect:

### imageDidNotDraw: inRect:

- (NSImage*) imageDidNotDraw: (id)sender inRect: (NSRect)aRect;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

Up