| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSGraphics.h NSImage.h |
| Related sample code |
An NSImage object is a high-level class for manipulating image data. You use this class to load existing images or create new ones and composite them into a view or other image. This class works in conjunction with one or more image representation objects (subclasses of NSImageRep), which manage the actual image data.
– initByReferencingFile:
– initByReferencingURL:
– initWithContentsOfFile:
– initWithContentsOfURL:
– initWithData:
– initWithPasteboard:
– initWithSize:
– initWithIconRef:
+ canInitWithPasteboard:
+ imageTypes
+ imageUnfilteredTypes
+ imageFileTypes
+ imageUnfilteredFileTypes
+ imagePasteboardTypes
+ imageUnfilteredPasteboardTypes
– addRepresentation:
– addRepresentations:
– bestRepresentationForDevice:
– representations
– removeRepresentation:
– setPrefersColorMatch:
– prefersColorMatch
– setUsesEPSOnResolutionMismatch:
– usesEPSOnResolutionMismatch
– setMatchesOnMultipleResolution:
– matchesOnMultipleResolution
– drawAtPoint:fromRect:operation:fraction:
– drawInRect:fromRect:operation:fraction:
– drawRepresentation:inRect:
– compositeToPoint:operation:
– compositeToPoint:fromRect:operation:
– compositeToPoint:fromRect:operation:fraction:
– compositeToPoint:operation:fraction:
– dissolveToPoint:fraction:
– dissolveToPoint:fromRect:fraction:
– imageDidNotDraw:inRect: delegate method
– setCachedSeparately:
– isCachedSeparately
– setDataRetained:
– isDataRetained
– setCacheDepthMatchesImageDepth:
– cacheDepthMatchesImageDepth
– cacheMode
– setCacheMode:
– isValid
– setScalesWhenResized:
– scalesWhenResized
– setBackgroundColor:
– backgroundColor
– setFlipped:
– isFlipped
– recache
– cancelIncrementalLoad
– image:didLoadPartOfRepresentation:withValidRows: delegate method
– image:didLoadRepresentation:withStatus: delegate method
– image:didLoadRepresentationHeader: delegate method
– image:willLoadRepresentation: delegate method
Tests whether the receiver can create an instance of itself using pasteboard data.
+ (BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard
The pasteboard containing the image data.
YES if the receiver knows how to handle the data on the pasteboard; otherwise, NO.
This method uses the NSImageRep class method imageUnfilteredPasteboardTypes to find a class that can handle the data in the specified pasteboard. If you create your own NSImageRep subclasses, override the imageUnfilteredPasteboardTypes method to notify NSImage of the pasteboard types your class supports.
NSImage.h
Returns an array of strings identifying the image types supported by the registered NSImageRep objects.
+ (NSArray *)imageFileTypes
An array of NSString objects, each of which identifies a single supported file type. The array can include encoded HFS file types as well as filename extensions.
This list includes all file types supported by registered subclasses of NSImageRep plus those that can be converted to a supported type by a user-installed filter service. You can pass the array returned by this method directly to the runModalForTypes: method of NSOpenPanel.
When creating a subclass of NSImageRep, do not override this method. Instead, override the imageUnfilteredFileTypes method to notify NSImage of the file types your class supports directly.
NSImage.h
Returns the NSImage instance associated with the specified name.
+ (id)imageNamed:(NSString *)name
The name associated with the desired image.
The NSImage object associated with the specified name, or nil if no such image was found.
This method searches for named images in several places, returning the first image it finds matching the given name. The order of the search is as follows:
Search for an object whose name was set explicitly using the setName: method and currently resides in the image cache.
Search the application's main bundle for a file whose name matches the specified string. (For information on how the bundle is searched, see “Searching for Bundle Resources“ in Bundle Programming Guide.)
Search the Application Kit framework for a shared image with the specified name.
When looking for files in the application bundle, it is better (but not required) to include the filename extension in the name parameter. When naming an image with the setName: method, it is also convention not to include filename extensions in the names you specify. That way, you can easily distinguish between images you have named explicitly and those you want to load from the application's bundle.
One particularly useful image you can retrieve is your application's icon. This image is set by Cocoa automatically and referenced by the string @"NSApplicationIcon". Icons for other applications can be obtained through the use of methods declared in the NSWorkspace class. You can also retrieve some standard system images using Cocoa defined constants; for more information, see the Constants section of this class.
If an application is linked in Mac OS X v10.5 or later, images requested using this method and whose name ends in the word “Template” are automatically marked as template images.
The NSImage class may cache a reference to the returned image object for performance in some cases. However, the class holds onto cached objects only while the object exists. If the image object is subsequently released, either because its retain count was 0 or it was not referenced anywhere in a garbage-collected application, the object may be quietly removed from the cache. Thus, if you plan to hold onto a returned image object, you must retain it like you would any Cocoa object. You can clear an image object from the cache explicitly by calling the object’s setName: method and passing nil for the image name.
– setName:– name– iconForFile: (NSWorkspace)+ imageFileTypesNSImage.hReturns an array of strings identifying the pasteboard types supported directly by the registered NSImageRep objects.
+ (NSArray *)imagePasteboardTypes
An array of NSString objects, each of which identifies a single supported pasteboard type. By default, this list contains the NSPDFPboardType, NSPICTPboardType, NSPostScriptPboardType, and NSTIFFPboardType types.
This list includes all pasteboard types supported by registered subclasses of NSImageRep plus those that can be converted to a supported type by a user-installed filter service.
When creating a subclass of NSImageRep, do not override this method. Instead, override the imageUnfilteredPasteboardTypes method to notify NSImage of the pasteboard types your class supports.
NSImage.hReturns an array of UTI strings identifying the image types supported by the registered NSImageRep objects, either directly or through a user-installed filter service.
+ (NSArray *)imageTypes
An array of NSString objects, each of which contains a UTI identifying a supported image type. Some sample image-related UTI strings include "public.image”, "public.jpeg”, and "public.tiff”. For a list of supported types, see UTCoreTypes.h.
The returned list includes UTIs all file types supported by registered subclasses of NSImageRep plus those that can be converted to a supported type by a user-installed filter service. You can use the returned UTI strings with any method that supports UTIs.
You should not override this method directly. Instead, you should override the imageTypes method of NSImageRep.
NSImage.hReturns an array of strings identifying the file types supported directly by the registered NSImageRep objects.
+ (NSArray *)imageUnfilteredFileTypes
An array of NSString objects, each of which identifies a single supported file type. File types are identified by file extension and HFS file types.
The returned list does not contain pasteboard types that are available only through a user-installed filter service.
NSImage.hReturns an array of strings identifying the pasteboard types supported directly by the registered NSImageRep objects.
+ (NSArray *)imageUnfilteredPasteboardTypes
An array of NSString objects, each of which identifies a single supported pasteboard type.
The returned list does not contain pasteboard types that are supported only through a user-installed filter service.
NSImage.hReturns an array of UTI strings identifying the image types supported directly by the registered NSImageRep objects.
+ (NSArray *)imageUnfilteredTypes
An array of NSString objects, each of which contains a UTI identifying a supported image type. Some sample image-related UTI strings include "public.image”, "public.jpeg”, and "public.tiff”. For a list of supported types, see UTCoreTypes.h.
The returned list includes UTI strings only for those file types that are supported directly by registered subclasses of NSImageRep. It does not include types that are supported through user-installed filter services. You can use the returned UTI strings with any method that supports UTIs.
You should not override this method directly. Instead, you should override the imageUnfilteredTypes method of NSImageRep.
NSImage.hAdds the specified image representation object to to the receiver.
- (void)addRepresentation:(NSImageRep *)imageRep
The image representation to add.
After invoking this method, you may need to explicitly set features of the new image representation, such as the size, number of colors, and so on. This is true particularly when the NSImage object has multiple image representations to choose from. See NSImageRep and its subclasses for the methods you use to complete initialization.
Any representation added by this method is retained by the receiver. Image representations cannot be shared among multiple NSImage objects.
NSImage.hAdds an array of image representation objects to the receiver.
- (void)addRepresentations:(NSArray *)imageReps
An array of NSImageRep objects.
After invoking this method, you may need to explicitly set features of the new image representations, such as their size, number of colors, and so on. This is true particularly when the NSImage object has multiple image representations to choose from. See NSImageRep and its subclasses for the methods you use to complete initialization.
Representations added by this method are retained by the receiver. Image representations cannot be shared among multiple NSImage objects.
NSImage.hReturns alignment metadata that your code can use to position the image during layout.
- (NSRect)alignmentRect
A rectangle containing the layout information for the image. If not set, the returned rectangle has an origin of (0, 0) and a size that matches the size of the image.
The returned rectangle is merely a hint that your own code can use to determine positioning. The NSImage class does not use this rectangle during drawing. However, instances of NSCell typically use this information when laying out images within their own boundaries.
NSImage.h
Returns the background color of image.
- (NSColor *)backgroundColor
The background color of the image. The default color is transparent, as returned by the clearColor method of NSColor.
The background color is visible only if the drawn image representation does not completely cover all of the pixels available for the image's current size.
NSImage.hReturns the best representation for the device with the specified characteristics.
- (NSImageRep *)bestRepresentationForDevice:(NSDictionary *)deviceDescription
A dictionary of attributes for the specified device, or nil to specify the current device. For a list of dictionary keys and values appropriate to display and print devices, see the constants in NSScreen.
The image representation that most closely matches the specified criteria.
If deviceDescription is nil, this method uses the attributes of the device on which the content is to be drawn.
For information on how the "best" representation is chosen, see the Images chapter of Cocoa Drawing Guide.
NSImage.hReturns a Boolean value indicating whether an image's offscreen window caches use the same bit depth as the image data itself.
- (BOOL)cacheDepthMatchesImageDepth
YES if the offscreen window caches use the same bit depth as the image data; otherwise, NO. The default value is NO.
NSImage.hReturns the receiver’s caching mode.
- (NSImageCacheMode)cacheMode
A value indicating the caching mode. For a list of possible values, see NSImageCacheMode. This value is set to NSImageCacheDefault by default.
NSImage.hCancels the current download operation immediately, if the image is being incrementally loaded.
- (void)cancelIncrementalLoad
This call has no effect if the image is not loading.
NSImage.hComposites a portion of the image to the specified point in the current coordinate system.
- (void)compositeToPoint:(NSPoint)aPoint fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op
The point at which to draw the image, specified in the current coordinate system.
The portion of the image you want to draw, specified in the image's coordinate system.
The compositing operation to use when drawing the image to the screen. The supported compositing operations are described in “Constants.”
This method draws the specified portion of the image without checking the bounds rectangle you pass into the srcRect parameter. If you specify a source rectangle that strays outside of the image's bounds rectangle, it is conceivable that you could composite parts of the offscreen cache window that do not belong to the receiver's image. You can avoid this problem by using the setCachedSeparately: method to force the image to be cached in its own offscreen window, which results in the content being clipped to the window rectangle. Alternatively, you can use the drawAtPoint:fromRect:operation:fraction: method, which checks the source rectangle before drawing.
During drawing, the image is composited from its offscreen window cache. Because the offscreen cache is not created until the image representation is first used, this method may need to render the image before compositing. Bitmap representations in particular are not cached until they are explicitly rendered. You can use the lockFocus and unlockFocus methods to force the cached version to be created.
Compositing part of an image is as efficient as compositing the whole image, but printing just part of an image is not. When printing, it’s necessary to draw the whole image and rely on a clipping path to be sure that only the desired portion appears.
During printing, this method ignores the op parameter. Even though this parameter is ignored, this method attempts to render the image as close as possible to its appearance when the compositing operation is used on the screen. In either case, the best image representation is chosen for the printing context.
Important: If you are writing new code, or updating old code, you should avoid using this method. Instead, you should use the drawAtPoint:fromRect:operation:fraction: or drawInRect:fromRect:operation:fraction: method to draw the image. Although the method itself is not deprecated, the behavior it provides is not recommended for general use.
– dissolveToPoint:fromRect:fraction:– drawAtPoint:fromRect:operation:fraction:– drawInRect:fromRect:operation:fraction:NSImage.hComposites a portion of the image at the specified opacity to the current coordinate system.
- (void)compositeToPoint:(NSPoint)aPoint fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(CGFloat)delta
The point at which to draw the image, specified in the current coordinate system.
The portion of the image you want to draw, specified in the image's coordinate system.
The compositing operation to use when drawing the image to the screen. The supported compositing operations are described in “Constants.”
The desired opacity of the image, specified as a value between 0.0 and 1.0, with 1.0 representing total opacity. Values larger than 1.0 are interpreted as 1.0. This method always expects to render something, so for values that are equal to or less than 0, this method renders at full opacity.
Behaves the same as compositeToPoint:fromRect:operation: except that you can specify the amount of opacity to use when drawing the image.
Important: If you are writing new code, or updating old code, you should avoid using this method. Instead, you should use the drawAtPoint:fromRect:operation:fraction: or drawInRect:fromRect:operation:fraction: method to draw the image. Although the method itself is not deprecated, the behavior it provides is not recommended for general use.
– dissolveToPoint:fromRect:fraction:– drawAtPoint:fromRect:operation:fraction:– drawInRect:fromRect:operation:fraction:NSImage.hComposites the entire image to the specified point in the current coordinate system.
- (void)compositeToPoint:(NSPoint)aPoint operation:(NSCompositingOperation)op
The point at which to draw the image, specified in the current coordinate system.
The compositing operation to use when drawing the image to the screen. The supported compositing operations are described in “Constants.”
This method draws the receiver's best image representation at the specified point in the currently focused view. The entire image is drawn using its current size information. During drawing, the image is composited from its offscreen window cache. Because the offscreen cache is not created until the image representation is first used, this method may need to render the image before compositing. Bitmap representations in particular are not cached until they are explicitly rendered. You can use the lockFocus and unlockFocus methods to force the cached version to be created.
During printing, this method ignores the op parameter. Even though this parameter is ignored, this method attempts to render the image as close as possible to its appearance when the compositing operation is used on the screen. In either case, the best image representation is chosen for the printing context.
Important: If you are writing new code, or updating old code, you should avoid using this method. Instead, you should use the drawAtPoint:fromRect:operation:fraction: or drawInRect:fromRect:operation:fraction: method to draw the image. Although the method itself is not deprecated, the behavior it provides is not recommended for general use.
– dissolveToPoint:fraction:– drawAtPoint:fromRect:operation:fraction:– drawInRect:fromRect:operation:fraction:NSImage.hComposites the entire image at the specified opacity in the current coordinate system.
- (void)compositeToPoint:(NSPoint)aPoint operation:(NSCompositingOperation)op fraction:(CGFloat)delta
The point at which to draw the image, specified in the current coordinate system.
The compositing operation to use when drawing the image to the screen. The supported compositing operations are described in “Constants.”
The desired opacity of the image, specified as a value between 0.0 and 1.0, with 1.0 representing total opacity. Values larger than 1.0 are interpreted as 1.0. This method always expects to render something, so for values that are equal to or less than 0, this method renders at full opacity.
Behaves the same as compositeToPoint:operation: except that you can specify the amount of opacity to use when drawing the image.
Important: If you are writing new code, or updating old code, you should avoid using this method. Instead, you should use the drawAtPoint:fromRect:operation:fraction: or drawInRect:fromRect:operation:fraction: method to draw the image. Although the method itself is not deprecated, the behavior it provides is not recommended for general use.
– dissolveToPoint:fraction:– drawAtPoint:fromRect:operation:fraction:– drawInRect:fromRect:operation:fraction:NSImage.hReturns the delegate object of the receiver
- (id)delegate
The current delegate object, or nil if no delegate has been set.
NSImage.hComposites the entire image to the specified location using the NSCompositeSourceOver operator.
- (void)dissolveToPoint:(NSPoint)aPoint fraction:(CGFloat)delta
The point at which to draw the image, specified in the current coordinate system.
The desired opacity of the image, specified as a value between 0.0 and 1.0. A value of 0.0 renders the image totally transparent while 1.0 renders it fully opaque. Values larger than 1.0 are interpreted as 1.0.
Except for the choice of compositing operator, this method behaves in the same way as the compositeToPoint:operation: method. During printing, the delta parameter is ignored.
If the source image contains alpha information, this operation may promote the destination NSWindow object to contain alpha information.
To slowly dissolve this image onto another, you can invoke this method (or the dissolveToPoint:fromRect:fraction: method) repeatedly with an ever-increasing delta value. Because the delta parameter refers to the visible fraction of the source image, increasing the value causes the source image to replace the destination content gradually. You should generally perform this type of operation using a buffered window or other offscreen drawing environment.
NSImage.hComposites a portion of the image to the specified location using the NSCompositeSourceOver operator.
- (void)dissolveToPoint:(NSPoint)aPoint fromRect:(NSRect)srcRect fraction:(CGFloat)delta
The point at which to draw the image, specified in the current coordinate system.
The portion of the image you want to draw, specified in the image's coordinate system.
The desired opacity of the image, specified as a value between 0.0 and 1.0. A value of 0.0 renders the image totally transparent while 1.0 renders it fully opaque. Values larger than 1.0 are interpreted as 1.0.
Except for the choice of compositing operator, this method behaves in the same way as the compositeToPoint:fromRect:operation: method. During printing, the delta parameter is ignored.
If the source image contains alpha information, this operation may promote the destination NSWindow object to contain alpha information.
NSImage.hDraws all or part of the image at the specified point in the current coordinate system.
- (void)drawAtPoint:(NSPoint)point fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(CGFloat)delta
The location in the current coordinate system at which to draw the image.
The source rectangle specifying the portion of the image you want to draw. The coordinates of this rectangle are specified in the image's own coordinate system. If you pass in NSZeroRect, the entire image is drawn.
The compositing operation to use when drawing the image. See the NSCompositingOperation constants.
The opacity of the image, specified as a value from 0.0 to 1.0. Specifying a value of 0.0 draws the image as fully transparent while a value of 1.0 draws the image as fully opaque. Values greater than 1.0 are interpreted as 1.0.
The image content is drawn at its current resolution and is not scaled unless the CTM of the current coordinate system itself contains a scaling factor. The image is otherwise positioned and oriented using the current coordinate system.
Unlike the compositeToPoint:fromRect:operation: and compositeToPoint:fromRect:operation:fraction: methods, this method checks the rectangle you pass to the srcRect parameter and makes sure it does not lie outside the image bounds.
NSImage.hDraws all or part of the image in the specified rectangle in the current coordinate system.
- (void)drawInRect:(NSRect)dstRect fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(CGFloat)delta
The rectangle in which to draw the image, specified in the current coordinate system.
The source rectangle specifying the portion of the image you want to draw. The coordinates of this rectangle must be specified using the image's own coordinate system. If you pass in NSZeroRect, the entire image is drawn.
The compositing operation to use when drawing the image. See the NSCompositingOperation constants.
The opacity of the image, specified as a value from 0.0 to 1.0. Specifying a value of 0.0 draws the image as fully transparent while a value of 1.0 draws the image as fully opaque. Values greater than 1.0 are interpreted as 1.0.
If the srcRect and dstRect rectangles have different sizes, the source portion of the image is scaled to fit the specified destination rectangle. The image is otherwise positioned and oriented using the current coordinate system.
Unlike the compositeToPoint:fromRect:operation: and compositeToPoint:fromRect:operation:fraction: methods, this method checks the rectangle you pass to the srcRect parameter and makes sure it does not lie outside the image bounds.
NSImage.hDraws the image using the specified image representation object.
- (BOOL)drawRepresentation:(NSImageRep *)imageRep inRect:(NSRect)dstRect
The image representation object to be drawn.
The rectangle in which to draw the image representation, specified in the current coordinate system.
YES if the image was successfully drawn; otherwise, returns NO.
This method fills the specified rectangle with the image's current background color and then sends a message to the specified image representation asking if to draw itself. If the image supports the ability to scale itself when it is resized, this method sends a drawInRect: message; otherwise, it sends a drawAtPoint: message.
You should not call this method directly; an NSImage object uses it to cache and print its image representations. You can override this method to change the way images are rendered into their caches and onto the printed page. For example, you could scale or rotate the coordinate system before sending this message to super to continue rendering the image representation.
If the background color is fully transparent and the image data is not being cached, the specified rectangle is not to be filled before the representation draws.
NSImage.h
Initializes and returns an NSImage instance and associates it with the specified file.
- (id)initByReferencingFile:(NSString *)filename
A full or relative path name specifying the file with the desired image data. Relative paths must be relative to the current working directory.
An initialized NSImage instance, or nil if the new instance cannot be initialized.
This method initializes the image object lazily. It does not actually open the specified file or create any image representations from its data until an application attempts to draw the image or request information about it.
The filename parameter should include the file extension that identifies the type of the image data. The mechanism that actually creates the image representation for filename looks for an NSImageRep subclass that handles that data type from among those registered with NSImage.
Because this method doesn’t actually create image representations for the image data, your application should do error checking before attempting to use the image; one way to do so is by invoking the isValid method to check whether the image can be drawn.
This method invokes setDataRetained: with an argument of YES, thus enabling it to hold onto its filename. When archiving an image created with this method, only the image's filename is written to the archive.
If the cached version of the image uses less memory than the original image data, the original data is flushed and the cached image is used. (This can occur for images whose resolution is greater than 72 dpi.) If you resize the image by less than 50%, the data is loaded in again from the file. If you expect the file to change or be deleted, you should use initWithContentsOfFile: instead.
NSImage.hInitializes and returns an NSImage instance and associates it with the specified URL.
- (id)initByReferencingURL:(NSURL *)url
The URL identifying the image.
An initialized NSImage instance, or nil if the new instance cannot be initialized.
This method initializes the image object lazily. It does not attempt to retrieve the data from the specified URL or create any image representations from that data until an application attempts to draw the image or request information about it.
This url parameter should include a file extension that identifies the type of the image data. The mechanism that actually creates the image representation looks for an NSImageRep subclass that handles that data type from among those registered with NSImage.
Because this method doesn’t actually create image representations for the image data, your application should do error checking before attempting to use the image; one way to do so is by invoking the isValid method to check whether the image can be drawn.
This method invokes setDataRetained: with an argument of YES, thus enabling it to hold onto its URL. When archiving an image created with this method, only the image's URL is written to the archive.
NSImage.h
Initializes and returns an NSImage instance with the contents of the specified file.
- (id)initWithContentsOfFile:(NSString *)filename
A full or relative path name specifying the file with the desired image data. Relative paths must be relative to the current working directory.
An initialized NSImage instance, or nil if the method cannot create an image representation from the contents of the specified file.
Unlike initByReferencingFile:, which initializes an NSImage object lazily, this method immediately opens the specified file and creates one or more image representations from its data.
The filename parameter should include the file extension that identifies the type of the image data. This method looks for an NSImageRep subclass that handles that data type from among those registered with NSImage.
NSImage.hInitializes and returns an NSImage instance with the contents of the specified URL.
- (id)initWithContentsOfURL:(NSURL *)aURL
The URL identifying the image.
An initialized NSImage instance, or nil if the method cannot create an image representation from the contents of the specified URL.
NSImage.h
Initializes and returns an NSImage instance with the contents of the specified NSData object.
- (id)initWithData:(NSData *)data
The data object containing the image data.
An initialized NSImage instance, or nil if the method cannot create an image representation from the contents of the specified data object.
NSImage.hInitializes the image object with a Carbon-style icon resource.
- (id)initWithIconRef:(IconRef)iconRef
A reference to a Carbon icon resource.
An initialized NSImage instance.
Creates one or more bitmap image representations, one for each size icon contained in the IconRef data structure. This initialization method automatically retains the data in the iconRef parameter and loads the bitmaps from that data file lazily.
NSImage.h
Initializes and returns an NSImage instance with data from the specified pasteboard.
- (id)initWithPasteboard:(NSPasteboard *)pasteboard
The pasteboard containing the image data.
An initialized NSImage instance, or nil if the method cannot create an image representation from the contents of the pasteboard.
The specified pasteboard should contain a type supported by one of the registered NSImageRep subclasses. Table 1 lists the default pasteboard types and file extensions for several NSImageRep subclasses.
Image representation class | Default pasteboard type | Default file extensions |
|---|---|---|
|
| |
|
| |
|
|
|
|
|
If the specified pasteboard contains the value NSFilenamesPboardType, each filename on the pasteboard should have an extension supported by one of the registered NSImageRep subclasses. You can use the imageUnfilteredFileTypes method of a given subclass to obtain the list of supported types for that class.
NSImage.h
Initializes and returns an NSImage instance whose size is set to the specified value.
- (id)initWithSize:(NSSize)aSize
The size of the image, measured in points.
An initialized NSImage instance.
This method does not add any image representations to the image object.. It is permissible to initialize the receiver by passing a size of (0.0, 0.0); however, the receiver’s size must be set to a non-zero value before the NSImage object is used or an exception will be raised.
NSImage.h
Returns a Boolean value indicating whether each image representation caches its contents in a separate offscreen window.
- (BOOL)isCachedSeparately
YES if the image representations cache their content in separate offscreen windows; otherwise, NO. The default value is NO.
If this method returns NO, it means that the image may be cached in a shared window but is not required to be. Images are cached in a shared window if they have the same general attributes, such as color space, resolution, and bit depth.
NSImage.h
Returns a Boolean value indicating whether the receiver retains its source image data.
- (BOOL)isDataRetained
YES if the image retains its source data; otherwise, NO. The default value is NO with some exceptions, which are covered in the discussion.
For image objects initialized using either the initByReferencingFile: or initByReferencingURL: method, this value is YES by default. The reason is that for these methods, data retention simply involves retaining the filename or URL.
Data retention increases the memory used by the NSImage object and its image representations.
NSImage.hReturns a Boolean value indicating whether the image uses a flipped coordinate system.
- (BOOL)isFlipped
YES if the image's coordinate system is flipped; otherwise, NO. The default is NO.
NSImage.hReturns a Boolean value indicating whether the image is a template image.
- (BOOL)isTemplate
YES if the image is a template image; otherwise, NO.
Template images consist of black and clear colors (and an alpha channel). Template images are not intended to be used as standalone images and are usually mixed with other content to create the desired final appearance.
NSImage.hReturns a Boolean value indicating whether an image representation from the receiver can be drawn.
- (BOOL)isValid
YES if the receiver can be drawn; otherwise, NO.
If the receiver is initialized with an existing image file, but the corresponding image data is not yet loaded into memory, this method loads the data and expands it as needed. If the receiver contains no image representations and no associated image file, this method creates a valid cached image representation and initializes it to the default bit depth. This method returns NO in cases where the file or URL from which it was initialized is nonexistent or when the data in an existing file is invalid.
NSImage.hPrepares the image to receive drawing commands.
- (void)lockFocus
This method sets the current drawing context to the area of the offscreen window used to cache the receiver's contents. Subsequent drawing commands are composited to this offscreen window. If the offscreen drawing area already has some content, any new drawing commands are composited with that content. This method does not modify the original image data directly.
When locking focus, this method chooses the best image representation object available and locks focus on that object. If the receiver has no image representations, this method creates one with the default depth and locks focus on it. For information on how the "best" representation is chosen, see the Images chapter of Cocoa Drawing Guide.
A successful lockFocus message must be balanced with a matching unlockFocus message to the same NSImage object. These messages bracket the code that draws the image.
If lockFocus is unable to focus on the image, it raises an NSImageCacheException.
NSImage.hPrepares the specified image representation to receive drawing commands.
- (void)lockFocusOnRepresentation:(NSImageRep *)imageRepresentation
An image representation belonging to the receiver, or nil if you want the receiver to choose which image representation to use.
This method sets the current drawing context to the area of the offscreen window used to cache the specified image representation's contents. Subsequent drawing commands are composited to this offscreen window. If the offscreen drawing area already has some content, any new drawing commands are composited with that content. This method does not modify the original image data directly.
If imageRepresentation is nil, this method acts like the lockFocus method, setting the focus to the best representation for the NSImage object.
A successful lockFocusOnRepresentation: message must be balanced with a matching unlockFocus message to the same NSImage object. These messages bracket the code that draws the image.
If lockFocusOnRepresentation: is unable to focus on the specified image representation, it raises an NSImageCacheException.
NSImage.hReturns a Boolean value indicating whether image representations whose resolution is an integral multiple of the device resolution are considered a match.
- (BOOL)matchesOnMultipleResolution
YES if image representations whose resolution is an integral multiple of the device resolution are considered a match; otherwise, NO.
When this method returns NO, only image representations whose resolution is exactly the same as the device resolution are considered matches. If this method returns YES and multiple image representations fit this criteria, the one whose resolution is closest to the device resolution is chosen.
The default value is YES.
NSImage.hReturns the name associated with the receiver, if any.
- (NSString *)name
The name associated with the receiver, or nil if no name is assigned.
NSImage.h
Returns a Boolean value indicating whether the image prefers to choose image representations using color matching or resolution matching.
- (BOOL)prefersColorMatch
YES if color matching is preferred over resolution matching; otherwise NO if resolution matching is preferred.
Both color matching and resolution matching may influence the choice of an image representation. This method simply indicates which technique is used first during the selection process. The default value is YES.
NSImage.hInvalidates and frees the offscreen caches of all image representations.
- (void)recache
If you modify an image representation, you must send a recache message to the corresponding image object to force the changes to be recached. The next time any image representation is drawn, it is asked to recreate its cached image. If you do not send this message, the image representation may use the old cache data. This method simply clears the cached image data; it does not delete the NSCachedImageRep objects associated with any image representations.
If you do not plan to use an image again right away, you can free its caches to reduce the amount of memory consumed by your program.
NSImage.h
Removes the specified image representation from the receiver and releases it.
- (void)removeRepresentation:(NSImageRep *)imageRep
The image representation object you want to remove.
NSImage.h
Returns an array containing all of the receiver's image representations.
- (NSArray *)representations
An array containing zero or more NSImageRep objects.
NSImage.h
Returns a Boolean value indicating whether image representations are scaled to fit the receiver's size.
- (BOOL)scalesWhenResized
YES if image representations are scaled to fit the receiver; otherwise, NO. The default value is NO.
Images are not resized during drawing if this method returns YES. They are only resized when you change the size by sending the receiver a setSize: message.
NSImage.hSets the alignment metadata that your code can use to position the image during layout.
- (void)setAlignmentRect:(NSRect)rect
The alignment rectangle for the image.
Alignment rectangles specify baselines that you can use to position the content of an image more accurately. These baselines are merely hints that your own code can use to determine positioning and are not used internally by NSImage itself during drawing. For example, if you have a 20 x 20 pixel icon that includes a glow effect, you might set the alignment rectangle to {{2, 2}, {16, 16}} to indicate the position of the underlying icon without the glow effect.
NSImage.h
Sets the background color of the image.
- (void)setBackgroundColor:(NSColor *)aColor
The new background color for the image.
The background color is visible only if the drawn image representation does not completely cover all of the pixels available for the image's current size. The background color is ignored for cached image representations; such caches are always created with a white background. This method does not cause the receiver to recache itself.
NSImage.hSets whether the receiver's offscreen window caches use the same bit depth as the image data itself.
- (void)setCacheDepthMatchesImageDepth:(BOOL)flag
YES if the offscreen caches use the same bit-depth associated with the image data; otherwise, NO to indicate they should use the default bit depth.
This method does not cause the receiver to recache itself. The default depth limit is equal to the bit depth of the deepest screen on the system.
NSImage.h
Sets whether each image representation uses a separate offscreen window to cache its contents.
- (void)setCachedSeparately:(BOOL)flag
YES if you want each of the receiver's image representation objects to use a separate offscreen window for caching; otherwise, NO.
If you specify NO, a representation can be cached together with other images, though in practice it might not be. This method does not invalidate any existing caches.
If you plan to resize an NSImage object frequently, it is usually more efficient to cache its representations separately. In some situations, you might also want to enable separate caching if you plan to use the compositeToPoint:fromRect:operation: or compositeToPoint:fromRect:operation:fraction:methods to draw the image.
NSImage.hSet the receiver’s caching mode.
- (void)setCacheMode:(NSImageCacheMode)mode
The caching mode to use with this image. For a list of possible values, see NSImageCacheMode.
The caching mode determines when the receiver's image representations use offscreen caches. Offscreen caches speed up rendering time but do so by using extra memory. In the default caching mode (NSImageCacheDefault), each image representation chooses the caching technique that produces the fastest drawing times. For example, in the default mode, the NSPDFImageRep and NSEPSImageRep classes use the NSImageCacheAlways mode but the NSBitmapImageRep class uses the NSImageCacheBySize mode.
For more information on image caching behavior, see the Images chapter of Cocoa Drawing Guide.
NSImage.h
Sets whether the receiver retains its source image data.
- (void)setDataRetained:(BOOL)flag
YES if you want the source image data to be retained; otherwise NO.
Retention of the source image data is important if the source of the image data could change, be moved, or be deleted. Data retention is also useful if you plan to resize an image frequently; otherwise, resizing occurs on a cached copy of the image, which can lose image quality during successive scaling operations. With data retention enabled, the image is resized from the original source data.
If the responsibility for drawing the image is delegated to another object, there is no reason to retain the image data. Similarly, if the source of the image data is not expected to change or you do not plan to resize the image, you do not need to retain the data. In fact, retaining the data leads to increased memory usage, which could have a negative impact on performance.
If you create your image object using the initByReferencingFile: method, the only data retained is the name of the source file.
NSImage.h
Sets the delegate object of the receiver.
- (void)setDelegate:(id)anObject
The new delegate object.
NSImage.h
Sets whether the polarity of the y axis is inverted when drawing an image.
- (void)setFlipped:(BOOL)flag
YES if you want the image data to be inverted before drawing; otherwise, NO.
If flag is YES, the y-axis of the image's internal coordinate system is inverted, with the origin in the upper-left corner and the positive y axis extending downward. This method affects only the coordinate system used internally by the image and the orientation of the image when it is drawn; it does not affect the coordinate system used to specify the position of an image in a view. This method does not cause the receiver to recache itself.
If you set flag to YES and then lock focus and draw into the image, the content you draw is cached in the inverted (flipped) orientation. Changing the value for flag does not affect the orientation of the cached image.
NSImage.hSets whether image representations whose resolutions are integral multiples of the device resolution are considered a match.
- (void)setMatchesOnMultipleResolution:(BOOL)flag
YES if image representations whose resolution is an integral multiple of the device resolution should be considered a match; otherwise, NO.
NSImage.hRegisters the receiver under the specified name.
- (BOOL)setName:(NSString *)aString
The name to associate with the receiver.
YES if the receiver was successfully registered with the given name; otherwise, NO.
If the receiver is already registered under a different name, this method unregisters the other name. If a different image is registered under the name specified in aString, this method does nothing and returns NO.
When naming an image using this method, it is convention not to include filename extensions in the names you specify. That way, you can easily distinguish between images you have named explicitly and those you want to load from the application's bundle. For information about the rules used to search for images, and for information about the ownership policy of named images, see the imageNamed: method.
NSImage.h
Sets whether choosing an image representation favors color matching over resolution matching.
- (void)setPrefersColorMatch:(BOOL)flag
YES if the receiver should match the color capabilities of the rendering device first; otherwise, NO to indicate that resolution matching is preferred.
Both color matching and resolution matching may influence the choice of an image representation. You use this method to choose which technique should be used first during the selection process.
NSImage.h
Sets whether different-sized image representations are scaled to fit the receiver's size.
- (void)setScalesWhenResized:(BOOL)flag
YES if image representations are scaled to fit; otherwise NO.
Most images (especially those loaded from files and URLs) contain only a single image representation whose size is the same as the receiver. It is possible to add image representations using the addRepresentation: or addRepresentations: methods but doing so is rarely necessary because modern hardware is powerful enough to resize and scale images quickly. The only reason to consider creating new representations is if each representations contains a customized version of the image at a specific size. (TIFF images may also contain a thumbnail version of an image, which is stored using a separate image representation.) If you pass YES in the flag parameter, and subsequently send a setSize: message to the receiver, all such image representations would be scaled to the same size. Scaling of bitmap images usually results in the interpolation of the bitmap data.
This method does not invalidate the caches of any of the receiver's image representations. The caches are not invalidated until you change the image size using a setSize: message. Scaling affects only the cached offscreen data for a given image representation.
NSImage.hSets the width and height of the image.
- (void)setSize:(NSSize)aSize
The new size of the image, measured in points.
The size of an NSImage object must be set before it can be used. If the size of the image hasn’t already been set when an image representation is added, the size is taken from the image representation's data. For EPS images, the size is taken from the image's bounding box. For TIFF images, the size is taken from the ImageLength and ImageWidth attributes.
Changing the size of an NSImage after it has been used effectively resizes the image. Changing the size invalidates all its caches and frees them. When the image is next composited, the selected representation will draw itself in an offscreen window to recreate the cache.
NSImage.hSets whether the image represents a template image.
- (void)setTemplate:(BOOL)isTemplate
Specify YES if the image is a template image; otherwise, NO.
Images you mark as template images should consist of only black and clear colors. You can use the alpha channel in the image to adjust the opacity of black content, however.
Template images are not intended to be used as standalone images. They are always mixed with other content and processed to create the desired appearance. You can mark an image as a “template image” to notify clients who care that the image contains only black and clear content. The most common use for template images is in image cells. For example, you might use a template image to provide the content for a button or segmented control. Cocoa cells take advantage of the nature of template images—that is, their simplified color scheme and use of transparency—to improve the appearance of the corresponding control in each of its supported states.
NSImage.hSets whether EPS image representations are preferred when no other representations match the resolution of the device.
- (void)setUsesEPSOnResolutionMismatch:(BOOL)flag
YES if EPS image representations are preferred; otherwise NO.
NSImage.hReturns the size of the receiver.
- (NSSize)size
The size of the receiver or (0.0, 0.0) if no size has been set and the size cannot be determined from any of the receiver's image representations.
NSImage.h
Returns a data object containing TIFF data for all of the image representations in the receiver.
- (NSData *)TIFFRepresentation
A data object containing the TIFF data, or nil if the TIFF data could not be created.
You can use the returned data object to write the TIFF data to a file. For each image representation, this method uses the TIFF compression option associated with that representation or NSTIFFCompressionNone, if no option is set.
If one of the receiver's image representations does not support the creation of TIFF data natively (PDF and EPS images, for example), this method creates the TIFF data from that representation's cached content.
– TIFFRepresentationUsingCompression:factor:– representationUsingType:properties: (NSBitmapImageRep)– TIFFRepresentation (NSBitmapImageRep)– TIFFRepresentationUsingCompression:factor: (NSBitmapImageRep)NSImage.h
Returns a data object containing TIFF data with the specified compression settings for all of the image representations in the receiver.
- (NSData *)TIFFRepresentationUsingCompression:(NSTIFFCompression)comp factor:(float)aFloat
The type of compression to use. For a list of values, see the constants in NSBitmapImageRep.
Provides a hint for compression types that implement variable compression ratios. Currently, only JPEG compression uses a compression factor.
A data object containing the TIFF data, or nil if the TIFF data could not be created.
You can use the returned data object to write the TIFF data to a file. If the specified compression isn’t applicable, no compression is used. If a problem is encountered during generation of the TIFF data, this method may raise an exception.
If one of the receiver's image representations does not support the creation of TIFF data natively (PDF and EPS images, for example), this method creates the TIFF data from that representation's cached content.
– TIFFRepresentation– representationUsingType:properties: (NSBitmapImageRep)– TIFFRepresentation (NSBitmapImageRep)– TIFFRepresentationUsingCompression:factor: (NSBitmapImageRep)NSImage.h
Removes the focus from the receiver.
- (void)unlockFocus
This message must be sent after a successful lockFocus or lockFocusOnRepresentation: message and the completion of any intermediate drawing commands. This method restores the focus to the previous owner, if any.
Do not send this message if the preceding call to lock focus raised an NSImageCacheException.
NSImage.hReturns a Boolean value indicating whether EPS representations are preferred when no other representations match the resolution of the device.
- (BOOL)usesEPSOnResolutionMismatch
YES if EPS image representations are preferred; otherwise NO.
The default value is NO.
NSImage.hDuring incremental loading, this method is called repeatedly to inform the delegate that more of the image data is available.
- (void)image:(NSImage *)image didLoadPartOfRepresentation:(NSImageRep *)rep withValidRows:(NSInteger)rows
The image object whose contents are being loaded.
The image representation object that is receiving and processing the image data.
The number of rows of data that have been decompressed.
This method is optional; incremental loading will continue if the delegate does not implement it.
NSImage.hFor incremental loading, this method is invoked when the specified image has been loaded and decompressed as fully as is possible.
- (void)image:(NSImage *)image didLoadRepresentation:(NSImageRep *)rep withStatus:(NSImageLoadStatus)status
The image object whose contents are being loaded.
The image representation object that loaded the image data.
The status of the load operation. For a list of possible values, see “Constants.”
The delegate must implement this method if it wants to support the incremental loading of images. In that case, you must also set up the image object to be loaded lazily, by initializing it using the initByReferencingFile: or initByReferencingURL: method.
If an error occurs during downloading or decompression, the status parameter is set to NSImageLoadStatusInvalidData, NSImageLoadStatusUnexpectedEOF, or NSImageLoadStatusReadError. If the download was cancelled, the status parameter is set to NSImageLoadStatusCancelled.
NSImage.hDuring incremental loading, this method is called once enough data has been read to determine the size of the image.
- (void)image:(NSImage *)image didLoadRepresentationHeader:(NSImageRep *)rep
The image object whose contents are being loaded.
The image representation object that is receiving and processing the image data.
By the time this method is called, the NSBitmapImageRep object specified in the rep parameter is valid and has allocated the memory needed to store the bitmap. The bitmap itself is filled with the image's background color. This method is optional; incremental loading will continue if the delegate does not implement it.
NSImage.hFor incremental loading, this method is invoked when you first attempt to draw the image or otherwise access the bitmap data.
- (void)image:(NSImage *)image willLoadRepresentation:(NSImageRep *)rep
The image object whose contents need to be loaded.
The image representation object that was accessed.
Downloading of the image begins immediately after this method returns. This method is optional; incremental loading will continue if the delegate does not implement it.
NSImage.hSent to the delegate when the image object is unable, for whatever reason, to lock focus on its image or draw in the specified rectangle.
- (NSImage *)imageDidNotDraw:(id)sender inRect:(NSRect)aRect
The NSImage object that encountered the problem.
The rectangle that the image object was attempting to draw.
An NSImage to draw in place of the one in sender, or nil if the delegate wants to draw the image itself.
The delegate can do one of the following:
Return another NSImage object to draw in the sender’s place.
Draw the image itself and return nil,.
Simply return nil to indicate that sender should give up on the attempt at drawing the image.
NSImage.hThese constants specify compositing operators described in terms of having source and destination images, each having an opaque and transparent region. The destination image after the operation is defined in terms of the source and destination before images.
typedef enum _NSCompositingOperation { NSCompositeClear = 0, NSCompositeCopy = 1, NSCompositeSourceOver = 2, NSCompositeSourceIn = 3, NSCompositeSourceOut = 4, NSCompositeSourceAtop = 5, NSCompositeDestinationOver = 6, NSCompositeDestinationIn = 7, NSCompositeDestinationOut = 8, NSCompositeDestinationAtop = 9, NSCompositeXOR = 10, NSCompositePlusDarker = 11, NSCompositeHighlight = 12, NSCompositePlusLighter = 13 } NSCompositingOperation;
NSCompositeClearTransparent. (R = 0)
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeCopySource image. (R = S)
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeSourceOverSource image wherever source image is opaque, and destination image elsewhere. (R = S + D*(1 - Sa))
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeSourceInSource image wherever both images are opaque, and transparent elsewhere. (R = S*Da)
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeSourceOutSource image wherever source image is opaque but destination image is transparent, and transparent elsewhere. (R = S*(1 - Da))
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeSourceAtopSource image wherever both images are opaque, destination image wherever destination image is opaque but source image is transparent, and transparent elsewhere. (R = S*Da + D*(1 - Sa))
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeDestinationOverDestination image wherever destination image is opaque, and source image elsewhere. (R = S*(1 - Da) + D)
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeDestinationInDestination image wherever both images are opaque, and transparent elsewhere. (R = D*Sa)
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeDestinationOutDestination image wherever destination image is opaque but source image is transparent, and transparent elsewhere. (R = D*(1 - Sa))
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeDestinationAtopDestination image wherever both images are opaque, source image wherever source image is opaque but destination image is transparent, and transparent elsewhere. (R = S*(1 - Da) + D*Sa)
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeXORExclusive OR of source and destination images. (R = S*(1 - Da) + D*(1 - Sa))
Works only with black and white images and is not recommended for color contexts.
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositePlusDarkerSum of source and destination images, with color values approaching 0 as a limit. (R = MAX(0, (1 - D) + (1 - S)))
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositeHighlightSource image wherever source image is opaque, and destination image elsewhere. (Deprecated. Mapped to NSCompositeSourceOver.)
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
NSCompositePlusLighterSum of source and destination images, with color values approaching 1 as a limit. (R = MIN(1, S + D))
Available in Mac OS X v10.0 and later.
Declared in NSGraphics.h.
These compositing operators are defined in and used by compositeToPoint:fromRect:operation:, compositeToPoint:operation:, compositeToPoint:fromRect:operation:fraction:, compositeToPoint:operation:fraction:, drawAtPoint:fromRect:operation:fraction:, and drawInRect:fromRect:operation:fraction:. They are also used by drawing methods in other classes that take a compositing operator.
The equations after each constant represent the mathematical formulas used to calculate the color value of the resulting pixel. Table 2 lists the meaning of each placeholder value in the equations.
Para | Para |
|---|---|
| The premultiplied result color. |
| The source color |
| The destination color |
| The alpha value of the source color |
| The alpha value of the destination color |
NSGraphics.hThese constants are status values passed to the incremental loading delegate method image:didLoadRepresentation:withStatus:.
typedef enum {
NSImageLoadStatusCompleted,
NSImageLoadStatusCancelled,
NSImageLoadStatusInvalidData,
NSImageLoadStatusUnexpectedEOF,
NSImageLoadStatusReadError
} NSImageLoadStatus;
NSImageLoadStatusCompletedEnough data has been provided to completely decompress the image.
Available in Mac OS X v10.2 and later.
Declared in NSImage.h.
NSImageLoadStatusCancelledImage loading was canceled.
The image contains the portions of the data that have already been successfully decompressed, if any.
Available in Mac OS X v10.2 and later.
Declared in NSImage.h.
NSImageLoadStatusInvalidDataAn error occurred during image decompression.
The image data is probably corrupt. The image contains the portions of the data that have already been successfully decompressed, if any.
Available in Mac OS X v10.2 and later.
Declared in NSImage.h.
NSImageLoadStatusUnexpectedEOFNot enough data was available for full decompression of the image.
The image contains the portions of the data that have already been successfully decompressed, if any.
Available in Mac OS X v10.2 and later.
Declared in NSImage.h.
NSImageLoadStatusReadErrorNot enough data was available for full decompression of the image.
The image contains the portions of the data that have already been successfully decompressed, if any.
Available in Mac OS X v10.2 and later.
Declared in NSImage.h.
NSImage.hThese constants specify the caching policy on a per NSImage basis. The caching policy is set using cacheMode and setCacheMode:.
typedef enum {
NSImageCacheDefault,
NSImageCacheAlways,
NSImageCacheBySize,
NSImageCacheNever
} NSImageCacheMode;
NSImageCacheDefaultCaching is unspecified.
Use the image rep's default.
Available in Mac OS X v10.2 and later.
Declared in NSImage.h.
NSImageCacheAlwaysAlways generate a cache when drawing.
Available in Mac OS X v10.2 and later.
Declared in NSImage.h.
NSImageCacheBySizeCache if cache size is smaller than the original data.
Available in Mac OS X v10.2 and later.
Declared in NSImage.h.
NSImageCacheNeverNever cache; always draw direct.
Available in Mac OS X v10.2 and later.
Declared in NSImage.h.
The following table specifies the default caching policy for the various types of image representation.
Image Rep Class |
Default caching policy |
|---|---|
|
|
|
|
| |
|
|
| |
|
NSImage.hImages representing standard artwork and icons that you can use in your applications
NSString *const NSImageNameQuickLookTemplate; NSString *const NSImageNameBluetoothTemplate; NSString *const NSImageNameIChatTheaterTemplate; NSString *const NSImageNameSlideshowTemplate; NSString *const NSImageNameActionTemplate; NSString *const NSImageNameSmartBadgeTemplate; NSString *const NSImageNamePathTemplate; NSString *const NSImageNameInvalidDataFreestandingTemplate; NSString *const NSImageNameLockLockedTemplate; NSString *const NSImageNameLockUnlockedTemplate; NSString *const NSImageNameGoRightTemplate; NSString *const NSImageNameGoLeftTemplate; NSString *const NSImageNameRightFacingTriangleTemplate; NSString *const NSImageNameLeftFacingTriangleTemplate; NSString *const NSImageNameAddTemplate; NSString *const NSImageNameRemoveTemplate; NSString *const NSImageNameRevealFreestandingTemplate; NSString *const NSImageNameFollowLinkFreestandingTemplate; NSString *const NSImageNameEnterFullScreenTemplate; NSString *const NSImageNameExitFullScreenTemplate; NSString *const NSImageNameStopProgressTemplate; NSString *const NSImageNameStopProgressFreestandingTemplate; NSString *const NSImageNameRefreshTemplate; NSString *const NSImageNameRefreshFreestandingTemplate;
NSImageNameQuickLookTemplateA Quick Look template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameBluetoothTemplateA Bluetooth template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameIChatTheaterTemplateAn iChat Theater template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameSlideshowTemplateA slideshow template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameActionTemplateAn action menu template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameSmartBadgeTemplateA badge for a “smart” item. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNamePathTemplateA path button template image.
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameInvalidDataFreestandingTemplateAn invalid data template image. Place this icon to the right of any fields containing invalid data. You can use this image to implement a borderless button. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameLockLockedTemplateA locked lock template image. Use to indicate locked content. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameLockUnlockedTemplateAn unlocked lock template image. Use to indicate modifiable content that can be locked. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameGoRightTemplateA “go forward” template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameGoLeftTemplateA “go back” template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameRightFacingTriangleTemplateA generic right-facing triangle template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameLeftFacingTriangleTemplateA generic left-facing triangle template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameAddTemplateAn add item template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameRemoveTemplateA remove item template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameRevealFreestandingTemplateA reveal contents template image. You can use this image to implement a borderless button. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameFollowLinkFreestandingTemplateA link template image. You can use this image to implement a borderless button. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameEnterFullScreenTemplateAn enter full-screen mode template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameExitFullScreenTemplateAn exit full-screen mode template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameStopProgressTemplateA stop progress button template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameStopProgressFreestandingTemplateA stop progress template image. You can use this image to implement a borderless button. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameRefreshTemplateA refresh template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameRefreshFreestandingTemplateA refresh template image. You can use this image to implement a borderless button. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
To access these images, pass the specified constant to the imageNamed: method.
Images with the word “Template” in their title identify shapes that are not intended as standalone images. You would typically use these icons as the custom image for a button, or you might apply them to a cell in a control. For example, you might use the NSImageNameLockLockedTemplate image to indicate an item is not modifiable. Template images should use black and clear colors only and it is fine to include varying levels of alpha.
Images with the word “Freestanding” in their title can be used to implement borderless buttons. You do not need to include any extra bezel artwork behind such images.
You should always use named images according to their intended purpose, and not according to how the image appears when loaded. The appearance of images can change between releases. If you use an image for its intended purpose (and not because of it looks), your code should look correct from release to release.
The size and aspect ratio of system images may change from release to release. In some situations, you should explicitly resize images as appropriate for your use. If you use these images in conjunction with an NSButtonCell object, however, you can use the setImageScaling: method of the cell to control scaling instead. Similarly, for an NSSegmentedCell object, you can use the setImageScaling:forSegment: method to control scaling.
The string value for each constant is equal to the constant name without the “ImageName” portion. You might need this information to locate images by name in Interface Builder. For example, the constant NSImageNameRefreshFreestandingTemplate would correspond to an image named “NSRefreshFreestandingTemplate” in Interface Builder.
NSImage.hDrag images you can use in your applications.
NSString *const NSImageNameMultipleDocuments;
NSImageNameMultipleDocumentsA drag image for multiple items. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
To access this image, pass the specified constant to the imageNamed: method.
You can use this icon as the drag image when dragging multiple items. You should not use this image for any other intended purpose, however. The appearance of images can change between releases. If you use an image for its intended purpose (and not because of how it looks), your code should look correct from release to release.
The size and aspect ratio of system images may change from release to release. In some situations, you should explicitly resize images as appropriate for your use. If you use these images in conjunction with an NSButtonCell object, however, you can use the setImageScaling: method of the cell to control scaling instead. Similarly, for an NSSegmentedCell object, you can use the setImageScaling:forSegment: method to control scaling.
The string value for each constant is equal to the constant name without the “ImageName” portion. You might need this information to locate images by name in Interface Builder. For example, the constant NSImageNameMultipleDocuments would correspond to an image named “NSMultipleDocuments” in Interface Builder.
NSImage.hImages representing sharing permission icons that you can use in your applications.
NSString *const NSImageNameUser; NSString *const NSImageNameUserGroup; NSString *const NSImageNameEveryone;
NSImageNameUserPermissions for a single user. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameUserGroupPermissions for a group of users.
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameEveryonePermissions for all users. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
To access these images, pass the specified constant to the imageNamed: method.
You should use these images to reflect user and group permission or sharing information. The appearance of images can change between releases. If you use an image for its intended purpose (and not because of how it looks), your code should look correct from release to release.
The size and aspect ratio of system images may change from release to release. In some situations, you should explicitly resize images as appropriate for your use. If you use these images in conjunction with an NSButtonCell object, however, you can use the setImageScaling: method of the cell to control scaling instead. Similarly, for an NSSegmentedCell object, you can use the setImageScaling:forSegment: method to control scaling.
The string value for each constant is equal to the constant name without the “ImageName” portion. You might need this information to locate images by name in Interface Builder. For example, the constant NSImageNameEveryone would correspond to an image named “NSEveryone” in Interface Builder.
NSImage.hImages representing Finder items.
NSString *const NSImageNameBonjour; NSString *const NSImageNameDotMac; NSString *const NSImageNameComputer; NSString *const NSImageNameFolderBurnable; NSString *const NSImageNameFolderSmart; NSString *const NSImageNameNetwork;
NSImageNameBonjourA Bonjour icon. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameDotMacA Dot Mac icon. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameComputerA computer icon. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameFolderBurnableA burnable folder icon. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameFolderSmartA smart folder icon. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameNetworkA network icon. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
To access these images, pass the specified constant to the imageNamed: method.
You should use these images to reflect specific elements of the Mac OS X environment. For example, you might use the burnable folder icon if your software allows the user to organize content for burning onto an optical disk. The appearance of images can change between releases. If you use an image for its intended purpose (and not because of how it looks), your code should look correct from release to release.
The size and aspect ratio of system images may change from release to release. In some situations, you should explicitly resize images as appropriate for your use. If you use these images in conjunction with an NSButtonCell object, however, you can use the setImageScaling: method of the cell to control scaling instead. Similarly, for an NSSegmentedCell object, you can use the setImageScaling:forSegment: method to control scaling.
The string value for each constant is equal to the constant name without the “ImageName” portion. You might need this information to locate images by name in Interface Builder. For example, the constant NSImageNameNetwork would correspond to an image named “NSNetwork” in Interface Builder.
NSImage.hImages that you can use in application toolbars.
NSString *const NSImageNameUserAccounts; NSString *const NSImageNamePreferencesGeneral; NSString *const NSImageNameAdvanced; NSString *const NSImageNameInfo; NSString *const NSImageNameFontPanel; NSString *const NSImageNameColorPanel;
NSImageNameUserAccountsUser account toolbar icon. Use in a preferences window only. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNamePreferencesGeneralGeneral preferences toolbar icon. Use in a preferences window only. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameAdvancedAdvanced preferences toolbar icon. Use in a preferences window only. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameInfoAn information toolbar icon. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameFontPanelA font panel toolbar icon. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameColorPanelA color panel toolbar icon. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
To access these images, pass the specified constant to the imageNamed: method.
You should use these images as icons for toolbar items. The appearance of images can change between releases. If you use an image for its intended purpose (and not because of how it looks), your code should look correct from release to release.
The size and aspect ratio of system images may change from release to release. In some situations, you should explicitly resize images as appropriate for your use. If you use these images in conjunction with an NSButtonCell object, however, you can use the setImageScaling: method of the cell to control scaling instead. Similarly, for an NSSegmentedCell object, you can use the setImageScaling:forSegment: method to control scaling.
The string value for each constant is equal to the constant name without the “ImageName” portion. You might need this information to locate images by name in Interface Builder. For example, the constant NSImageNameColorPanel would correspond to an image named “NSColorPanel” in Interface Builder.
NSImage.hImages used in segmented controls to switch the current view type.
NSString *const NSImageNameIconViewTemplate; NSString *const NSImageNameListViewTemplate; NSString *const NSImageNameColumnViewTemplate; NSString *const NSImageNameFlowViewTemplate;
NSImageNameIconViewTemplateAn icon view mode template image. ![]()
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameListViewTemplateA list view mode template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameColumnViewTemplateA column view mode template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
NSImageNameFlowViewTemplateA cover flow view mode template image. 
Available in Mac OS X v10.5 and later.
Declared in NSImage.h.
To access these images, pass the specified constant to the imageNamed: method.
Images with the word “Template” in their title identify shapes that are not intended as standalone images. You would typically use these icons as the custom image for a button, or you might apply them to a cell in a control. For example, you might use the NSImageNameIconViewTemplate image to indicate an item is not modifiable. Template images should use black and clear colors only and it is fine to include varying levels of alpha.
You should use these images in conjunction with the buttons (usually part of a segmented control) that change the current viewing mode. The appearance of images can change between releases. If you use an image for its intended purpose (and not because of how it looks), your code should look correct from release to release.
The size and aspect ratio of system images may change from release to release. In some situations, you should explicitly resize images as appropriate for your use. If you use these images in conjunction with an NSButtonCell object, however, you can use the setImageScaling: method of the cell to control scaling instead. Similarly, for an NSSegmentedCell object, you can use the setImageScaling:forSegment: method to control scaling.
The string value for each constant is equal to the constant name without the “ImageName” portion. You might need this information to locate images by name in Interface Builder. For example, the constant NSImageNameFlowViewTemplate would correspond to an image named “NSFlowViewTemplate” in Interface Builder.
NSImage.h
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)