Ah, so your problem is that not every CG blend mode is available as an NSCompositingOperation? If you would, please file a quick bug mentioning that you needed this.

If you're running on 10.6, you can use -[NSImage CGImageForProposedRect:context:hints:] to get a CGImage, then draw the CGImage with your blend mode. See the AppKit relnotes for details, but that's likely to be efficient. If that method isn't available, you can get the same end effect by taking a destination CGContext, setting the blend mode to darken, starting a transparency layer, drawing the NSImage in copy or source over mode, and ending the transparency layer. The layers contents are composited to the context in darken mode. Repeat for each NSImage. Perf-wise, this is like drawing each image once in copy mode and once in darken mode. Copy mode is vectorized, darken mode isn't, so I would expect to see most of your time in CGContextEndTransparencyLayer for images of reasonable size.

-Ken
Sent from my iPhone, so be forgiving.

On Apr 18, 2010, at 7:14 PM, Izak van Langevelde <eezac...@xs4all.nl> wrote:

I need to combine a number of NSImages such that each pixel of the result is the darkest of the corresponding pixels of the NSImages. Blend mode 'darken' does exactly what I need to, but I'm clueless about how to efficiently apply blend modes to NSImages. An alternative is to use an NSCompositingOperation, but the best candidate NSCompositePlusDarker is not exactly what I need. I could convert my NSImage to a bitmap and do my thing, but fear a performance hit.

Any suggestions?

Thanks,
Izak
---
Grinnikend door het leven...

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com

This email sent to kenfe...@gmail.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to