Developer Documentation
PATH  Mac OS X Documentation > Application Kit Reference: Objective-C


[Previous] [Class List] [Next]

NSPICTImageRep


Inherits from: NSImageRep : NSObject
Conforms to: NSCoding
(from NSImageRep)
NSCopying (from NSImageRep)
NSObject (from NSObject)
Declared in: AppKit/NSPICTImageRep.h




Class Description


An NSPICTImageRep is an object that can render an image from a PICT format data stream as described in Inside Macintosh: Imaging With QuickDraw. This includes PICT format version 1, version 2, and extended version 2 pictures.

WARNING

There is no guarantee that the image will render exactly the same as it would under QuickDraw because of the differences between Display PostScript and QuickDraw. In particular, some transfer modes and region operations may not be supported.

Like most other kinds of NSImageReps, an NSPICTImageRep is generally used indirectly, through an NSImage object. An NSImage must be able to choose from among various representations of a given image. It also needs to provide an off-screen cache of the appropriate depth for any image it uses. It determines this information by querying its NSImageReps.

Thus to work with an NSImage, an NSPICTImageRep must be able to provide some information about its image. The bounding box is obtained from the PICT format data. Use these methods, inherited from the NSImageRep class, to set the other attributes of an NSPICTImageRep object:

Note that if these attributes aren't set, and an NSPICTImageRep is used in an NSImage with other representations, NSImage won't be able to select from among the representations. In actual practice, this usually isn't a problem.


Method Types


Creating an NSPICTImageRep
+ imageRepWithData:
- initWithData:
Getting image data
- boundingBox
- PICTRepresentation

Class Methods



imageRepWithData:

+ (id)imageRepWithData:(NSData *)pictData

Creates a new NSPICTImageRep instance and then invokes initWithData: to initialize it with the contents of pictData, a PICT format data stream. If the new object can't be initialized for any reason (for example, pictData doesn't conform to the PICT file format), this method frees the receiver and returns nil. Otherwise, it returns a new instance of NSPICTImageRep.

See Also: - PICTRepresentation




Instance Methods



boundingBox

- (NSRect)boundingBox

Returns the rectangle that bounds the image. The rectangle is obtained from the PICT format data, specifically the picFrame field in the picture header. See Inside Macintosh: Imaging With QuickDraw for information on the picture header.

initWithData:

- (id)initWithData:(NSData *)pictData

Initializes the receiver, a newly allocated NSPICTImageRep object, with the contents of pictData, a PICT format data stream. If pictData is obtained directly from a PICT file or document, it contains a 512-byte header before the actual picture data starts. This method simply ignores that header. If the new object can't be initialized for any reason (for example, pictData doesn't conform to the PICT file format), this method frees the receiver and returns nil. Otherwise, it returns self.

See Also: + imageRepWithData:, - PICTRepresentation



PICTRepresentation

- (NSData *)PICTRepresentation

Returns the PICT representation of the receiver. The returned PICT data is a copy of the data supplied to initWithData: minus the 512 byte header if it is present. Note, PICT files or documents contain a 512-byte header, so if you wish to save the returned data to a file you need to precede the data with 512 bytes (all zero) to conform to the PICT document format.


[Previous] [Next]