Re: Looking for alpha channel solution for transparencies
Re: Looking for alpha channel solution for transparencies
- Subject: Re: Looking for alpha channel solution for transparencies
- From: Brian Webster <email@hidden>
- Date: Fri, 30 Nov 2001 17:16:41 -0600
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