views:

242

answers:

1

What is the difference between the last two lines?

 CIImage *outputImage = [compositingFilter valueForKey:@"outputImage"];


 [[[NSGraphicsContext currentContext] CIContext] drawImage:outputImage atPoint:point fromRect:fromRect];

 [outputImage drawAtPoint:point fromRect:fromRect operation:op fraction:delta];

The last one produces a distorted image with a rect that is smaller than [outputImage extent];

The drawImage: line crashes on some occasions.

A: 

From the docs on -drawAtPoint:…

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.

fromRect should be the entire size of the image if you're wanting the whole thing drawn. Also in many cases flippedness is handled differently between different drawing methods.

Lastly, the docs on -drawImage:… somewhat cryptically only state:

You can call this method to force evaluation of the result after you apply a filter using one of the methods of the CIFilter class, such as apply:, apply:arguments:options:, and apply:k…

Hope this helps.

Ben Lachman