Re: drawing/masking one image with the alpha value from another
Re: drawing/masking one image with the alpha value from another
- Subject: Re: drawing/masking one image with the alpha value from another
- From: Roland King <email@hidden>
- Date: Wed, 23 Sep 2009 00:42:42 +0800
Thanks David .. I'm a little confused by this though. The
documentation for masks doesn't really tell you where alpha fits in to
the overall 'mask value', in fact they don't really say how a general
RGB value maps to 0->1.0. They talk totally about color as in RGB
(1,1,1) maps to 1 and RGB(0,0,0) maps to 0 in the mask. The docs don't
say for instance what RGB(1,0,0) maps to, I've been assuming it's 1/3
or so.
The mask images I'm using can be a bit degenerate however. They have a
lot of one primary colour and nothing else, but that colour is still
alpha=1 and if I'm using a mask I'd need that to map to 1. My
experiments indicate that doesn't happen. ie I'd need RGBA(1,0,0,1),
RGBA(0,1,0,1), RGBA(0,0,1,1), RGBA( 0,0,0,1) and RGBA(1,1,1,1) all to
map to .. one and it seems to me that's not how the masks work. I
really just want the alpha channel and nothing else, my experiments
seem to show that RGBA(0,0,0,1) for instance maps to 0, I need that to
map to 1.
What I've been working with now (and appears to be working) is a
decode array which maps RGB to [ 1.0, 1.0 ] and alpha to [ 0.0, 1.0 ],
that seems to be working for me, every pixel ends up as RGBA( 1, 1, 1,
alpha) and that I can paint with quite happily.
Note on the phone that the decode array has to be backwards because
the alpha value comes first by default, that was a surprise discovery.
If you think I've missed something vital here about masks please point
it out.
On 23-Sep-2009, at 12:20 AM, David Duncan 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.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden