Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a couple of CGContext questions



On Jan 30, 2007, at 5:17 PM, David Duncan wrote:

On Jan 30, 2007, at 4:14 PM, Steve Christensen wrote:

Yes. For alpha, I'd like to be able to make changes relative to an arbitrary current context alpha setting, i.e., CGContextSetAlpha (theContext, CGContextGetAlpha(theContext) * 0.5) -- assuming a CGContextGetAlpha function existed.

If you do this, you'll get the alpha double counted. Whatever alpha you set for the context is automatically calculated into further drawing operations on the context, including those that include alpha drawing. So the effective alpha of any drawing operation is pixelAlpha * contextAlpha.

I'm not sure I understand the double counting part, but I understand that once an operation has been performed on a context that the resulting pixels take into account the pixel's previous alpha value as well as that of the context's alpha. All I'm saying is that I'd like to be able to do things like this:


theAlpha = CGContextGetAlpha(theContext);

CGContextSetAlpha(theContext, theAlpha * 0.5);
CGContextStrokeRect(theContext, theRect);
CGContextSetAlpha(theContext, theAlpha);

In this case, I'd expect to see a rectangle drawn at half the current context alpha. I might have, for example, just drawn an image at an arbitrary alpha on top of some background, then wanted to draw a border at half that alpha.

I could obviously just carry around an alpha value to be used for all the drawing and then use that for calculating relative alpha values. But since the context must already know what its current alpha value is, it seems reasonable to be able to just ask when needed.

steve

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >a couple of CGContext questions (From: Steve Christensen <email@hidden>)
 >Re: a couple of CGContext questions (From: Laurence Harris <email@hidden>)
 >Re: a couple of CGContext questions (From: Steve Christensen <email@hidden>)
 >Re: a couple of CGContext questions (From: David Duncan <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.