Skip navigation.
 
mlRe: How to highlight an image with transparency [SOLUTION]
FROM : Andrew Platzer
DATE : Wed Jan 16 22:23:10 2002

On Monday, January 14, 2002, at 05:10 , John Blackburn wrote:
> With Andrew's instruction, here's a working result:
> ...
> -(void)drawImage:(NSImage*)theImage atPoint:(NSPoint)where
> asSelected:(BOOL)selected
> {
> On Monday, January 14, 2002, at 01:04 PM, Andrew Platzer wrote:

>> On Monday, January 14, 2002, at 12:25 , John Blackburn wrote:
>>> What's the proper composite for highlighting an image which contains
>>> transparency?  NSCompositePlusDarker seems the logical choice, but it
>>> draws black for transparent pixels in the image.  I've tried all of the
>>> combinations of the composite modes I can think of, but none work
>>> exactly right.  I just want to highlight arbitrarily-shaped image just
>>> as Finder does with icons.

>>
>> Try NSCompositeSourceAtop with black at 50% alpha.


I would suggest keeping the darkened image around between calls to
drawRect: since creating a cached image rep involves creating an offscreen
window, drawing, etc. A lot of overhead that can be avoided.

Andrew


Related mailsAuthorDate
mlHow to highlight an image with transparency John Blackburn Jan 14, 21:25
mlRe: How to highlight an image with transparency Andrew Platzer Jan 14, 22:04
mlHow to highlight an image with transparency [SOLUTION] John Blackburn Jan 15, 02:10
mlRe: How to highlight an image with transparency [SOLUTION] Andrew Platzer Jan 16, 22:23