Thank you Ken, and for the transparency layer hint too, I wouldn't have thought of that.

I missed a whole load of blend modes not realizing that the Quartz 2D Programming Guide didn't list them all, it stops at luminosity, my bad there for not checking out the actual class docs and finding all the other ones (which they actually give formulae for too!)

One question about Transparency Layers, the docs say that when you start one the global alpha is set to 1, shadows are turned off and blend mode is set normal (actually only the Quartz 2D guide says that the blend mode changes, the actual API docs don't mention it). When the layer is ended it's composited back to the original context, what blending mode is used to do that, I assume the original blend mode at the point the Transparency Layer was started right?

On 23-Sep-2009, at 4:05 AM, Ken Ferry wrote:

On Tue, Sep 22, 2009 at 9:20 AM, David Duncan <[email protected]> wrote:
On Sep 21, 2009, at 9:32 PM, Roland King wrote:

I'm trying to construct an image which is colored according to the alpha value of a different image. I've been hunting around the Quartz Core docs and I can't figure out a good way to do this. The motivation is to do something similar to what apple does on the iphone tabbar items which are drawn white or blue using the alpha of the image you supply and it's a pretty good effect I want to reuse.


Just use your second image as a mask via CGContextClipToMask(). If you use a normal image, then the alpha values are used as alpha for the drawing you do which should do exactly what you want.

Also, this bit

So for instance if I my drawing color is D and the point on my underlying image is {r,g,b,a}, I want to draw a point of color S * a.

seems to have a typo, but there are compositing modes for whatever operation you're talking about here.

DestinationIn is Result = DestinationColor * SourceAlpha. So you could do CGContextBeginTransparencyLayer, draw mask with SourceOver, draw color to be masked with DestinationIn, CGContextEndTransparencyLayer.

There are quite a few modes that use only the alpha channel from either source or destination.

-Ken

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to