[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Drawing transparent images?
From: |
Alexander Malmberg |
Subject: |
Re: Drawing transparent images? |
Date: |
Sun, 02 Nov 2003 18:46:33 +0100 |
Björn Giesler wrote:
> Hi,
>
> I'm trying to create a transparent NSImage from my program,
> but all I get is a grey block,
How do you check what you got in the image?
[snip]
> [[NSColor clearColor] set];
> NSRectFill(NSMakeRect(0, 0, size.width, size.height));
This is a noop. Drawing an invisible rectangle doesn't change the
contents of the buffer. What you want is probably:
NSRectFillUsingOperation(NSMakeRect(...), NSCompositeClear);
which will clear the buffer. NSCompositeCopy and setting the color would
also work. A plain NSRectFill() is equivalent to using
NSCompositeSourceOver.
> [[NSColor blackColor] set];
This is also a noop. The color used to draw the text will come from the
attributes of the string. It's black by default. If you want to force it
black, do:
[str addAttribute: NSForegroundColorAttributeName
value: [NSColor blackColor]
range: NSMakeRange(0,[[str string] length)];
> [str drawAtPoint: NSZeroPoint];
>
> All I get is a grey box. If I pass hasAlpha: NO, I get a grey
> box with some text on it, but it's still grey, not transparent.
>
> Is this a known bug?
back-art doesn't do text drawing in buffers with alpha (ie. the alpha
channel is ignored, which causes problems). It will probably be a while
before I get around to fixing this (I want to clean up the code involved
before adding new stuff).
- Alexander Malmberg