Contents

compositeToPoint:fromRect:operation:

Composites a portion of the image to the specified point in the current coordinate system.

Declaration

- (void) compositeToPoint:(NSPoint) point fromRect:(NSRect) rect operation:(NSCompositingOperation) operation;

Parameters

  • point:

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

  • rect:

    The portion of the image you want to draw, specified in the image’s coordinate system.

  • operation:

    The compositing operation to use when drawing the image to the screen. The supported compositing operations are described in Constants.

Discussion

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 using the draw(at:from: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.

See Also

Related Documentation

Instance Methods