Skip navigation.
 
mlGetting CGContext's alpha
FROM : David Dunham
DATE : Tue Aug 22 19:39:20 2006

I want to fade text and graphics. The former I handle by calling

CGContextRef    context = (CGContextRef) [[NSGraphicsContext 
currentContext] graphicsPort];
CGContextSetAlpha(context, alpha);

before rendering the text. But my graphics is an NSImage, drawn by

[fIcon drawInRect: cellFrame fromRect: b operation: 
NSCompositeSourceOver fraction: 1.0];

Obviously, I could fix this by changing the "1.0" to "alpha" (well, 
maybe it's not obvious that this call overrides the CGContext's 
settings). Unfortunately, due to encapsulation, the object that's 
drawing the NSImage has no way of getting my "alpha" variable. So it 
would make sense to get it from the CGContext. Except that there 
doesn't seem to be an accessor.

Or is there a different way to draw an NSImage, using the current 
context?

David Dunham    A Sharp, LLC
Voice/Fax: 206 783 7404    http://a-sharp.com
"People seem to misinterpret complexity as sophistication" -- Niklaus 
Wirth

Related mailsAuthorDate
No related mails found.