Instance Method

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

Draws all or part of the image in the specified rectangle in the current coordinate system.

Declaration

- (BOOL)drawInRect:(NSRect)dstSpacePortionRect fromRect:(NSRect)srcSpacePortionRect operation:(NSCompositingOperation)op fraction:(CGFloat)requestedAlpha respectFlipped:(BOOL)respectContextIsFlipped hints:(NSDictionary<NSImageHintKey, id> *)hints;

Parameters

dstSpacePortionRect

The rectangle in which to draw the image, specified in the current coordinate system.

srcSpacePortionRect

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.

op

The compositing operation to use when drawing the image. See the NSCompositingOperation constants.

requestedAlpha

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.

respectContextIsFlipped

YES if the flipped context of the receiver should be respected, otherwise NO.

hints

An optional dictionary of hints that provide more context for selecting or generating the image. See Image Hint Dictionary Keys for possible values.

Return Value

YES if the image was successfully drawn; otherwise, NO.

Discussion

If the srcSpacePortionRect and dstSpacePortionRect rectangles have different sizes, the source portion of the image is scaled to fit the specified destination rectangle.

See Also

Drawing the Image

- draw

Implemented by subclasses to draw the image in the current coordinate system.

- drawAtPoint:

Draws the receiver's image data at the specified point in the current coordinate system.

- drawInRect:

Draws the image, scaling it (as needed) to fit the specified rectangle.

NSImageHintKey

Constants for the keys to include in a hints dictionary when drawing the image.