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: Looking for alpha channel solution for transparencies



On Friday, November 30, 2001, at 04:23 PM, cocoa-dev-
email@hidden wrote:

Next I created a CustomView class in Project Builder where I used some of
the alpha channel methods from the NSColor and NSImage classes with each of
these files. The results were the same for each file, which was a
transparency of the entire image, even the parts that weren't masked as well
and the part that was supposed to be completely transparent was white.

Which methods exactly are you using to draw the image? You should try NSImage's compositeToPoint:operation: method, and the key is to pass in NSCompositeSourceOver for the operation: parameter so that it will respect your alpha mask. You should also fill the view with transparent color before drawing the image. So, something like this:

-(void)drawRect:(NSRect)rect
{
[[NSColor clearColor] set];
NSRectFill([self bounds]);
[myImage compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver];
}

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster




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.