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: BravoBug Software <email@hidden>
- Date: Mon, 21 Sep 2009 22:03:53 -0700
Modifying the bitmap data yourself shouldn't be too difficult, for an
NSBitmapImageRep you'd just grab the data with the -bitmapData method.
But have you checked out CIFilter? I'm not entirely sure I understood
what your goal is but there's likely a filter in place already that
will do it for you:
https://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/CoreImageFilterReference/Reference/reference.html
https://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/QuartzCoreFramework/Classes/CIFilter_Class/Reference/Reference.html
On Mon, Sep 21, 2009 at 9:32 PM, Roland King <email@hidden> 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.
>
> 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.
>
> Assume that I have the image I want to process and I can get that into a
> bitmap - because I do and I have.
>
> I've looked at all the colour blending modes but unless I've missed
> something, all of them deal, as you'd expect, in colour, not alpha, so I
> can't find one of those I think I can use which totally ignores the colour
> information.
>
> I thought about using a CFImageMask which has points which are white where
> the underlyer is alpha=1 and black where it's 0 and all points between but
> creating that from the original image is the same problem..
>
> I thought about wandering through the bytes of data in the bitmap (assuming
> I can even figure out how to access them which currently I cannot) and
> changing them but that seems pretty hokey even if I deal correctly with the
> byte orderings the packing and .. getting to the data in the first place.
>
> I'm sure I've entirely missed some piece of Quartz or CF here which does
> exactly what I want, or a blending mode I can use cleverly for this. Any
> pointers would be very useful.
>
> Roland
> _______________________________________________
>
> 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
>
_______________________________________________
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